Skip to content

Commit

Permalink
Merge pull request doctrine#106 from FabioBatSilva/master
Browse files Browse the repository at this point in the history
[DDC-1325] @target annotation
  • Loading branch information
beberlei committed Aug 14, 2011
2 parents a0ca506 + a04d293 commit 2ee3cde
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 35 deletions.
167 changes: 134 additions & 33 deletions lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,68 @@

/* Annotations */

/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class Entity extends Annotation {
public $repositoryClass;
public $readOnly = false;
}

/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class MappedSuperclass extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class InheritanceType extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class DiscriminatorColumn extends Annotation {
public $name;
public $fieldName; // field name used in non-object hydration (array/scalar)
public $type;
public $length;
}

/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class DiscriminatorMap extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class Id extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class GeneratedValue extends Annotation {
public $strategy = 'AUTO';
}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class Version extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target({"PROPERTY","ANNOTATION"})
*/
final class JoinColumn extends Annotation {
public $name;
public $fieldName; // field name used in non-object hydration (array/scalar)
Expand All @@ -68,10 +95,16 @@ final class JoinColumn extends Annotation {
public $columnDefinition;
}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class JoinColumns extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class Column extends Annotation {
public $type = 'string';
public $length;
Expand All @@ -86,7 +119,10 @@ final class Column extends Annotation {
public $columnDefinition;
}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class OneToOne extends Annotation {
public $targetEntity;
public $mappedBy;
Expand All @@ -96,7 +132,10 @@ final class OneToOne extends Annotation {
public $orphanRemoval = false;
}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class OneToMany extends Annotation {
public $mappedBy;
public $targetEntity;
Expand All @@ -106,15 +145,21 @@ final class OneToMany extends Annotation {
public $indexBy;
}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class ManyToOne extends Annotation {
public $targetEntity;
public $cascade;
public $fetch = 'LAZY';
public $inversedBy;
}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class ManyToMany extends Annotation {
public $targetEntity;
public $mappedBy;
Expand All @@ -124,82 +169,138 @@ final class ManyToMany extends Annotation {
public $indexBy;
}

/** @Annotation */
/**
* @Annotation
* @Target("ALL")
* @todo check available targets
*/
final class ElementCollection extends Annotation {
public $tableName;
}

/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class Table extends Annotation {
public $name;
public $schema;
public $indexes;
public $uniqueConstraints;
}

/** @Annotation */
/**
* @Annotation
* @Target("ANNOTATION")
*/
final class UniqueConstraint extends Annotation {
public $name;
public $columns;
}

/** @Annotation */
/**
* @Annotation
* @Target("ANNOTATION")
*/
final class Index extends Annotation {
public $name;
public $columns;
}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class JoinTable extends Annotation {
public $name;
public $schema;
public $joinColumns = array();
public $inverseJoinColumns = array();
}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class SequenceGenerator extends Annotation {
public $sequenceName;
public $allocationSize = 1;
public $initialValue = 1;
}

/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class ChangeTrackingPolicy extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class OrderBy extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class NamedQueries extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("ANNOTATION")
*/
final class NamedQuery extends Annotation {
public $name;
public $query;
}

/* Annotations for lifecycle callbacks */
/** @Annotation */

/**
* @Annotation
* @Target("CLASS")
*/
final class HasLifecycleCallbacks extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PrePersist extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PostPersist extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PreUpdate extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PostUpdate extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PreRemove extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PostRemove extends Annotation {}

/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PostLoad extends Annotation {}
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public function setGenerateAnnotations($bool)
*/
public function setAnnotationPrefix($prefix)
{
if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0-DEV', '>=')) {
if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
return;
}
$this->_annotationsPrefix = $prefix;
Expand Down
9 changes: 8 additions & 1 deletion tests/Doctrine/Tests/OrmTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ protected function createAnnotationDriver($paths = array(), $alias = null)
$reader = new \Doctrine\Common\Annotations\CachedReader(
new \Doctrine\Common\Annotations\AnnotationReader(), new ArrayCache()
);
} else if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
}
else if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
// Register the ORM Annotations in the AnnotationRegistry
$reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader();
$reader->addNamespace('Doctrine\ORM\Mapping');
$reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
}
else if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader->setIgnoreNotImportedAnnotations(true);
$reader->setEnableParsePhpImports(false);
Expand Down

0 comments on commit 2ee3cde

Please sign in to comment.