Symfony:如何在generator.yml中添加聚合字段?
我正在使用 Doctrine 在 Symfony 1.4 中对我的应用程序进行原型设计。我有两个模型,遭遇和照片。一次邂逅可以有很多照片,并且在 schema.yml 中设置了正确的一对多关系。
我使用 ./symfony generated:app backend 生成了一个后端。一切工作正常,但我现在想在我的遭遇列表中添加一个计数字段,我认为我应该能够在生成器.yml 中执行此操作。在我的 Encounters.class.php 中,我有以下方法:
public function getPhotoCount() {
return count($this->CcPhotos);
}
我的问题是如何在运行此方法的生成器.yml 中添加新字段。我尝试了 %%photo_count%% 但我认为这是用于字符串替换。
generator:
class: sfDoctrineGenerator
param:
model_class: CcEncounters
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: cc_encounters
with_doctrine_route: true
actions_base_class: sfActions
config:
actions: ~
fields: ~
list: ~
filter: ~
form: ~
edit: ~
new:
display: [_camera_id, longitude, latitude, elevation, New Photos]
I am prototyping my application in Symfony 1.4 using Doctrine. I have two models, encounters and photos. One encounter can have many photos and the correct one-to-many relationship is set up in schema.yml.
I have generated a backend using ./symfony generate:app backend. Everything is working fine but I now want to add a count field to my encounters list which I think I should be able to do in generator.yml. In my Encounters.class.php I have the following method:
public function getPhotoCount() {
return count($this->CcPhotos);
}
My questions is how can I add a new field in generator.yml which runs this method. I tried %%photo_count%% but I think this is intended for string substitution.
generator:
class: sfDoctrineGenerator
param:
model_class: CcEncounters
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: cc_encounters
with_doctrine_route: true
actions_base_class: sfActions
config:
actions: ~
fields: ~
list: ~
filter: ~
form: ~
edit: ~
new:
display: [_camera_id, longitude, latitude, elevation, New Photos]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了这个问题。只需添加以下内容即可:
其中 'photo_count' 与名为 getPhotoCount 的访问器方法匹配
I resolved this. It was as simple as adding:
Where 'photo_count' matches an accessor method called getPhotoCount