Changeset 4094
- Timestamp:
- 05/24/07 03:50:47 (6 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelActAsTaggableBehaviorPlugin/README
r4085 r4094 171 171 * '''tags''': tags that have been attached to the object, but not yet saved. Contract: tags are disjoin of (saved_tags union removed_tags) 172 172 * '''saved_tags''': tags that are presently saved in the database 173 * '''removed_tags''': tags that are presently saved in the database, but which will be removed at the next save(). Contract: removed_tags are included in saved_tags173 * '''removed_tags''': tags that are presently saved in the database, but which will be removed at the next save(). Contract: removed_tags are disjoin of (tags union saved_tags) 174 174 175 175 When required, the saved_tags namespace is filled with the tags previously present in the database. The tagging methods have an action on these three namespaces, which are serialized in the database after the Propel object gets saved. plugins/sfPropelActAsTaggableBehaviorPlugin/lib/sfPropelActAsTaggableBehavior.class.php
r4085 r4094 29 29 * The plugin associates a parameterHolder to Propel objects, with 3 namespaces: 30 30 * 31 * - tags : tags that have been attached to the object, but not yet saved. 32 * contract : tags are disjoin of (saved_tags union removed_tags) 33 * 34 * - saved_tags : tags that are presently saved in the database 35 * 36 * - removed_tags : tags that are presently saved in the database, but which 37 * will be removed at the next save() 38 * contract : removed_tags are included in saved_tags 31 * - tags: 32 * Tags that have been attached to the object, but not yet saved. 33 * Contract: tags are disjoin of (saved_tags union removed_tags) 34 * 35 * - saved_tags: 36 * Tags that are presently saved in the database 37 * 38 * - removed_tags: 39 * Tags that are presently saved in the database, but which will be removed 40 * at the next save() 41 * Contract: removed_tags are disjoin of (tags union saved_tags) 39 42 * 40 43 * … … 82 85 self::clear_tags($object); 83 86 self::getTagsHolder($object)->add($tags, 'tags'); 87 } 88 89 private static function add_saved_tag(BaseObject $object, $tag) 90 { 91 self::getTagsHolder($object)->set($tag, $tag, 'saved_tags'); 84 92 } 85 93 … … 154 162 unset($removed_tags[$tagname]); 155 163 self::set_removed_tags($object, $removed_tags); 164 self::add_saved_tag($object, $tagname); 156 165 } 157 166 else plugins/sfPropelActAsTaggableBehaviorPlugin/test/unit/sfPropelActAsTaggableBehaviorTest.php
r4085 r4094 83 83 $t->ok(!$object->hasTag(), 'tags can all be removed at once'); 84 84 85 $object = _create_object(); 86 $object->addTag('toto,tutu,tata'); 87 $object->save(); 88 $id = $object->getPrimaryKey(); 89 $object = call_user_func(array(_create_object()->getPeer(), 'retrieveByPk'), $id); 90 $object->removeTag('tata'); 91 $object->addTag('tata'); 92 $object->save(); 93 $object = call_user_func(array(_create_object()->getPeer(), 'retrieveByPk'), $id); 94 $object_tags = $object->getTags(); 95 $t->ok(count($object_tags) == 3, 'when removing one previously saved tags, then restoring it, and then saving it again, tags are not duplicated'); 96 97 $object = _create_object(); 98 $object->addTag('toto,tutu,tata'); 99 $object->save(); 100 $object->removeAllTags(); 101 $object->addTag('toto,tutu,tata'); 102 $object->save(); 103 $id = $object->getPrimaryKey(); 104 $object = call_user_func(array(_create_object()->getPeer(), 'retrieveByPk'), $id); 105 $object_tags = $object->getTags(); 106 $t->ok(count($object_tags) == 3, 'when removing all previously saved tags, then restoring it, and then saving it again, tags are not duplicated'); 85 107 86 108 unset($object, $object2, $object2_copy); 87 109 die(); 88 110 89 111 // these tests check the various methods for applying tags to an object