是否有可能在Doctrine中的一个表上有多个slug?
我在我的yaml文件中尝试过这个:
Article:
tableName: tst_article
actAs:
Sluggable:
unique: true
fields: [title]
canUpdate: true
Sluggable:
unique: true
fields: [text]
name: secondSlug
columns:
id:
type: integer(8)
primary: true
autoincrement: true
category_id:
type: integer(8)
title:
type: text(255)
text:
type: clob
Run Code Online (Sandbox Code Playgroud)
但是在生成sql之后只生成了第二个插件......
有可能的.在你的表定义中写:
public function setUp() {
parent::setUp();
$sluggable0 = new Doctrine_Template_Sluggable(array(
'fields' => array(0 => 'name'),
'unique' => true,
'canUpdate' => true
));
$this->actAs($sluggable0);
$sluggable1 = new Doctrine_Template_Sluggable(array(
'fields' => array(0 => 'native_name'),
'unique' => false,
'canUpdate' => false,
'name' => 'native_name_slug'
));
$this->actAs($sluggable1);
}
Run Code Online (Sandbox Code Playgroud)
问题出在YAML本身.你有这样的事情:
keyA:
keyB: value
keyB: value
Run Code Online (Sandbox Code Playgroud)
什么可能被翻译成:
array(
'keyA' => array(
'keyB' => 'value',
'keyB' => 'value'
)
);
Run Code Online (Sandbox Code Playgroud)
所以当你看到有定义,keyB然后keyB被新值覆盖.所以在你的YAML文件中,第二个定义会覆盖第一个定义.
怎么解决?我不知道,但我会做一些研究.现在你被迫用纯PHP声明你的模型.