Php Symfony 1.4路由:来自不同类的字段
如何创建路由并将其与来自不同类的字段相匹配? 可能吗?是否有自定义路由类 例如,我有两门课:Php Symfony 1.4路由:来自不同类的字段,php,symfony1,symfony-1.4,Php,Symfony1,Symfony 1.4,如何创建路由并将其与来自不同类的字段相匹配? 可能吗?是否有自定义路由类 例如,我有两门课: File: columns: name: { type: string(255), unique: true, notnull: true } ... Link: columns: file_id: { type: bigint, notnull: true } ticket: { type: string(64), notnull: true } rela
File:
columns:
name: { type: string(255), unique: true, notnull: true }
...
Link:
columns:
file_id: { type: bigint, notnull: true }
ticket: { type: string(64), notnull: true }
relations:
File:
local: file_id
foreign: id
foreignAlias: links
...
现在假设我想创建这样一条路由:mysite.com/:ticket/:name
如您所见,ticket
是Link
表的一个字段,name
是文件
表的一个字段。有没有办法在symfony 1.4中创建这样的链接
第一种解决方案是更改文件
表的主键并将其设置为其名称。我知道这一点,但我想知道是否有办法通过路由来处理这个问题
我的目标是,当我调用getObject方法时,它返回一个带有已发送票证的链接对象,但是还应该检查是否存在以及与已发送文件名的关系。IIRC您可以这样做:
my_route:
url: /:ticket/:name
class: sfDoctrineRoute
param: { module: yourModule, action: yourAction }
options: { type: object, model: Link, method: findLinkWithSendTicket }
然后symfony应该调用LinkTable::findLinkWithSendTicket
方法并向其传递参数,以便您可以使用它来获取对象
链接可能会有所帮助: