浏览代码

[mapping] updated annotations and documentation related

gediminasm 13 年之前
父节点
当前提交
03a7fd5fc7

+ 5 - 0
README.md

@@ -7,6 +7,11 @@
 **Note:** Use 2.1.x tag in order to use extensions based on Doctrine2.1.x versions. Currently
 master branch is based on 2.2.x versions and may not work with 2.1.x components
 
+**2011-10-30**
+
+- Support for doctrine common **2.2.x** with backward compatibility. Be sure to use all components
+from the specific version, etc.: **2.2.x** or **2.1.x** both are supported
+
 **2011-10-23**
 
 - [@everzet](https://github.com/everzet) has contributed the **Translator** behavior, which indeed

+ 17 - 3
doc/annotations.md

@@ -68,10 +68,24 @@ mapping and listeners:
 
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
+    Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace(
+        'Gedmo\\Mapping\\Annotation',
+        'path/to/gedmo/extension/library'
+    );
     
     $chain = new \Doctrine\ORM\Mapping\Driver\DriverChain;
-    $chain->addDriver($annotationDriver, 'Gedmo\Translatable\Entity');
-    $chain->addDriver($annotationDriver, 'Gedmo\Tree\Entity');
+    $annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($annotationReader, array(
+        __DIR__.'/../your/application/source/Entity',
+        'path/to/gedmo/extension/library'.'/Gedmo/Translatable/Entity',
+        'path/to/gedmo/extension/library'.'/Gedmo/Loggable/Entity',
+        'path/to/gedmo/extension/library'.'/Gedmo/Tree/Entity',
+    ));
+    // drivers
+    $driverChain->addDriver($annotationDriver, 'Gedmo\\Translatable\\Entity');
+    $driverChain->addDriver($annotationDriver, 'Gedmo\\Loggable\\Entity');
+    $driverChain->addDriver($annotationDriver, 'Gedmo\\Tree\\Entity');
+    $driverChain->addDriver($annotationDriver, 'Entity');
+    $config->setMetadataDriverImpl($driverChain);
     
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataDriverImpl($chain);
@@ -99,7 +113,7 @@ mapping and listeners:
     );
     $em = \Doctrine\ORM\EntityManager::create($conn, $config, $evm);
 
-**Notice:** that symfony2 DoctrineExtensionsBundle does it automatically this
+**Notice:** that symfony2 StofDoctrineExtensionsBundle does it automatically this
 way you will maintain a single instance of annotation reader. It relates only
 to doctrine-common-2.1.x branch and newer.
 

+ 1 - 0
lib/Gedmo/Mapping/Annotation/Language.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * Language annotation for Translatable behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 1 - 0
lib/Gedmo/Mapping/Annotation/Locale.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * Locale annotation for Translatable behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 2 - 0
lib/Gedmo/Mapping/Annotation/Loggable.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * Loggable annotation for Loggable behavioral extension
  *
  * @Annotation
+ * @Target("CLASS")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation
@@ -17,6 +18,7 @@ use Doctrine\Common\Annotations\Annotation;
  */
 final class Loggable extends Annotation
 {
+    /** @var string */
     public $logEntryClass;
 }
 

+ 7 - 0
lib/Gedmo/Mapping/Annotation/Slug.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * Slug annotation for Sluggable behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation
@@ -17,11 +18,17 @@ use Doctrine\Common\Annotations\Annotation;
  */
 final class Slug extends Annotation
 {
+    /** @var array<string> @required */
     public $fields = array();
+    /** @var boolean */
     public $updatable = true;
+    /** @var string */
     public $style = 'default'; // or "camel"
+    /** @var boolean */
     public $unique = true;
+    /** @var string */
     public $separator = '-';
+    /** @var array<Gedmo\Mapping\Annotation\SlugHandler> */
     public $handlers = array();
 }
 

+ 4 - 1
lib/Gedmo/Mapping/Annotation/SlugHandler.php

@@ -20,6 +20,7 @@ use Doctrine\Common\Annotations\Annotation;
  * }, separator="-", updatable=false)
  *
  * @Annotation
+ * @Target("ANNOTATION")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation
@@ -29,7 +30,9 @@ use Doctrine\Common\Annotations\Annotation;
  */
 final class SlugHandler extends Annotation
 {
-    public $class = '';
+    /** @var string @required */
+    public $class;
+    /** @var array<Gedmo\Mapping\Annotation\SlugHandlerOption> */
     public $options = array();
 }
 

