Skip to content

Commit

Permalink
[mapping] updated annotations and documentation related
Browse files Browse the repository at this point in the history
  • Loading branch information
l3pp4rd committed Oct 30, 2011
1 parent 01c5b18 commit 03a7fd5
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 7 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions doc/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Language annotation for Translatable behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Locale annotation for Translatable behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
2 changes: 2 additions & 0 deletions lib/Gedmo/Mapping/Annotation/Loggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Loggable annotation for Loggable behavioral extension
*
* @Annotation
* @Target("CLASS")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand All @@ -17,6 +18,7 @@
*/
final class Loggable extends Annotation
{
/** @var string */
public $logEntryClass;
}

7 changes: 7 additions & 0 deletions lib/Gedmo/Mapping/Annotation/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Slug annotation for Sluggable behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand All @@ -17,11 +18,17 @@
*/
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();
}

5 changes: 4 additions & 1 deletion lib/Gedmo/Mapping/Annotation/SlugHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* }, separator="-", updatable=false)
*
* @Annotation
* @Target("ANNOTATION")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand All @@ -29,7 +30,9 @@
*/
final class SlugHandler extends Annotation
{
public $class = '';
/** @var string @required */
public $class;
/** @var array<Gedmo\Mapping\Annotation\SlugHandlerOption> */
public $options = array();
}

3 changes: 3 additions & 0 deletions lib/Gedmo/Mapping/Annotation/SlugHandlerOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* }, separator="-", updatable=false)
*
* @Annotation
* @Target("ANNOTATION")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand All @@ -29,7 +30,9 @@
*/
final class SlugHandlerOption extends Annotation
{
/** @var string */
public $name;
/** @var mixed */
public $value;
}

3 changes: 2 additions & 1 deletion lib/Gedmo/Mapping/Annotation/SortableGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
* @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
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Gedmo/Mapping/Annotation/SortablePosition.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
* @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
{
Expand Down
4 changes: 4 additions & 0 deletions lib/Gedmo/Mapping/Annotation/Timestampable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Timestampable annotation for Timestampable behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand All @@ -17,8 +18,11 @@
*/
final class Timestampable extends Annotation
{
/** @var string */
public $on = 'update';
/** @var string */
public $field;
/** @var mixed */
public $value;
}

1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Translatable annotation for Translatable behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
2 changes: 2 additions & 0 deletions lib/Gedmo/Mapping/Annotation/TranslationEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* TranslationEntity annotation for Translatable behavioral extension
*
* @Annotation
* @Target("CLASS")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand All @@ -17,6 +18,7 @@
*/
final class TranslationEntity extends Annotation
{
/** @var string @required */
public $class;
}

2 changes: 2 additions & 0 deletions lib/Gedmo/Mapping/Annotation/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Tree annotation for Tree behavioral extension
*
* @Annotation
* @Target("CLASS")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand All @@ -17,6 +18,7 @@
*/
final class Tree extends Annotation
{
/** @var string */
public $type = 'nested';
}

2 changes: 2 additions & 0 deletions lib/Gedmo/Mapping/Annotation/TreeClosure.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* TreeClosure annotation for Tree behavioral extension
*
* @Annotation
* @Target("CLASS")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand All @@ -17,6 +18,7 @@
*/
final class TreeClosure extends Annotation
{
/** @var string @required */
public $class;
}

1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/TreeLeft.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* TreeLeft annotation for Tree behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/TreeLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* TreeLevel annotation for Tree behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/TreeParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* TreeParent annotation for Tree behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/TreeRight.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* TreeRight annotation for Tree behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/TreeRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* TreeRoot annotation for Tree behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
1 change: 1 addition & 0 deletions lib/Gedmo/Mapping/Annotation/Versioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Versioned annotation for Loggable behavioral extension
*
* @Annotation
* @Target("PROPERTY")
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @package Gedmo.Mapping.Annotation
Expand Down
2 changes: 1 addition & 1 deletion lib/Gedmo/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 03a7fd5

Please sign in to comment.