1
0
mirror of synced 2024-12-13 06:46:03 +03:00

[2.0] Changed identifier quoting strategy to something simpler. Dropped Doctrine prefix from annotations.

This commit is contained in:
romanb 2009-05-29 10:23:13 +00:00
parent f994680d54
commit f3677a5714
27 changed files with 304 additions and 258 deletions

View File

@ -97,6 +97,21 @@ class EventManager
}
}
/**
* Removes an event listener from the specified events.
*
* @param string|array $events
* @param object $listener
*/
public function removeEventListener($events, $listener)
{
foreach ((array)$events as $event) {
if ($key = array_search($listener, $this->_listeners[$event], true)) {
unset($this->_listeners[$event][$key]);
}
}
}
/**
* Adds an EventSubscriber. The subscriber is asked for all the events he is
* interested in and added as a listener for these events.

View File

@ -47,7 +47,7 @@ class Configuration
public function __construct()
{
$this->_attributes = array(
'quoteIdentifiers' => false,
//'quoteIdentifiers' => false,
'sqlLogger' => null
);
}
@ -71,7 +71,7 @@ class Configuration
{
return $this->_attributes['sqlLogger'];
}
/*
public function getQuoteIdentifiers()
{
return $this->_attributes['quoteIdentifiers'];
@ -81,7 +81,7 @@ class Configuration
{
$this->_attributes['quoteIdentifiers'] = (bool) $bool;
}
*/
public function setCustomTypes(array $types)
{
foreach ($types as $name => $typeClassName) {

View File

@ -150,13 +150,6 @@ class Connection
*/
protected $_driver;
/**
* Whether to quote identifiers. Read from the configuration upon construction.
*
* @var boolean
*/
protected $_quoteIdentifiers = false;
/**
* Initializes a new instance of the Connection class.
*
@ -188,8 +181,6 @@ class Connection
$this->_eventManager = $eventManager;
$this->_platform = $driver->getDatabasePlatform();
$this->_transactionIsolationLevel = $this->_platform->getDefaultTransactionIsolationLevel();
$this->_quoteIdentifiers = $config->getQuoteIdentifiers();
$this->_platform->setQuoteIdentifiers($this->_quoteIdentifiers);
}
/**
@ -482,10 +473,7 @@ class Connection
*/
public function quoteIdentifier($str)
{
if ($this->_quoteIdentifiers) {
return $this->_platform->quoteIdentifier($str);
}
return $str;
return $this->_platform->quoteIdentifier($str);
}
/**

View File

@ -36,31 +36,11 @@ use Doctrine\DBAL\Types;
*/
abstract class AbstractPlatform
{
private $_quoteIdentifiers = false;
/**
* Constructor.
*/
public function __construct() {}
/**
* Sets whether to quote identifiers.
*/
public function setQuoteIdentifiers($bool)
{
$this->_quoteIdentifiers = $bool;
}
/**
* Gets whether the platform instance currently quotes identifiers in generated SQL.
*
* @return boolean TRUE
*/
public function getQuoteIdentifiers()
{
return $this->_quoteIdentifiers;
}
/**
* Gets the character used for identifier quoting.
*
@ -697,22 +677,12 @@ abstract class AbstractPlatform
*/
public function quoteIdentifier($str)
{
if ( ! $this->_quoteIdentifiers) {
if ($str[0] != '`') {
return $str;
}
// quick fix for the identifiers that contain a dot
if (strpos($str, '.')) {
$e = explode('.', $str);
return $this->quoteIdentifier($e[0])
. '.'
. $this->quoteIdentifier($e[1]);
}
$c = $this->getIdentifierQuoteCharacter();
$str = str_replace($c, $c . $c, $str);
return $c . $str . $c;
return $c . trim($str, '`') . $c;
}
/**

View File

@ -35,7 +35,7 @@ require __DIR__ . '/DoctrineAnnotations.php';
* The AnnotationDriver reads the mapping metadata from docblock annotations
* with the help of the Addendum reflection extensions.
*
* @author robo
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
class AnnotationDriver
@ -48,27 +48,26 @@ class AnnotationDriver
$annotClass = new \ReflectionAnnotatedClass($className);
// Evaluate DoctrineEntity annotation
if (($entityAnnot = $annotClass->getAnnotation('DoctrineEntity')) === false) {
if (($entityAnnot = $annotClass->getAnnotation('Entity')) === false) {
throw DoctrineException::updateMe("$className is no entity.");
}
$metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
// Evaluate DoctrineTable annotation
if ($tableAnnot = $annotClass->getAnnotation('DoctrineTable')) {
if ($tableAnnot = $annotClass->getAnnotation('Table')) {
$metadata->setPrimaryTable(array(
'name' => $tableAnnot->name,
'schema' => $tableAnnot->schema,
'catalog' => $tableAnnot->catalog
'schema' => $tableAnnot->schema
));
}
// Evaluate DoctrineInheritanceType annotation
if ($inheritanceTypeAnnot = $annotClass->getAnnotation('DoctrineInheritanceType')) {
if ($inheritanceTypeAnnot = $annotClass->getAnnotation('InheritanceType')) {
$metadata->setInheritanceType($inheritanceTypeAnnot->value);
}
// Evaluate DoctrineDiscriminatorColumn annotation
if ($discrColumnAnnot = $annotClass->getAnnotation('DoctrineDiscriminatorColumn')) {
if ($discrColumnAnnot = $annotClass->getAnnotation('DiscriminatorColumn')) {
$metadata->setDiscriminatorColumn(array(
'name' => $discrColumnAnnot->name,
'type' => $discrColumnAnnot->type,
@ -77,17 +76,17 @@ class AnnotationDriver
}
// Evaluate DoctrineDiscriminatorMap annotation
if ($discrValueAnnot = $annotClass->getAnnotation('DoctrineDiscriminatorValue')) {
if ($discrValueAnnot = $annotClass->getAnnotation('DiscriminatorValue')) {
$metadata->setDiscriminatorValue($discrValueAnnot->value);
}
// Evaluate DoctrineSubClasses annotation
if ($subClassesAnnot = $annotClass->getAnnotation('DoctrineSubClasses')) {
if ($subClassesAnnot = $annotClass->getAnnotation('SubClasses')) {
$metadata->setSubclasses($subClassesAnnot->value);
}
// Evaluate DoctrineChangeTrackingPolicy annotation
if ($changeTrackingAnnot = $annotClass->getAnnotation('DoctrineChangeTrackingPolicy')) {
if ($changeTrackingAnnot = $annotClass->getAnnotation('ChangeTrackingPolicy')) {
$metadata->setChangeTrackingPolicy($changeTrackingAnnot->value);
}
@ -102,7 +101,7 @@ class AnnotationDriver
// Check for DoctrineJoinColummn/DoctrineJoinColumns annotations
$joinColumns = array();
if ($joinColumnAnnot = $property->getAnnotation('DoctrineJoinColumn')) {
if ($joinColumnAnnot = $property->getAnnotation('JoinColumn')) {
$joinColumns[] = array(
'name' => $joinColumnAnnot->name,
'referencedColumnName' => $joinColumnAnnot->referencedColumnName,
@ -111,61 +110,63 @@ class AnnotationDriver
'onDelete' => $joinColumnAnnot->onDelete,
'onUpdate' => $joinColumnAnnot->onUpdate
);
} else if ($joinColumnsAnnot = $property->getAnnotation('DoctrineJoinColumns')) {
} else if ($joinColumnsAnnot = $property->getAnnotation('JoinColumns')) {
$joinColumns = $joinColumnsAnnot->value;
}
// Field can only be annotated with one of: DoctrineColumn,
// DoctrineOneToOne, DoctrineOneToMany, DoctrineManyToOne, DoctrineManyToMany
if ($columnAnnot = $property->getAnnotation('DoctrineColumn')) {
if ($columnAnnot = $property->getAnnotation('Column')) {
if ($columnAnnot->type == null) {
throw DoctrineException::updateMe("Missing type on property " . $property->getName());
}
$mapping['type'] = $columnAnnot->type;
$mapping['length'] = $columnAnnot->length;
$mapping['nullable'] = $columnAnnot->nullable;
if ($idAnnot = $property->getAnnotation('DoctrineId')) {
if (isset($columnAnnot->name)) {
$mapping['columnName'] = $columnAnnot->name;
}
if ($idAnnot = $property->getAnnotation('Id')) {
$mapping['id'] = true;
}
if ($generatedValueAnnot = $property->getAnnotation('DoctrineGeneratedValue')) {
if ($generatedValueAnnot = $property->getAnnotation('GeneratedValue')) {
$metadata->setIdGeneratorType($generatedValueAnnot->strategy);
}
$metadata->mapField($mapping);
// Check for SequenceGenerator/TableGenerator definition
if ($seqGeneratorAnnot = $property->getAnnotation('DoctrineSequenceGenerator')) {
if ($seqGeneratorAnnot = $property->getAnnotation('SequenceGenerator')) {
$metadata->setSequenceGeneratorDefinition(array(
'sequenceName' => $seqGeneratorAnnot->sequenceName,
'allocationSize' => $seqGeneratorAnnot->allocationSize,
'initialValue' => $seqGeneratorAnnot->initialValue
));
} else if ($tblGeneratorAnnot = $property->getAnnotation('DoctrineTableGenerator')) {
} else if ($tblGeneratorAnnot = $property->getAnnotation('TableGenerator')) {
throw new DoctrineException("DoctrineTableGenerator not yet implemented.");
}
} else if ($oneToOneAnnot = $property->getAnnotation('DoctrineOneToOne')) {
} else if ($oneToOneAnnot = $property->getAnnotation('OneToOne')) {
$mapping['targetEntity'] = $oneToOneAnnot->targetEntity;
$mapping['joinColumns'] = $joinColumns;
$mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
$mapping['cascade'] = $oneToOneAnnot->cascade;
$metadata->mapOneToOne($mapping);
} else if ($oneToManyAnnot = $property->getAnnotation('DoctrineOneToMany')) {
} else if ($oneToManyAnnot = $property->getAnnotation('OneToMany')) {
$mapping['mappedBy'] = $oneToManyAnnot->mappedBy;
$mapping['targetEntity'] = $oneToManyAnnot->targetEntity;
$mapping['cascade'] = $oneToManyAnnot->cascade;
$metadata->mapOneToMany($mapping);
} else if ($manyToOneAnnot = $property->getAnnotation('DoctrineManyToOne')) {
} else if ($manyToOneAnnot = $property->getAnnotation('ManyToOne')) {
$mapping['joinColumns'] = $joinColumns;
$mapping['cascade'] = $manyToOneAnnot->cascade;
$mapping['targetEntity'] = $manyToOneAnnot->targetEntity;
$metadata->mapManyToOne($mapping);
} else if ($manyToManyAnnot = $property->getAnnotation('DoctrineManyToMany')) {
} else if ($manyToManyAnnot = $property->getAnnotation('ManyToMany')) {
$joinTable = array();
if ($joinTableAnnot = $property->getAnnotation('DoctrineJoinTable')) {
if ($joinTableAnnot = $property->getAnnotation('JoinTable')) {
$joinTable = array(
'name' => $joinTableAnnot->name,
'schema' => $joinTableAnnot->schema,
'catalog' => $joinTableAnnot->catalog,
'joinColumns' => $joinTableAnnot->joinColumns,
'inverseJoinColumns' => $joinTableAnnot->inverseJoinColumns
);
@ -182,8 +183,8 @@ class AnnotationDriver
/**
* Whether the class with the specified name should have its metadata loaded.
* This is only the case if it is annotated with either @DoctrineEntity or
* @DoctrineMappedSuperclass in the class doc block.
* This is only the case if it is annotated with either @Entity or
* @MappedSuperclass in the class doc block.
*
* @param string $className
* @return boolean
@ -192,7 +193,7 @@ class AnnotationDriver
{
$refClass = new \ReflectionClass($className);
$docComment = $refClass->getDocComment();
return strpos($docComment, '@DoctrineEntity') === false &&
strpos($docComment, '@DoctrineMappedSuperclass') === false;
return strpos($docComment, '@Entity') === false &&
strpos($docComment, '@MappedSuperclass') === false;
}
}

View File

@ -21,25 +21,25 @@
/* Annotations */
final class DoctrineEntity extends \Annotation {
final class Entity extends \Annotation {
public $repositoryClass;
}
final class DoctrineInheritanceType extends \Annotation {}
final class DoctrineDiscriminatorColumn extends \Annotation {
final class InheritanceType extends \Annotation {}
final class DiscriminatorColumn extends \Annotation {
public $name;
public $type;
public $length;
}
final class DoctrineDiscriminatorMap extends \Annotation {}
final class DoctrineDiscriminatorValue extends \Annotation {}
final class DoctrineSubClasses extends \Annotation {}
final class DoctrineId extends \Annotation {}
final class DoctrineGeneratedValue extends \Annotation {
//final class DiscriminatorMap extends \Annotation {}
final class DiscriminatorValue extends \Annotation {}
final class SubClasses extends \Annotation {}
final class Id extends \Annotation {}
final class GeneratedValue extends \Annotation {
public $strategy;
//public $generator;
}
final class DoctrineVersion extends \Annotation {}
final class DoctrineJoinColumn extends \Annotation {
final class Version extends \Annotation {}
final class JoinColumn extends \Annotation {
public $name;
public $referencedColumnName;
public $unique = false;
@ -47,60 +47,57 @@ final class DoctrineJoinColumn extends \Annotation {
public $onDelete;
public $onUpdate;
}
final class DoctrineJoinColumns extends \Annotation {}
final class DoctrineColumn extends \Annotation {
final class JoinColumns extends \Annotation {}
final class Column extends \Annotation {
public $type;
public $length;
public $unique = false;
public $nullable = false;
public $quote = false;
public $name;
//public $quote = false;
}
final class DoctrineOneToOne extends \Annotation {
final class OneToOne extends \Annotation {
public $targetEntity;
public $mappedBy;
public $cascade;
public $fetch;
public $optional;
}
final class DoctrineOneToMany extends \Annotation {
final class OneToMany extends \Annotation {
public $mappedBy;
public $targetEntity;
public $cascade;
public $fetch;
}
final class DoctrineManyToOne extends \Annotation {
final class ManyToOne extends \Annotation {
public $targetEntity;
public $cascade;
public $fetch;
public $optional;
}
final class DoctrineManyToMany extends \Annotation {
final class ManyToMany extends \Annotation {
public $targetEntity;
public $mappedBy;
public $cascade;
public $fetch;
}
final class DoctrineElementCollection extends \Annotation {
final class ElementCollection extends \Annotation {
public $tableName;
}
final class DoctrineTable extends \Annotation {
final class Table extends \Annotation {
public $name;
public $catalog;
public $schema;
}
final class DoctrineJoinTable extends \Annotation {
final class JoinTable extends \Annotation {
public $name;
public $catalog;
public $schema;
public $joinColumns;
public $inverseJoinColumns;
}
final class DoctrineSequenceGenerator extends \Annotation {
final class SequenceGenerator extends \Annotation {
//public $name;
public $sequenceName;
public $allocationSize = 20;
public $allocationSize = 10;
public $initialValue = 1;
/** The name of the class that defines the generator. */
//public $definingClass;
}
final class DoctrineChangeTrackingPolicy extends \Annotation {}
final class ChangeTrackingPolicy extends \Annotation {}

View File

@ -26,6 +26,7 @@ use Doctrine\ORM\EntityManager;
use Doctrine\ORM\UnitOfWork;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Events;
/**
* Base class for all EntityPersisters.
@ -66,6 +67,13 @@ class StandardEntityPersister
*/
protected $_em;
/**
* The EventManager instance.
*
* @var Doctrine\Common\EventManager
*/
protected $_evm;
/**
* Queued inserts.
*
@ -81,6 +89,7 @@ class StandardEntityPersister
public function __construct(EntityManager $em, ClassMetadata $class)
{
$this->_em = $em;
$this->_evm = $em->getEventManager();
$this->_entityName = $class->name;
$this->_conn = $em->getConnection();
$this->_class = $class;
@ -113,12 +122,19 @@ class StandardEntityPersister
$stmt = $this->_conn->prepare($this->_class->insertSql);
$primaryTableName = $this->_class->primaryTable['name'];
$sqlLogger = $this->_conn->getConfiguration()->getSqlLogger();
$hasPreInsertListeners = $this->_evm->hasListeners(Events::preInsert);
$hasPostInsertListeners = $this->_evm->hasListeners(Events::postInsert);
foreach ($this->_queuedInserts as $entity) {
$insertData = array();
$this->_prepareData($entity, $insertData, true);
if ($hasPreInsertListeners) {
$this->_preInsert($entity);
}
$paramIndex = 1;
if ($sqlLogger) {
//TODO: Log type
@ -139,6 +155,10 @@ class StandardEntityPersister
if ($isPostInsertId) {
$postInsertIds[$idGen->generate($this->_em, $entity)] = $entity;
}
if ($hasPostInsertListeners) {
$this->_postInsert($entity);
}
}
$stmt->closeCursor();
@ -159,7 +179,16 @@ class StandardEntityPersister
$id = array_combine($this->_class->getIdentifierFieldNames(),
$this->_em->getUnitOfWork()->getEntityIdentifier($entity));
$tableName = $this->_class->primaryTable['name'];
if ($this->_evm->hasListeners(Events::preUpdate)) {
$this->_preUpdate($entity);
}
$this->_conn->update($tableName, $updateData[$tableName], $id);
if ($this->_evm->hasListeners(Events::postUpdate)) {
$this->_postUpdate($entity);
}
}
/**
@ -282,8 +311,7 @@ class StandardEntityPersister
$result[$this->getOwningTable($field)][$columnName] = null;
} else {
$result[$this->getOwningTable($field)][$columnName] = Type::getType(
$this->_class->fieldMappings[$field]['type'])
->convertToDatabaseValue($newVal, $platform);
$this->_class->fieldMappings[$field]['type'])->convertToDatabaseValue($newVal, $platform);
}
}
}
@ -382,4 +410,50 @@ class StandardEntityPersister
return 'SELECT ' . $columnList . ' FROM ' . $this->_class->getTableName()
. ' WHERE ' . $conditionSql;
}
/**
* Dispatches the preInsert event for the given entity.
*
* @param object $entity
*/
final protected function _preInsert($entity)
{
$eventArgs = new \Doctrine\ORM\Event\PreInsertEventArgs(
$entity, $this->_em->getUnitOfWork()->getEntityChangeSet($entity)
);
$this->_evm->dispatchEvent(Events::preInsert, $eventArgs);
}
/**
* Dispatches the postInsert event for the given entity.
*
* @param object $entity
*/
final protected function _postInsert($entity)
{
$this->_evm->dispatchEvent(Events::postInsert);
}
/**
* Dispatches the preUpdate event for the given entity.
*
* @param object $entity
*/
final protected function _preUpdate($entity)
{
$eventArgs = new \Doctrine\ORM\Event\PreUpdateEventArgs(
$entity, $this->_em->getUnitOfWork()->getEntityChangeSet($entity)
);
$this->_evm->dispatchEvent(Events::preUpdate, $eventArgs);
}
/**
* Dispatches the postUpdate event for the given entity.
*
* @param object $entity
*/
final protected function _postUpdate($entity)
{
$this->_evm->dispatchEvent(Events::postUpdate);
}
}

View File

@ -42,6 +42,7 @@ class SqlWalker
private $_scalarResultCounter = 0;
private $_parserResult;
private $_em;
private $_conn;
private $_query;
private $_dqlToSqlAliasMap = array();
/** Map of all components/classes that appear in the DQL query. */
@ -67,6 +68,7 @@ class SqlWalker
$this->_resultSetMapping = $parserResult->getResultSetMapping();
$this->_query = $query;
$this->_em = $query->getEntityManager();
$this->_conn = $this->_em->getConnection();
$this->_parserResult = $parserResult;
$this->_queryComponents = $queryComponents;
}
@ -405,7 +407,7 @@ class SqlWalker
if ($beginning) $beginning = false; else $sql .= ', ';
$sqlTableAlias = $this->getSqlTableAlias($tableName . $dqlAlias);
$columnAlias = $this->getSqlColumnAlias($mapping['columnName']);
$sql .= $sqlTableAlias . '.' . $mapping['columnName'] . ' AS ' . $columnAlias;
$sql .= $sqlTableAlias . '.' . $this->_conn->quoteIdentifier($mapping['columnName']) . ' AS ' . $columnAlias;
$this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName);
}
@ -419,7 +421,7 @@ class SqlWalker
if ($beginning) $beginning = false; else $sql .= ', ';
$sqlTableAlias = $this->getSqlTableAlias($subClass->primaryTable['name'] . $dqlAlias);
$columnAlias = $this->getSqlColumnAlias($mapping['columnName']);
$sql .= $sqlTableAlias . '.' . $mapping['columnName'] . ' AS ' . $columnAlias;
$sql .= $sqlTableAlias . '.' . $this->_conn->quoteIdentifier($mapping['columnName']) . ' AS ' . $columnAlias;
$this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName);
}
}
@ -435,7 +437,7 @@ class SqlWalker
foreach ($fieldMappings as $fieldName => $mapping) {
if ($beginning) $beginning = false; else $sql .= ', ';
$columnAlias = $this->getSqlColumnAlias($mapping['columnName']);
$sql .= $sqlTableAlias . '.' . $mapping['columnName'] . ' AS ' . $columnAlias;
$sql .= $sqlTableAlias . '.' . $this->_conn->quoteIdentifier($mapping['columnName']) . ' AS ' . $columnAlias;
$this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName);
}
}
@ -1100,7 +1102,7 @@ class SqlWalker
public function getSqlColumnAlias($columnName)
{
return $columnName . $this->_aliasCounter++;
return trim($columnName, '`') . $this->_aliasCounter++;
}
/**

View File

@ -6,36 +6,36 @@ namespace Doctrine\Tests\Models\CMS;
* CmsAddress
*
* @author Roman S. Borschel
* @DoctrineEntity
* @DoctrineTable(name="cms_addresses")
* @Entity
* @Table(name="cms_addresses")
*/
class CmsAddress
{
/**
* @DoctrineColumn(type="integer")
* @DoctrineId
* @DoctrineGeneratedValue(strategy="auto")
* @Column(type="integer")
* @Id
* @GeneratedValue(strategy="auto")
*/
public $id;
/**
* @DoctrineColumn(type="string", length=50)
* @Column(type="string", length=50)
*/
public $country;
/**
* @DoctrineColumn(type="string", length=50)
* @Column(type="string", length=50)
*/
public $zip;
/**
* @DoctrineColumn(type="string", length=50)
* @Column(type="string", length=50)
*/
public $city;
/**
* @DoctrineOneToOne(targetEntity="CmsUser")
* @DoctrineJoinColumn(name="user_id", referencedColumnName="id")
* @OneToOne(targetEntity="CmsUser")
* @JoinColumn(name="user_id", referencedColumnName="id")
*/
public $user;

View File

@ -3,32 +3,32 @@
namespace Doctrine\Tests\Models\CMS;
/**
* @DoctrineEntity
* @DoctrineTable(name="cms_articles")
* @Entity
* @Table(name="cms_articles")
*/
class CmsArticle
{
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
public $id;
/**
* @DoctrineColumn(type="string", length=255)
* @Column(type="string", length=255)
*/
public $topic;
/**
* @DoctrineColumn(type="string")
* @Column(type="string")
*/
public $text;
/**
* @DoctrineManyToOne(targetEntity="CmsUser")
* @DoctrineJoinColumn(name="user_id", referencedColumnName="id")
* @ManyToOne(targetEntity="CmsUser")
* @JoinColumn(name="user_id", referencedColumnName="id")
*/
public $user;
/**
* @DoctrineOneToMany(targetEntity="CmsComment", mappedBy="article")
* @OneToMany(targetEntity="CmsComment", mappedBy="article")
*/
public $comments;
}

View File

@ -3,28 +3,28 @@
namespace Doctrine\Tests\Models\CMS;
/**
* @DoctrineEntity
* @DoctrineTable(name="cms_comments")
* @Entity
* @Table(name="cms_comments")
*/
class CmsComment
{
/**
* @DoctrineColumn(type="integer")
* @DoctrineId
* @DoctrineGeneratedValue(strategy="auto")
* @Column(type="integer")
* @Id
* @GeneratedValue(strategy="auto")
*/
public $id;
/**
* @DoctrineColumn(type="string", length=255)
* @Column(type="string", length=255)
*/
public $topic;
/**
* @DoctrineColumn(type="string")
* @Column(type="string")
*/
public $text;
/**
* @DoctrineManyToOne(targetEntity="CmsArticle")
* @DoctrineJoinColumn(name="article_id", referencedColumnName="id")
* @ManyToOne(targetEntity="CmsArticle")
* @JoinColumn(name="article_id", referencedColumnName="id")
*/
public $article;
}

View File

@ -6,26 +6,26 @@ namespace Doctrine\Tests\Models\CMS;
* Description of CmsEmployee
*
* @author robo
* @DoctrineEntity
* @DoctrineTable(name="cms_employees")
* @Entity
* @Table(name="cms_employees")
*/
class CmsEmployee
{
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
private $id;
/**
* @DoctrineColumn(type="string")
* @Column(type="string")
*/
private $name;
/**
* @DoctrineOneToOne(targetEntity="CmsEmployee")
* @DoctrineJoinColumn(name="spouse_id", referencedColumnName="id")
* @OneToOne(targetEntity="CmsEmployee")
* @JoinColumn(name="spouse_id", referencedColumnName="id")
*/
private $spouse;

View File

@ -10,23 +10,23 @@ namespace Doctrine\Tests\Models\CMS;
* Description of CmsGroup
*
* @author robo
* @DoctrineEntity
* @DoctrineTable(name="cms_groups")
* @Entity
* @Table(name="cms_groups")
*/
class CmsGroup
{
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
public $id;
/**
* @DoctrineColumn(type="string", length=50)
* @Column(type="string", length=50)
*/
public $name;
/**
* @DoctrineManyToMany(targetEntity="CmsUser", mappedBy="groups")
* @ManyToMany(targetEntity="CmsUser", mappedBy="groups")
*/
public $users;

View File

@ -3,19 +3,19 @@
namespace Doctrine\Tests\Models\CMS;
/**
* @DoctrineEntity
* @DoctrineTable(name="cms_phonenumbers")
* @Entity
* @Table(name="cms_phonenumbers")
*/
class CmsPhonenumber
{
/**
* @DoctrineColumn(type="string", length=50)
* @DoctrineId
* @Column(type="string", length=50)
* @Id
*/
public $phonenumber;
/**
* @DoctrineManyToOne(targetEntity="CmsUser")
* @DoctrineJoinColumn(name="user_id", referencedColumnName="id")
* @ManyToOne(targetEntity="CmsUser")
* @JoinColumn(name="user_id", referencedColumnName="id")
*/
public $user;

View File

@ -3,44 +3,43 @@
namespace Doctrine\Tests\Models\CMS;
/**
* @DoctrineEntity
* @DoctrineTable(name="cms_users")
* @Entity
* @Table(name="cms_users")
*/
class CmsUser
{
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
public $id;
/**
* @DoctrineColumn(type="string", length=50)
* @Column(type="string", length=50)
*/
public $status;
/**
* @DoctrineColumn(type="string", length=255)
* @Column(type="string", length=255)
*/
public $username;
/**
* @DoctrineColumn(type="string", length=255)
* @Column(type="string", length=255)
*/
public $name;
/**
* @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user", cascade={"save", "delete"})
* @OneToMany(targetEntity="CmsPhonenumber", mappedBy="user", cascade={"save", "delete"})
*/
public $phonenumbers;
/**
* @DoctrineOneToMany(targetEntity="CmsArticle", mappedBy="user")
* @OneToMany(targetEntity="CmsArticle", mappedBy="user")
*/
public $articles;
/**
* @DoctrineOneToOne(targetEntity="CmsAddress", mappedBy="user", cascade={"save"})
* @OneToOne(targetEntity="CmsAddress", mappedBy="user", cascade={"save"})
*/
public $address;
/**
* @DoctrineManyToMany(targetEntity="CmsGroup", cascade={"save"})
* @DoctrineJoinTable(name="cms_users_groups",
* @ManyToMany(targetEntity="CmsGroup", cascade={"save"})
* @JoinTable(name="cms_users_groups",
joinColumns={{"name"="user_id", "referencedColumnName"="id"}},
inverseJoinColumns={{"name"="group_id", "referencedColumnName"="id"}})
*/

View File

@ -3,20 +3,20 @@
namespace Doctrine\Tests\Models\Company;
/**
* @DoctrineEntity
* @DoctrineTable(name="company_employees")
* @DoctrineDiscriminatorValue("employee")
* @DoctrineSubClasses({"Doctrine\Tests\Models\Company\CompanyManager"})
* @Entity
* @Table(name="company_employees")
* @DiscriminatorValue("employee")
* @SubClasses({"Doctrine\Tests\Models\Company\CompanyManager"})
*/
class CompanyEmployee extends CompanyPerson
{
/**
* @DoctrineColumn(type="integer")
* @Column(type="integer")
*/
private $salary;
/**
* @DoctrineColumn(type="string", length=255)
* @Column(type="string", length=255)
*/
private $department;

View File

@ -3,14 +3,14 @@
namespace Doctrine\Tests\Models\Company;
/**
* @DoctrineEntity
* @DoctrineTable(name="company_managers")
* @DoctrineDiscriminatorValue("manager")
* @Entity
* @Table(name="company_managers")
* @DiscriminatorValue("manager")
*/
class CompanyManager extends CompanyEmployee
{
/**
* @DoctrineColumn(type="string", length="250")
* @Column(type="string", length="250")
*/
private $title;

View File

@ -6,29 +6,29 @@ namespace Doctrine\Tests\Models\Company;
* Description of CompanyPerson
*
* @author robo
* @DoctrineEntity
* @DoctrineTable(name="company_persons")
* @DoctrineDiscriminatorValue("person")
* @DoctrineInheritanceType("joined")
* @DoctrineDiscriminatorColumn(name="discr", type="string")
* @DoctrineSubClasses({"Doctrine\Tests\Models\Company\CompanyEmployee",
* @Entity
* @Table(name="company_persons")
* @DiscriminatorValue("person")
* @InheritanceType("joined")
* @DiscriminatorColumn(name="discr", type="string")
* @SubClasses({"Doctrine\Tests\Models\Company\CompanyEmployee",
"Doctrine\Tests\Models\Company\CompanyManager"})
*/
class CompanyPerson
{
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
private $id;
/**
* @DoctrineColumn(type="string")
* @Column(type="string")
*/
private $name;
/**
* @DoctrineOneToOne(targetEntity="CompanyPerson")
* @DoctrineJoinColumn(name="spouse_id", referencedColumnName="id")
* @OneToOne(targetEntity="CompanyPerson")
* @JoinColumn(name="spouse_id", referencedColumnName="id")
*/
private $spouse;

View File

@ -3,12 +3,12 @@
namespace Doctrine\Tests\Models\Forum;
/**
* @DoctrineEntity
* @Entity
*/
class ForumAdministrator extends ForumUser
{
/**
* @DoctrineColumn(type="integer", name="access_level")
* @Column(type="integer", name="access_level")
*/
public $accessLevel;
}

View File

@ -3,15 +3,15 @@
namespace Doctrine\Tests\Models\Forum;
/**
* @DoctrineEntity
* @DoctrineTable(name="forum_avatars")
* @Entity
* @Table(name="forum_avatars")
*/
class ForumAvatar
{
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
public $id;
}

View File

@ -6,23 +6,23 @@ namespace Doctrine\Tests\Models\Forum;
* Represents a board in a forum.
*
* @author robo
* @DoctrineEntity
* @DoctrineTable(name="forum_boards")
* @Entity
* @Table(name="forum_boards")
*/
class ForumBoard
{
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @Id
* @Column(type="integer")
*/
public $id;
/**
* @DoctrineColumn(type="integer")
* @Column(type="integer")
*/
public $position;
/**
* @DoctrineManyToOne(targetEntity="ForumCategory")
* @DoctrineJoinColumn(name="category_id", referencedColumnName="id")
* @ManyToOne(targetEntity="ForumCategory")
* @JoinColumn(name="category_id", referencedColumnName="id")
*/
public $category;
}

View File

@ -3,26 +3,26 @@
namespace Doctrine\Tests\Models\Forum;
/**
* @DoctrineEntity
* @DoctrineTable(name="forum_categories")
* @Entity
* @Table(name="forum_categories")
*/
class ForumCategory
{
/**
* @DoctrineColumn(type="integer")
* @DoctrineId
* @Column(type="integer")
* @Id
*/
private $id;
/**
* @DoctrineColumn(type="integer")
* @Column(type="integer")
*/
public $position;
/**
* @DoctrineColumn(type="string", length=255)
* @Column(type="string", length=255)
*/
public $name;
/**
* @DoctrineOneToMany(targetEntity="ForumBoard", mappedBy="category")
* @OneToMany(targetEntity="ForumBoard", mappedBy="category")
*/
public $boards;

View File

@ -3,19 +3,19 @@
namespace Doctrine\Tests\Models\Forum;
/**
* @DoctrineEntity
* @DoctrineTable(name="forum_entries")
* @Entity
* @Table(name="forum_entries")
*/
class ForumEntry
{
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
public $id;
/**
* @DoctrineColumn(type="string", length=50)
* @Column(type="string", length=50)
*/
public $topic;
}

View File

@ -3,24 +3,24 @@
namespace Doctrine\Tests\Models\Forum;
/**
* @DoctrineEntity
* @DoctrineTable(name="forum_users")
* @Entity
* @Table(name="forum_users")
*/
class ForumUser
{
/**
* @DoctrineColumn(type="integer")
* @DoctrineId
* @DoctrineGeneratedValue(strategy="auto")
* @Column(type="integer")
* @Id
* @GeneratedValue(strategy="auto")
*/
public $id;
/**
* @DoctrineColumn(type="string", length=50)
* @Column(type="string", length=50)
*/
public $username;
/**
* @DoctrineOneToOne(targetEntity="ForumAvatar", cascade={"save"})
* @DoctrineJoinColumn(name="avatar_id", referencedColumnName="id")
* @OneToOne(targetEntity="ForumAvatar", cascade={"save"})
* @JoinColumn(name="avatar_id", referencedColumnName="id")
*/
public $avatar;

View File

@ -18,12 +18,12 @@ class SequenceGeneratorTest extends \Doctrine\Tests\OrmFunctionalTestCase
}
/**
* @DoctrineEntity
* @Entity
*/
class SeqUser {
/**
* @DoctrineId
* @DoctrineIdGenerator("sequence")
* @Id
* @IdGenerator("sequence")
*/
private $id;

View File

@ -98,22 +98,22 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
}
/**
* @DoctrineEntity
* @DoctrineInheritanceType("singleTable")
* @DoctrineDiscriminatorColumn(name="discr", type="string")
* @DoctrineSubClasses({"Doctrine\Tests\ORM\Functional\ChildEntity"})
* @DoctrineDiscriminatorValue("parent")
* @Entity
* @InheritanceType("singleTable")
* @DiscriminatorColumn(name="discr", type="string")
* @SubClasses({"Doctrine\Tests\ORM\Functional\ChildEntity"})
* @DiscriminatorValue("parent")
*/
class ParentEntity {
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
private $id;
/**
* @DoctrineColumn(type="string")
* @Column(type="string")
*/
private $data;
@ -131,17 +131,17 @@ class ParentEntity {
}
/**
* @DoctrineEntity
* @DoctrineDiscriminatorValue("child")
* @Entity
* @DiscriminatorValue("child")
*/
class ChildEntity extends ParentEntity {
/**
* @DoctrineColumn(type="integer", nullable=true)
* @Column(name="`number`", type="integer", nullable=true)
*/
private $number;
/**
* @DoctrineOneToOne(targetEntity="RelatedEntity")
* @DoctrineJoinColumn(name="related_entity_id", referencedColumnName="id")
* @OneToOne(targetEntity="RelatedEntity")
* @JoinColumn(name="related_entity_id", referencedColumnName="id")
*/
private $relatedEntity;
@ -164,21 +164,21 @@ class ChildEntity extends ParentEntity {
}
/**
* @DoctrineEntity
* @Entity
*/
class RelatedEntity {
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
private $id;
/**
* @DoctrineColumn(type="string", length=50)
* @Column(type="string", length=50)
*/
private $name;
/**
* @DoctrineOneToOne(targetEntity="ChildEntity", mappedBy="relatedEntity")
* @OneToOne(targetEntity="ChildEntity", mappedBy="relatedEntity")
*/
private $owner;

View File

@ -185,19 +185,19 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
}
/**
* @DoctrineEntity
* @Entity
*/
class NotifyChangedEntity implements \Doctrine\Common\NotifyPropertyChanged
{
private $_listeners = array();
/**
* @DoctrineId
* @DoctrineColumn(type="integer")
* @DoctrineGeneratedValue(strategy="auto")
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="auto")
*/
private $id;
/**
* @DoctrineColumn(type="string")
* @Column(type="string")
*/
private $data;