+ 3 - 0
lib/Gedmo/Mapping/Annotation/SlugHandlerOption.php

@@ -20,6 +20,7 @@ use Doctrine\Common\Annotations\Annotation;
  * }, separator="-", updatable=false)
  *
  * @Annotation
+ * @Target("ANNOTATION")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation
@@ -29,7 +30,9 @@ use Doctrine\Common\Annotations\Annotation;
  */
 final class SlugHandlerOption extends Annotation
 {
+    /** @var string */
     public $name;
+    /** @var mixed */
     public $value;
 }
 

+ 2 - 1
lib/Gedmo/Mapping/Annotation/SortableGroup.php

@@ -12,8 +12,9 @@ use Doctrine\Common\Annotations\Annotation;
  * @subpackage SortableGroup
  * @link http://www.gediminasm.org
  * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
- * 
+ *
  * @Annotation
+ * @Target("PROPERTY")
  */
 final class SortableGroup extends Annotation
 {

+ 2 - 1
lib/Gedmo/Mapping/Annotation/SortablePosition.php

@@ -12,8 +12,9 @@ use Doctrine\Common\Annotations\Annotation;
  * @subpackage SortableGroup
  * @link http://www.gediminasm.org
  * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
- * 
+ *
  * @Annotation
+ * @Target("PROPERTY")
  */
 final class SortablePosition extends Annotation
 {

+ 4 - 0
lib/Gedmo/Mapping/Annotation/Timestampable.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * Timestampable annotation for Timestampable behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation
@@ -17,8 +18,11 @@ use Doctrine\Common\Annotations\Annotation;
  */
 final class Timestampable extends Annotation
 {
+    /** @var string */
     public $on = 'update';
+    /** @var string */
     public $field;
+    /** @var mixed */
     public $value;
 }
 

+ 1 - 0
lib/Gedmo/Mapping/Annotation/Translatable.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * Translatable annotation for Translatable behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 2 - 0
lib/Gedmo/Mapping/Annotation/TranslationEntity.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * TranslationEntity annotation for Translatable behavioral extension
  *
  * @Annotation
+ * @Target("CLASS")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation
@@ -17,6 +18,7 @@ use Doctrine\Common\Annotations\Annotation;
  */
 final class TranslationEntity extends Annotation
 {
+    /** @var string @required */
     public $class;
 }
 

+ 2 - 0
lib/Gedmo/Mapping/Annotation/Tree.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * Tree annotation for Tree behavioral extension
  *
  * @Annotation
+ * @Target("CLASS")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation
@@ -17,6 +18,7 @@ use Doctrine\Common\Annotations\Annotation;
  */
 final class Tree extends Annotation
 {
+    /** @var string */
     public $type = 'nested';
 }
 

+ 2 - 0
lib/Gedmo/Mapping/Annotation/TreeClosure.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * TreeClosure annotation for Tree behavioral extension
  *
  * @Annotation
+ * @Target("CLASS")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation
@@ -17,6 +18,7 @@ use Doctrine\Common\Annotations\Annotation;
  */
 final class TreeClosure extends Annotation
 {
+    /** @var string @required */
     public $class;
 }
 

+ 1 - 0
lib/Gedmo/Mapping/Annotation/TreeLeft.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * TreeLeft annotation for Tree behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 1 - 0
lib/Gedmo/Mapping/Annotation/TreeLevel.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * TreeLevel annotation for Tree behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 1 - 0
lib/Gedmo/Mapping/Annotation/TreeParent.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * TreeParent annotation for Tree behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 1 - 0
lib/Gedmo/Mapping/Annotation/TreeRight.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * TreeRight annotation for Tree behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 1 - 0
lib/Gedmo/Mapping/Annotation/TreeRoot.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * TreeRoot annotation for Tree behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 1 - 0
lib/Gedmo/Mapping/Annotation/Versioned.php

@@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\Annotation;
  * Versioned annotation for Loggable behavioral extension
  *
  * @Annotation
+ * @Target("PROPERTY")
  *
  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  * @package Gedmo.Mapping.Annotation

+ 1 - 1
lib/Gedmo/Version.php

@@ -20,7 +20,7 @@ final class Version
     /**
      * Current version of extensions
      */
-    const VERSION = '2.1.0-DEV';
+    const VERSION = '2.2.0-DEV';
 
     /**
      * Checks the dependent ORM library components