Symfony Plugin sfDoctrineActAsTaggablePlugin funktioniert nicht

Ich möchte einigen Objekten meines Doktrinenmodells einige Tags zuweisen.

Ich fand sfDoctrineActAsTaggablePlugin das scheint genau das zu sein, was ich brauche.

Das Problem ist, dass beim Speichern eines Taggable-Objekts die folgende Fehlermeldung angezeigt wird:

Unknown record property / related component "saved_tags" on "Mishidea"

Mishidea ist der Name der Klasse / Tabelle, die ich als Taggable kennzeichnen möchte.

Hier ist der zugehörige Teil meiner schema.yml-Datei:

Mishidea:
  connection: doctrine
  actAs: {Timestampable: ~ , Taggable: ~ }      
  tableName: mishidea
  columns:
    idea_id:
      type: integer(4)
      primary: true
      autoincrement: true
    idea_title:
      type: string()
      notnull: true
      primary: false
    idea_summary:
      type: string()
      notnull: true
      primary: false
    idea_description:
      type: string()
      notnull: true
      primary: false
    idea_up:
      type: integer(8)
      notnull: true
      default: 0
      primary: false
    idea_down:
      type: integer(8)
      notnull: true
      default: 0
      primary: false
    idea_confirmation:
      type: boolean(1)
      default: false
      primary: false
    group_id:
      type: integer(4)
      notnull: false
      primary: false
  relations:
    Mishgroup:
      local: group_id
      foreign: group_id
      type: one
    Ideacomment:
      local: idea_id
      foreign: idea_id
      type: many
    Mishdocument:
      local: idea_id
      foreign: idea_id
      type: many
    RelIdeafollower:
      local: idea_id
      foreign: idea_id
      type: many

Ich habe auch andere Syntaxtypen für das actAs-Attribut der Klasse ausprobiert, z. B .:

actAs:
    Timestampable: ~
    Taggable: ~

und

actAs:[Timestampable,Taggable]

Aber es ist nicht das Problem, wie ich bekomme:

$timestampable0 = new Doctrine_Template_Timestampable();
$taggable0 = new Taggable();
$this->actAs($timestampable0);
$this->actAs($taggable0);

in der BaseMishidea.php Klasse meines Modells.

Ich verstehe nicht, warum die Mishidea-Klasse nicht die Attribute erhält, die die Taggable-Klasse hinzufügen sollte, da das Modell das Verhalten über die Anweisung $ this-> actAs () hinzuzufügen scheint.

Wie bekomme ich dieses Plugin zum Laufen?

Wenn dies hilft, verwende ich Symfony 1.4 mit MySQL / InnoDB und habe es zuvor mit dem PostgreSql-DBMS versucht, mit dem gleichen Ergebnis.

Ihre Hilfe wäre sehr dankbar.

Vielen Dan

FuzzyTern

EDIT1 - In Bezug auf das, was Johnwards gesagt hat: Kann jemand bestätigen, dass das Taggable-Verhalten in der Datei schema.yml über "actAs:" und nicht über "templates:" hinzugefügt wurde? Das ist, was ich hier und da gelesen habe (siehe meinen Kommentar zu Johnwards 'Post), aber da keine der beiden Lösungen für mich funktioniert, bin ich mir nicht sicher. Bei Verwendung des Schlüsselworts "templates" erhalte ich:

Unknown method Mishidea::addTag

und die spezifischen Klassen des Modells werden nicht generiert.

EDIT2 - Nach einer weiteren Untersuchung stellte ich fest, dass der Symfony-Stack-Trace interessant ist. In der Tat, wenn ich tue:

$idea = new Mishidea();
$idea->save();

Der TaggableListener wird aufgerufen (Punkt 8 im Stack-Trace unten), was zeigt, dass die Beziehung funktioniert. Aber dann verstehe ich nicht was los ist und führe zur Ausnahme.

Stack trace:

1. at ()
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record/Filter/Standard.php line 55 ...

    public function filterGet(Doctrine_Record $record, $name)

    {

        throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));

    }

}

2. at Doctrine_Record_Filter_Standard->filterGet(object('Mishidea'), 'saved_tags')
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php line 1374 ...
3. at Doctrine_Record->_get('saved_tags', 1)
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php line 1333 ...
4. at Doctrine_Record->get('saved_tags')
in n/a line n/a ...
5. at call_user_func_array(array(object('Mishidea'), 'get'), array('saved_tags'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecord.class.php line 212 ...
6. at sfDoctrineRecord->__call('getSavedTags', array())
in n/a line n/a ...
7. at Mishidea->getSavedTags()
in SF_ROOT_DIR/plugins/sfDoctrineActAsTaggablePlugin/lib/TaggableTemplate.class.php line 93 ...
8. at TaggableListener->postSave(object('Doctrine_Event'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record/Listener/Chain.php line 237 ...
9. at Doctrine_Record_Listener_Chain->postSave(object('Doctrine_Event'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php line 355 ...
10. at Doctrine_Record->invokeSaveHooks('post', 'save', object('Doctrine_Event'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php line 112 ...
11. at Doctrine_Connection_UnitOfWork->saveGraph(object('Mishidea'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php line 1691 ...
12. at Doctrine_Record->save()
in SF_ROOT_DIR/apps/frontend/modules/idea/actions/actions.class.php line 24 ...

Wenn jemand den Code für einen beliebigen Punkt des Stack-Trace sehen möchte (hier wird nur 1. erweitert), fragen Sie einfach. Jeder Vorschlag wird begrüßt.

Antworten auf die Frage(6)

Ihre Antwort auf die Frage