1
0
mirror of synced 2025-01-18 22:41:43 +03:00

Fixing code sniff issues before continuing refactoring of

This commit is contained in:
Marco Pivetta 2012-06-09 15:17:45 +02:00
parent e522391ee9
commit 94714db132
7 changed files with 135 additions and 80 deletions

View File

@ -19,8 +19,6 @@
namespace Doctrine\ORM\Mapping;
use ReflectionClass, ReflectionProperty;
/**
* A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata
* of an entity and it's associations.

View File

@ -26,11 +26,12 @@ use ReflectionException,
Doctrine\ORM\Events,
Doctrine\Common\Persistence\Mapping\ReflectionService,
Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface,
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory;
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory,
Doctrine\ORM\Id\IdentityGenerator;
/**
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
* metadata mapping informations of a class which describes how a class should be mapped
* metadata mapping information of a class which describes how a class should be mapped
* to a relational database.
*
* @since 2.0
@ -47,7 +48,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
private $em;
/**
* @var AbstractPlatform
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $targetPlatform;
@ -62,7 +63,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
private $evm;
/**
* @param EntityManager $$em
* @param EntityManager $em
* @return void
*/
public function setEntityManager(EntityManager $em)
{
@ -137,13 +139,13 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
}
// If this class has a parent the id generator strategy is inherited.
// However this is only true if the hierachy of parents contains the root entity,
// if it consinsts of mapped superclasses these don't necessarily include the id field.
// However this is only true if the hierarchy of parents contains the root entity,
// if it consists of mapped superclasses these don't necessarily include the id field.
if ($parent && $rootEntityFound) {
if ($parent->isIdGeneratorSequence()) {
$class->setSequenceGeneratorDefinition($parent->sequenceGeneratorDefinition);
} else if ($parent->isIdGeneratorTable()) {
$class->getTableGeneratorDefinition($parent->tableGeneratorDefinition);
$class->tableGeneratorDefinition = $parent->tableGeneratorDefinition;
}
if ($parent->generatorType) {
$class->setIdGeneratorType($parent->generatorType);
@ -208,7 +210,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
* Validate runtime metadata is correctly defined.
*
* @param ClassMetadata $class
* @param ClassMetadata $parent
* @param $parent
* @throws MappingException
* @return void
*/
protected function validateRuntimeMetadata($class, $parent)
{
@ -231,11 +235,11 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
throw MappingException::missingDiscriminatorColumn($class->name);
}
} else if ($parent && !$class->reflClass->isAbstract() && !in_array($class->name, array_values($class->discriminatorMap))) {
// enforce discriminator map for all entities of an inheritance hierachy, otherwise problems will occur.
// enforce discriminator map for all entities of an inheritance hierarchy, otherwise problems will occur.
throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName);
}
} else if ($class->isMappedSuperclass && $class->name == $class->rootEntityName && (count($class->discriminatorMap) || $class->discriminatorColumn)) {
// second condition is necessary for mapped superclasses in the middle of an inheritance hierachy
// second condition is necessary for mapped superclasses in the middle of an inheritance hierarchy
throw MappingException::noInheritanceOnMappedSuperClass($class->name);
}
}
@ -252,18 +256,19 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
* Adds a default discriminator map if no one is given
*
* If an entity is of any inheritance type and does not contain a
* discrimiator map, then the map is generated automatically. This process
* discriminator map, then the map is generated automatically. This process
* is expensive computation wise.
*
* The automatically generated discriminator map contains the lowercase shortname of
* The automatically generated discriminator map contains the lowercase short name of
* each class as key.
*
* @param \Doctrine\ORM\Mapping\ClassMetadata $class
* @throws MappingException
* @return void
*/
private function addDefaultDiscriminatorMap(ClassMetadata $class)
{
$allClasses = $this->driver->getAllClassNames();
$subClassesMetadata = array();
$fqcn = $class->getName();
$map = array($this->getShortName($class->name) => $fqcn);
@ -288,7 +293,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
}
/**
* Get the lower-case shortname of a class.
* Get the lower-case short name of a class.
*
* @param string $className
* @return string
@ -330,6 +335,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
*
* @param \Doctrine\ORM\Mapping\ClassMetadata $subClass
* @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
* @throws MappingException
* @return void
*/
private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
{
@ -427,7 +434,9 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
* Completes the ID generator mapping. If "auto" is specified we choose the generator
* most appropriate for the targeted database platform.
*
* @param \Doctrine\ORM\Mapping\ClassMetadata $class
* @param ClassMetadataInfo $class
* @throws ORMException
* @return void
*/
private function completeIdGeneratorMapping(ClassMetadataInfo $class)
{
@ -549,6 +558,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
*/
protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService)
{
/* @var $class ClassMetadata */
$class->wakeupReflection($reflService);
}
@ -557,6 +567,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
*/
protected function initializeReflection(ClassMetadataInterface $class, ReflectionService $reflService)
{
/* @var $class ClassMetadata */
$class->initializeReflection($reflService);
}

View File

@ -19,9 +19,13 @@
namespace Doctrine\ORM\Mapping;
use BadMethodCallException;
use InvalidArgumentException;
use RuntimeException;
use Doctrine\DBAL\Types\Type;
use ReflectionClass;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\ClassLoader;
/**
* A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata
@ -617,7 +621,7 @@ class ClassMetadataInfo implements ClassMetadata
* Gets a ReflectionProperty for a specific field of the mapped class.
*
* @param string $name
* @return ReflectionProperty
* @return \ReflectionProperty
*/
public function getReflectionProperty($name)
{
@ -627,13 +631,13 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Gets the ReflectionProperty for the single identifier field.
*
* @return ReflectionProperty
* @return \ReflectionProperty
* @throws BadMethodCallException If the class has a composite identifier.
*/
public function getSingleIdReflectionProperty()
{
if ($this->isIdentifierComposite) {
throw new \BadMethodCallException("Class " . $this->name . " has a composite identifier.");
throw new BadMethodCallException("Class " . $this->name . " has a composite identifier.");
}
return $this->reflFields[$this->identifier[0]];
}
@ -831,7 +835,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Restores some state that can not be serialized/unserialized.
*
* @param ReflectionService $reflService
* @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService
* @return void
*/
public function wakeupReflection($reflService)
@ -856,7 +860,7 @@ class ClassMetadataInfo implements ClassMetadata
* Initializes a new ClassMetadata instance that will hold the object-relational mapping
* metadata of the class with the given name.
*
* @param ReflectionService $reflService The reflection service.
* @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service.
*/
public function initializeReflection($reflService)
{
@ -873,6 +877,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Validate Identifier
*
* @throws MappingException
* @return void
*/
public function validateIdentifier()
@ -890,12 +895,13 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Validate association targets actually exist.
*
* @throws MappingException
* @return void
*/
public function validateAssocations()
{
foreach ($this->associationMappings as $mapping) {
if ( ! \Doctrine\Common\ClassLoader::classExists($mapping['targetEntity']) ) {
if ( ! ClassLoader::classExists($mapping['targetEntity']) ) {
throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
}
}
@ -904,12 +910,13 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Validate lifecycle callbacks
*
* @param ReflectionService $reflService
* @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService
* @throws MappingException
* @return void
*/
public function validateLifecycleCallbacks($reflService)
{
foreach ($this->lifecycleCallbacks as $event => $callbacks) {
foreach ($this->lifecycleCallbacks as $callbacks) {
foreach ($callbacks as $callbackFuncName) {
if ( ! $reflService->hasPublicMethod($this->name, $callbackFuncName)) {
throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callbackFuncName);
@ -1032,7 +1039,8 @@ class ClassMetadataInfo implements ClassMetadata
* reference to another object.
*
* @param string $fieldName The field name.
* @return array The field mapping.
* @throws MappingException
* @return array The field mapping.
*/
public function getFieldMapping($fieldName)
{
@ -1048,6 +1056,7 @@ class ClassMetadataInfo implements ClassMetadata
* @see ClassMetadataInfo::$associationMappings
* @param string $fieldName The field name that represents the association in
* the object model.
* @throws MappingException
* @return array The mapping.
*/
public function getAssociationMapping($fieldName)
@ -1165,7 +1174,8 @@ class ClassMetadataInfo implements ClassMetadata
* Validates & completes the given field mapping.
*
* @param array $mapping The field mapping to validated & complete.
* @return array The validated and completed field mapping.
* @throws MappingException
* @return array The validated and completed field mapping.
*/
protected function _validateAndCompleteFieldMapping(array &$mapping)
{
@ -1342,8 +1352,9 @@ class ClassMetadataInfo implements ClassMetadata
* Validates & completes a one-to-one association mapping.
*
* @param array $mapping The mapping to validate & complete.
* @return array The validated & completed mapping.
* @override
* @throws RuntimeException
* @throws MappingException
* @return array The validated & completed mapping.@override
*/
protected function _validateAndCompleteOneToOneMapping(array $mapping)
{
@ -1363,7 +1374,7 @@ class ClassMetadataInfo implements ClassMetadata
}
$uniqueContraintColumns = array();
foreach ($mapping['joinColumns'] as $key => &$joinColumn) {
foreach ($mapping['joinColumns'] as &$joinColumn) {
if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) {
if (count($mapping['joinColumns']) == 1) {
if ( ! isset($mapping['id']) || ! $mapping['id']) {
@ -1399,7 +1410,7 @@ class ClassMetadataInfo implements ClassMetadata
if ($uniqueContraintColumns) {
if ( ! $this->table) {
throw new \RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship.");
throw new RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship.");
}
$this->table['uniqueConstraints'][$mapping['fieldName']."_uniq"] = array(
'columns' => $uniqueContraintColumns
@ -1423,8 +1434,9 @@ class ClassMetadataInfo implements ClassMetadata
* Validates and completes the mapping.
*
* @param array $mapping The mapping to validate and complete.
* @return array The validated and completed mapping.
* @override
* @throws MappingException
* @throws InvalidArgumentException
* @return array The validated and completed mapping.@override
*/
protected function _validateAndCompleteOneToManyMapping(array $mapping)
{
@ -1440,7 +1452,7 @@ class ClassMetadataInfo implements ClassMetadata
if (isset($mapping['orderBy'])) {
if ( ! is_array($mapping['orderBy'])) {
throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
throw new InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
}
}
@ -1527,7 +1539,7 @@ class ClassMetadataInfo implements ClassMetadata
if (isset($mapping['orderBy'])) {
if ( ! is_array($mapping['orderBy'])) {
throw new \InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
throw new InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
}
}
@ -1587,7 +1599,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Gets the mapped identifier field of this class.
*
* @return string $identifier
* @return array|string $identifier
*/
public function getIdentifier()
{
@ -1597,7 +1609,8 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Checks whether the class has a (mapped) field with a certain name.
*
* @return boolean
* @param string $fieldName
* @return bool
*/
public function hasField($fieldName)
{
@ -1607,6 +1620,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Gets an array containing all the column names.
*
* @param array $fieldNames
* @return array
*/
public function getColumnNames(array $fieldNames = null)
@ -1734,7 +1748,7 @@ class ClassMetadataInfo implements ClassMetadata
*/
public function isIdGeneratorTable()
{
$this->generatorType == self::GENERATOR_TYPE_TABLE;
return $this->generatorType == self::GENERATOR_TYPE_TABLE;
}
/**
@ -1762,7 +1776,7 @@ class ClassMetadataInfo implements ClassMetadata
* Gets the type of a field.
*
* @param string $fieldName
* @return \Doctrine\DBAL\Types\Type
* @return \Doctrine\DBAL\Types\Type|string
*/
public function getTypeOfField($fieldName)
{
@ -1773,6 +1787,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Gets the type of a column.
*
* @param string $columnName
* @return \Doctrine\DBAL\Types\Type
*/
public function getTypeOfColumn($columnName)
@ -1834,6 +1849,8 @@ class ClassMetadataInfo implements ClassMetadata
* Sets the inheritance type used by the class and it's subclasses.
*
* @param integer $type
* @throws MappingException
* @return void
*/
public function setInheritanceType($type)
{
@ -1848,6 +1865,8 @@ class ClassMetadataInfo implements ClassMetadata
*
* @param string $fieldName
* @param array $overrideMapping
* @throws MappingException
* @return void
*/
public function setAssociationOverride($fieldName, array $overrideMapping)
{
@ -1870,7 +1889,7 @@ class ClassMetadataInfo implements ClassMetadata
$mapping['sourceToTargetKeyColumns'] = null;
$mapping['relationToSourceKeyColumns'] = null;
$mapping['relationToTargetKeyColumns'] = null;
switch ($mapping['type']) {
case self::ONE_TO_ONE:
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
@ -1889,11 +1908,14 @@ class ClassMetadataInfo implements ClassMetadata
$this->associationMappings[$fieldName] = $mapping;
}
/**
/**
* Sets the override for a mapped field.
*
* @param string $fieldName
* @param array $mapping
* @param array $overrideMapping
* @throws MappingException
* @param array $overrideMapping
* @return void
*/
public function setAttributeOverride($fieldName, array $overrideMapping)
{
@ -1930,7 +1952,8 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Checks whether a mapped field is inherited from an entity superclass.
*
* @return boolean TRUE if the field is inherited, FALSE otherwise.
* @param string $fieldName
* @return bool TRUE if the field is inherited, FALSE otherwise.
*/
public function isInheritedField($fieldName)
{
@ -2023,6 +2046,8 @@ class ClassMetadataInfo implements ClassMetadata
* Adds a mapped field to the class.
*
* @param array $mapping The field mapping.
* @throws MappingException
* @return void
*/
public function mapField(array $mapping)
{
@ -2039,6 +2064,8 @@ class ClassMetadataInfo implements ClassMetadata
* This is mainly used to add inherited association mappings to derived classes.
*
* @param array $mapping
* @throws MappingException
* @return void
*/
public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/)
{
@ -2053,7 +2080,8 @@ class ClassMetadataInfo implements ClassMetadata
* Adds a field mapping without completing/validating it.
* This is mainly used to add inherited field mappings to derived classes.
*
* @param array $mapping
* @internal param array $fieldMapping
* @return void
*/
public function addInheritedFieldMapping(array $fieldMapping)
{
@ -2247,6 +2275,8 @@ class ClassMetadataInfo implements ClassMetadata
* Stores the association mapping.
*
* @param array $assocMapping
* @throws MappingException
* @return void
*/
protected function _storeAssociationMapping(array $assocMapping)
{
@ -2277,8 +2307,8 @@ class ClassMetadataInfo implements ClassMetadata
* Dispatches the lifecycle event of the given entity to the registered
* lifecycle callbacks and lifecycle listeners.
*
* @param string $event The lifecycle event.
* @param Entity $entity The Entity on which the event occured.
* @param string $lifecycleEvent The lifecycle event.
* @param \Object $entity The Entity on which the event occured.
*/
public function invokeLifecycleCallbacks($lifecycleEvent, $entity)
{
@ -2335,6 +2365,10 @@ class ClassMetadataInfo implements ClassMetadata
* Sets the discriminator column definition.
*
* @param array $columnDef
*
* @param $columnDef
* @throws MappingException
* @return void
* @see getDiscriminatorColumn()
*/
public function setDiscriminatorColumn($columnDef)
@ -2382,6 +2416,8 @@ class ClassMetadataInfo implements ClassMetadata
*
* @param string $name
* @param string $className
* @throws MappingException
* @return void
*/
public function addDiscriminatorMapClass($name, $className)
{
@ -2493,6 +2529,7 @@ class ClassMetadataInfo implements ClassMetadata
* Return the single association join column (if any).
*
* @param string $fieldName
* @throws MappingException
* @return string
*/
public function getSingleAssociationJoinColumnName($fieldName)
@ -2507,6 +2544,7 @@ class ClassMetadataInfo implements ClassMetadata
* Return the single association referenced join column name (if any).
*
* @param string $fieldName
* @throws MappingException
* @return string
*/
public function getSingleAssociationReferencedJoinColumnName($fieldName)
@ -2523,6 +2561,7 @@ class ClassMetadataInfo implements ClassMetadata
* This method is used in foreign-key as primary-key contexts.
*
* @param string $columnName
* @throws MappingException
* @return string
*/
public function getFieldForColumn($columnName)
@ -2545,7 +2584,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Sets the ID generator used to generate IDs for instances of this class.
*
* @param AbstractIdGenerator $generator
* @param \Doctrine\ORM\Id\AbstractIdGenerator $generator
*/
public function setIdGenerator($generator)
{
@ -2591,6 +2630,8 @@ class ClassMetadataInfo implements ClassMetadata
* value to use depending on the column type.
*
* @param array $mapping The version field mapping array
* @throws MappingException
* @return void
*/
public function setVersionMapping(array &$mapping)
{
@ -2667,12 +2708,13 @@ class ClassMetadataInfo implements ClassMetadata
* Returns the target class name of the given association.
*
* @param string $assocName
* @throws InvalidArgumentException
* @return string
*/
public function getAssociationTargetClass($assocName)
{
if ( ! isset($this->associationMappings[$assocName])) {
throw new \InvalidArgumentException("Association name expected, '" . $assocName ."' is not an association.");
throw new InvalidArgumentException("Association name expected, '" . $assocName ."' is not an association.");
}
return $this->associationMappings[$assocName]['targetEntity'];
@ -2693,7 +2735,7 @@ class ClassMetadataInfo implements ClassMetadata
*
* @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy
*
* @param AbstractPlatform $platform
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return array
*/
public function getQuotedIdentifierColumnNames($platform)
@ -2728,11 +2770,11 @@ class ClassMetadataInfo implements ClassMetadata
/**
* Gets the (possibly quoted) column name of a mapped field for safe use in an SQL statement.
*
*
* @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy
*
* @param string $field
* @param AbstractPlatform $platform
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return string
*/
public function getQuotedColumnName($field, $platform)
@ -2747,7 +2789,7 @@ class ClassMetadataInfo implements ClassMetadata
*
* @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy
*
* @param AbstractPlatform $platform
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return string
*/
public function getQuotedTableName($platform)
@ -2760,7 +2802,8 @@ class ClassMetadataInfo implements ClassMetadata
*
* @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy
*
* @param AbstractPlatform $platform
* @param array $assoc
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return string
*/
public function getQuotedJoinTableName(array $assoc, $platform)

View File

@ -24,12 +24,13 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager,
Doctrine\Common\Persistence\Mapping\Driver\MappingDriver,
Doctrine\Common\Persistence\Mapping\ClassMetadata,
Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\Common\Util\Inflector;
Doctrine\Common\Util\Inflector,
Doctrine\ORM\Mapping\MappingException;
/**
* The DatabaseDriver reverse engineers the mapping metadata from a database.
*
*
*
* @link www.doctrine-project.org
* @since 2.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
@ -115,7 +116,7 @@ class DatabaseDriver implements MappingDriver
$this->tables = $this->manyToManyTables = $this->classToTableNames = array();
foreach ($tables as $tableName => $table) {
/* @var $table Table */
/* @var $table \Doctrine\DBAL\Schema\Table */
if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$foreignKeys = $table->getForeignKeys();
} else {
@ -189,13 +190,13 @@ class DatabaseDriver implements MappingDriver
$fieldMappings = array();
foreach ($columns as $column) {
$fieldMapping = array();
if (in_array($column->getName(), $allForeignKeyColumns)) {
continue;
} else if ($primaryKeyColumns && in_array($column->getName(), $primaryKeyColumns)) {
$fieldMapping['id'] = true;
}
$fieldMapping['fieldName'] = $this->getFieldNameForColumn($tableName, $column->getName(), false);
$fieldMapping['columnName'] = $column->getName();
$fieldMapping['type'] = strtolower((string) $column->getType());
@ -306,7 +307,7 @@ class DatabaseDriver implements MappingDriver
'referencedColumnName' => $fkCols[$i],
);
}
//Here we need to check if $cols are the same as $primaryKeyColums
if (!array_diff($cols,$primaryKeyColumns)) {
$metadata->mapOneToOne($associationMapping);

View File

@ -44,14 +44,14 @@ class DriverChain implements MappingDriver
/**
* The default driver
*
* @var Driver
* @var MappingDriver
*/
private $defaultDriver;
/**
* Get the default driver.
*
* @return Driver
* @return MappingDriver
*/
public function getDefaultDriver()
{
@ -94,6 +94,8 @@ class DriverChain implements MappingDriver
*
* @param string $className
* @param ClassMetadata $metadata
* @throws MappingException
* @return
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
{

View File

@ -53,7 +53,7 @@ class XmlDriver extends FileDriver
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
$xmlRoot = $this->getElement($className);
if ($xmlRoot->getName() == 'entity') {
if (isset($xmlRoot['repository-class'])) {
$metadata->setCustomRepositoryClass((string)$xmlRoot['repository-class']);
@ -235,7 +235,7 @@ class XmlDriver extends FileDriver
foreach ($mappings as $mapping) {
$metadata->mapField($mapping);
}
// Evaluate <id ...> mappings
$associationIds = array();
foreach ($xmlRoot->id as $idElement) {
@ -550,7 +550,7 @@ class XmlDriver extends FileDriver
/**
* Parses (nested) option elements.
*
* @param $options The XML element.
* @param SimpleXMLElement $options the XML element.
* @return array The options array.
*/
private function _parseOptions(SimpleXMLElement $options)
@ -580,7 +580,7 @@ class XmlDriver extends FileDriver
* Constructs a joinColumn mapping array based on the information
* found in the given SimpleXMLElement.
*
* @param $joinColumnElement The XML element.
* @param SimpleXMLElement $joinColumnElement the XML element.
* @return array The mapping array.
*/
private function joinColumnToArray(SimpleXMLElement $joinColumnElement)
@ -618,43 +618,43 @@ class XmlDriver extends FileDriver
private function columnToArray(SimpleXMLElement $fieldMapping)
{
$mapping = array(
'fieldName' => (string)$fieldMapping['name'],
'fieldName' => (string) $fieldMapping['name'],
);
if (isset($fieldMapping['type'])) {
$mapping['type'] = (string)$fieldMapping['type'];
$mapping['type'] = (string) $fieldMapping['type'];
}
if (isset($fieldMapping['column'])) {
$mapping['columnName'] = (string)$fieldMapping['column'];
$mapping['columnName'] = (string) $fieldMapping['column'];
}
if (isset($fieldMapping['length'])) {
$mapping['length'] = (int)$fieldMapping['length'];
$mapping['length'] = (int) $fieldMapping['length'];
}
if (isset($fieldMapping['precision'])) {
$mapping['precision'] = (int)$fieldMapping['precision'];
$mapping['precision'] = (int) $fieldMapping['precision'];
}
if (isset($fieldMapping['scale'])) {
$mapping['scale'] = (int)$fieldMapping['scale'];
$mapping['scale'] = (int) $fieldMapping['scale'];
}
if (isset($fieldMapping['unique'])) {
$mapping['unique'] = ((string)$fieldMapping['unique'] == "false") ? false : true;
$mapping['unique'] = ((string) $fieldMapping['unique'] == "false") ? false : true;
}
if (isset($fieldMapping['nullable'])) {
$mapping['nullable'] = ((string)$fieldMapping['nullable'] == "false") ? false : true;
$mapping['nullable'] = ((string) $fieldMapping['nullable'] == "false") ? false : true;
}
if (isset($fieldMapping['version']) && $fieldMapping['version']) {
$metadata->setVersionMapping($mapping);
$mapping['version'] = $fieldMapping['version'];
}
if (isset($fieldMapping['column-definition'])) {
$mapping['columnDefinition'] = (string)$fieldMapping['column-definition'];
$mapping['columnDefinition'] = (string) $fieldMapping['column-definition'];
}
if (isset($fieldMapping->options)) {
@ -667,7 +667,7 @@ class XmlDriver extends FileDriver
/**
* Gathers a list of cascade options found in the given cascade element.
*
* @param $cascadeElement The cascade element.
* @param SimpleXMLElement $cascadeElement the cascade element.
* @return array The list of cascade options.
*/
private function _getCascadeMappings($cascadeElement)

View File

@ -134,7 +134,7 @@ class YamlDriver extends FileDriver
$entities[] = $entityResult;
}
}
if (isset($resultSetMapping['columnResult'])) {
foreach ($resultSetMapping['columnResult'] as $columnResultAnnot) {
@ -571,7 +571,7 @@ class YamlDriver extends FileDriver
* Constructs a joinColumn mapping array based on the information
* found in the given join column element.
*
* @param $joinColumnElement The array join column element
* @param array $joinColumnElement The array join column element
* @return array The mapping array.
*/
private function joinColumnToArray($joinColumnElement)
@ -580,7 +580,7 @@ class YamlDriver extends FileDriver
if (isset($joinColumnElement['referencedColumnName'])) {
$joinColumn['referencedColumnName'] = (string) $joinColumnElement['referencedColumnName'];
}
if (isset($joinColumnElement['name'])) {
$joinColumn['name'] = (string) $joinColumnElement['name'];
}
@ -660,7 +660,7 @@ class YamlDriver extends FileDriver
}
if (isset($column['version']) && $column['version']) {
$metadata->setVersionMapping($mapping);
$mapping['version'] = $column['version'];
}
if (isset($column['columnDefinition'])) {