Skip to content

Commit

Permalink
make Property an annotation, instead of adding new annotaiton Field
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Jul 15, 2015
1 parent 0bf1430 commit e6c8d42
Show file tree
Hide file tree
Showing 80 changed files with 260 additions and 261 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Document/AbstractFile.php
Expand Up @@ -41,10 +41,10 @@ abstract class AbstractFile implements HierarchyInterface
/** @PHPCRODM\ParentDocument */
protected $parent;

/** @PHPCRODM\Field(type="date", property="jcr:created") */
/** @PHPCRODM\Property(type="date", property="jcr:created") */
protected $created;

/** @PHPCRODM\Field(type="string", property="jcr:createdBy") */
/** @PHPCRODM\Property(type="string", property="jcr:createdBy") */
protected $createdBy;

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/ODM/PHPCR/Document/Resource.php
Expand Up @@ -56,27 +56,27 @@ class Resource
protected $parent;

/**
* @PHPCRODM\Field(type="binary", property="jcr:data")
* @PHPCRODM\Property(type="binary", property="jcr:data")
*/
protected $data;

/**
* @PHPCRODM\Field(type="string", property="jcr:mimeType")
* @PHPCRODM\Property(type="string", property="jcr:mimeType")
*/
protected $mimeType = 'application/octet-stream';

/**
* @PHPCRODM\Field(type="string", property="jcr:encoding", nullable=true)
* @PHPCRODM\Property(type="string", property="jcr:encoding", nullable=true)
*/
protected $encoding;

/**
* @PHPCRODM\Field(type="date", property="jcr:lastModified")
* @PHPCRODM\Property(type="date", property="jcr:lastModified")
*/
protected $lastModified;

/**
* @PHPCRODM\Field(type="string", property="jcr:lastModifiedBy")
* @PHPCRODM\Property(type="string", property="jcr:lastModifiedBy")
*/
protected $lastModifiedBy;

Expand Down
Expand Up @@ -19,12 +19,35 @@

namespace Doctrine\ODM\PHPCR\Mapping\Annotations;

use Doctrine\Common\Annotations\Annotation;

/**
* @Annotation
* @Target("PROPERTY")
* base class for all property types
*/
final class Field extends TranslatableProperty
abstract class BaseProperty
{
/**
* The PHPCR property name to use
* @var string
*/
public $property;

/**
* @var string
*/
public $type = 'undefined';

/**
* @var boolean
*/
public $multivalue = false;

/**
* @var string
*/
public $assoc;

/**
* @var boolean
*/
public $nullable = false;
}
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Binary.php
Expand Up @@ -21,13 +21,13 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Binary annotation is deprecated, use @Field(type="binary") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Binary annotation is deprecated, use @Property(type="binary") instead.', E_USER_DEPRECATED);

/**
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="Binary") instead.
* @deprecated Use @Property(type="Binary") instead.
*/
final class Binary extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Boolean.php
Expand Up @@ -21,13 +21,13 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Boolean annotation is deprecated, use @Field(type="boolean") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Boolean annotation is deprecated, use @Property(type="boolean") instead.', E_USER_DEPRECATED);

/**
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="boolean") instead.
* @deprecated Use @Property(type="boolean") instead.
*/
final class Boolean extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Date.php
Expand Up @@ -21,13 +21,13 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Date annotation is deprecated, use @Field(type="date") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Date annotation is deprecated, use @Property(type="date") instead.', E_USER_DEPRECATED);

/**
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="date") instead.
* @deprecated Use @Property(type="date") instead.
*/
final class Date extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Decimal.php
Expand Up @@ -21,15 +21,15 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Decimal annotation is deprecated, use @Field(type="decimal") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Decimal annotation is deprecated, use @Property(type="decimal") instead.', E_USER_DEPRECATED);

/**
* Large numbers bcmath compatible strings.
*
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="decimal") instead.
* @deprecated Use @Property(type="decimal") instead.
*/
final class Decimal extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Double.php
Expand Up @@ -21,13 +21,13 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Double annotation is deprecated, use @Field(type="double") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Double annotation is deprecated, use @Property(type="double") instead.', E_USER_DEPRECATED);

/**
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="double") instead.
* @deprecated Use @Property(type="double") instead.
*/
final class Double extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Float.php
Expand Up @@ -21,15 +21,15 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Float annotation is deprecated, use @Field(type="double") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Float annotation is deprecated, use @Property(type="double") instead.', E_USER_DEPRECATED);

/**
* Convenience alias for Double.
*
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="double") instead.
* @deprecated Use @Property(type="double") instead.
*/
final class Float extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Int.php
Expand Up @@ -21,15 +21,15 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Int annotation is deprecated, use @Field(type="long") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Int annotation is deprecated, use @Property(type="long") instead.', E_USER_DEPRECATED);

