Symfony plugin sfDoctrineActAsTaggablePlugin not working

强颜欢笑 提交于 2019-12-02 08:39:21

Whoop whoop!! I solved this problem, at last!

Well... The problem is that the sfDoctrineActAsTaggablePlugin plugin does work only for taggable objects which have an id property called precisely "id". I like to put the name of the entity in the name of my properties, that's why I called the idea of my taggable entity "idea_id".

As soon as I replaced "idea_id" by "id" everything worked like a charm (you may have several changes to do in the schema.yml and maybe even in the routing.yml file later on).

I don't know if I'm clear enough so don't hesitate to ask me further explanations.

Anyway that's a bit of a shame for this plugin, it is not generic enough (will report this to the developers).

BTW, all the syntaxes for actAs written in my first post are equivalent, use whichever you prefer.

Thank you all for your help, each reply was an encouragement without which I wouldn't have had the strength to find the bug ;).

Cheers

Possible Issues:

Make sure you have the plugin enabled

In ProjectConfiguration::setup, you should have

$this->enablePlugins(array(
  'sfDoctrineActAsCommentablePlugin', //plus other plugins, like Doctrine
));

Set Up Your Schema Correctly

It should look like this:

ModelClass:
  actAs:
    Taggable:
  columns: //etc

You should be using actAs not templates.

I don't believe you need to set an explicit relations for Tags, but I could be wrong about that. If you let me know, I will edit this answer.

Edit: Have you done a build all reload?

You need to add templates: [Taggable] to your schema not actAs.

Mishidea:
  connection: doctrine
  actAs: [Timestampable]    
  templates: [Taggable]  
  tableName: mishidea
  columns:
    idea_id:
      type: integer(4)
      primary: true
      autoincrement: true
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!