Browse Source

[docs] updated docs for new annotation mapping usage, closes #54

gediminasm 14 years ago
parent
commit
9c663df53d
2 changed files with 71 additions and 9 deletions
  1. 10 8
      README.markdown
  2. 61 1
      doc/annotations.md

+ 10 - 8
README.markdown

@@ -25,10 +25,18 @@ use these extensions from separate branch **doctrine2.0.x** or simply checkout t
 
 ### Latest updates
 
+**2011-05-23**
+
+- Recently **doctrine-common** library changed the way for annotation mapping in branch **3.0.x**
+If you are a **Symfony2** user, you will notice that shortly. Extensions were upgraded to support
+injection of annotation reader into listener which makes them compatible with these changes. For more
+details look in **doc/annotations.md**
+
 **2011-05-07**
 
-- Tree **closure** strategy was refactored and now fully functional. I recommend to use it
-on huge trees which do not care about ordering of nodes, like file-folder tree for instance.
+- Tree **closure** strategy was refactored and now fully functional. Actually nested-set
+is performing faster during concurrent inserts and moving subtrees and it also supports
+ordering of nodes.
 - Also there are good news for ODM users, @mtotheikle is working on **materialized path**
 strategy for ODM Tree like documents.
 
@@ -38,12 +46,6 @@ strategy for ODM Tree like documents.
 translate any query components and filter or order by translated fields. I recommmend you
 to use it extensively since it is very performative also.
 
-**2011-04-11**
-
-- **Tree nestedset** was improved, now all in memory nodes are synchronized and do not require `$em->clear()` all the time.
-If you have any problems with new feature, open an issue.
-- Extensions now use only one listener instance for different object managers
-
 ### ODM MongoDB support
 
 List of extensions which support ODM

+ 61 - 1
doc/annotations.md

@@ -5,13 +5,73 @@ There will be introduction on usage with examples. For more detailed usage
 on extensions, refer to their specific documentation.
 
 Content:
-    
+
+- [New annotation mapping](#annotation_mapping) example for common3.0.x
 - [Tree](#tree)
 - [Translatable](#translatable)
 - [Sluggable](#sluggable)
 - [Timestampable](#timestampable)
 - [Loggable](#loggable)
 
+## New annotation mapping example for common3.0.x {#annotation_mapping}
+
+Recently there was an upgrade made for annotation reader in order to support
+more native way for annotation mapping in **common3.0.x** branch. Before that
+you had to make aliases for namespaces (like __gedmo:Translatable__), this strategy
+was limited and errors were not explainable. Now you have to add a **use** statement
+for each annotation you use in your mapping, see example bellow:
+
+    namespace MyApp\Entity;
+    
+    use Gedmo\Mapping\Annotation as Gedmo; // this will be like an alias before
+    use Doctrine\ORM\Mapping\Id; // includes single annotation
+    use Doctrine\ORM\Mapping as ORM;
+    
+    /**
+     * @ORM\Entity
+     * @Gedmo\TranslationEntity(class="something")
+     */
+    class Article
+    {
+        /**
+         * @Id
+         * @ORM\GeneratedValue
+         * @ORM\Column(type="integer")
+         */
+        private $id;
+        
+        /**
+         * @Gedmo\Translatable
+         * @Gedmo\Sluggable
+         * @ORM\Column(length=64)
+         */
+        private $title;
+        
+        /**
+         * @Gedmo\Slug
+         * @ORM\Column(length=64, unique=true)
+         */
+        private $slug;
+    }
+
+**Note:** this new mapping applies only if you use **doctrine-common** library at version **3.0.x**
+
+### Injecting the new annotation reader
+
+New annotation reader does not depend on any namespaces, for that reason you can use
+single reader instance for whole project. The example bellow shows how to inject it into
+listener:
+
+    $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader;
+    $translatable = new \Gedmo\Translatable\TranslationListener;
+    $translatable->setAnnotationReader($annotationReader);
+    $sluggable = new \Gedmo\Sluggable\SluggableListener;
+    $sluggable->setAnnotationReader($annotationReader);
+    // ...
+    $eventManager->addEventSubscriber($translatable);
+    $eventManager->addEventSubscriber($sluggable);
+    // ...
+
 ## Tree annotations {#tree}
 
 Tree can use diferent adapters. Currently **Tree** extension supports **NestedSet**