/**
* Convenience alias for Long.
*
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="long") instead.
* @deprecated Use @Property(type="long") instead.
*/
final class Int extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Long.php
Expand Up @@ -21,13 +21,13 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Long annotation is deprecated, use @Field(type="long") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Long annotation is deprecated, use @Property(type="long") instead.', E_USER_DEPRECATED);

/**
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="long") instead.
* @deprecated Use @Property(type="long") instead.
*/
final class Long extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Name.php
Expand Up @@ -21,15 +21,15 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Name annotation is deprecated, use @Field(type="name") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Name annotation is deprecated, use @Property(type="name") instead.', E_USER_DEPRECATED);

/**
* String that is restricted to name with optional namespace.
*
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="name") instead.
* @deprecated Use @Property(type="name") instead.
*/
final class Name extends TranslatableProperty
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Path.php
Expand Up @@ -21,15 +21,15 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Path annotation is deprecated, use @Field(type="path") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Path annotation is deprecated, use @Property(type="path") instead.', E_USER_DEPRECATED);

/**
* String that is an absolute or relative path in the repository.
*
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="path") instead.
* @deprecated Use @Property(type="path") instead.
*/
final class Path extends TranslatableProperty
{
Expand Down
32 changes: 6 additions & 26 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Property.php
Expand Up @@ -18,36 +18,16 @@
*/

namespace Doctrine\ODM\PHPCR\Mapping\Annotations;


/**
* base class for all property types
* @Annotation
* @Target("PROPERTY")
*
* Represent a standard property.
*/
class Property
class Property extends BaseProperty
{
/**
* The PHPCR property name to use
* @var string
*/
public $property;

/**
* @var string
*/
public $type = 'undefined';

/**
* @var boolean
*/
public $multivalue = false;

/**
* @var string
*/
public $assoc;

/**
* @var boolean
*/
public $nullable = false;
public $translated = false;
}
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/String.php
Expand Up @@ -21,13 +21,13 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @String annotation is deprecated, use @Field(type="string") instead.', E_USER_DEPRECATED);
//@trigger_error('The @String annotation is deprecated, use @Property(type="string") instead.', E_USER_DEPRECATED);

/**
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="string") instead.
* @deprecated Use @Property(type="string") instead.
*/
final class String extends TranslatableProperty
{
Expand Down
Expand Up @@ -19,12 +19,8 @@

namespace Doctrine\ODM\PHPCR\Mapping\Annotations;
/**
* Base class for all the translatable properties (i.e. every property but Uuid and Version)
* @deprecated Use Property instead
*/
class TranslatableProperty extends Property
{
/**
* @var boolean
*/
public $translated = false;
}
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uri.php
Expand Up @@ -21,15 +21,15 @@

use Doctrine\Common\Annotations\Annotation;

//@trigger_error('The @Uri annotation is deprecated, use @Field(type="uri") instead.', E_USER_DEPRECATED);
//@trigger_error('The @Uri annotation is deprecated, use @Property(type="uri") instead.', E_USER_DEPRECATED);

/**
* String that is validated to be an URI.
*
* @Annotation
* @Target("PROPERTY")
*
* @deprecated Use @Field(type="uri") instead.
* @deprecated Use @Property(type="uri") instead.
*/
final class Uri extends TranslatableProperty
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Mapping/Annotations/Uuid.php
Expand Up @@ -25,7 +25,7 @@
* @Annotation
* @Target("PROPERTY")
*/
final class Uuid extends Property
final class Uuid extends BaseProperty
{
/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php
Expand Up @@ -118,7 +118,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
$mapping['fieldName'] = $property->getName();

foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) {
if ($fieldAnnot instanceof ODM\Property) {
if ($fieldAnnot instanceof ODM\BaseProperty) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapField($mapping);
} elseif ($fieldAnnot instanceof ODM\Id) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/Models/Blog/Comment.php
Expand Up @@ -18,7 +18,7 @@ class Comment
/** @PHPCRODM\Id() */
public $id;

/** @PHPCRODM\Field(type="string") */
/** @PHPCRODM\Property(type="string") */
public $title;
}

4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/Models/Blog/Post.php
Expand Up @@ -14,9 +14,9 @@ class Post
/** @PHPCRODM\Id() */
public $id;

/** @PHPCRODM\Field(type="string") */
/** @PHPCRODM\Property(type="string") */
public $title;

/** @PHPCRODM\Field(type="string") */
/** @PHPCRODM\Property(type="string") */
public $username;
}

0 comments on commit e6c8d42

Please sign in to comment.