diff --git a/lib/Doctrine/ODM/PHPCR/Configuration.php b/lib/Doctrine/ODM/PHPCR/Configuration.php index b8e32fd53..9502ecea2 100644 --- a/lib/Doctrine/ODM/PHPCR/Configuration.php +++ b/lib/Doctrine/ODM/PHPCR/Configuration.php @@ -19,6 +19,7 @@ namespace Doctrine\ODM\PHPCR; +use Doctrine\Common\Cache\Cache; use Doctrine\ODM\PHPCR\Mapping\Driver\Driver; use Doctrine\ODM\PHPCR\Mapping\Driver\BuiltinDocumentsDriver; use Doctrine\ODM\PHPCR\DocumentClassMapperInterface; @@ -44,9 +45,10 @@ class Configuration 'writeDoctrineMetadata' => true, 'validateDoctrineMetadata' => true, 'metadataDriverImpl' => null, + 'metadataCacheImpl' => null, 'documentClassMapper' => null, 'proxyNamespace' => 'MyPHPCRProxyNS', - 'autoGenerateProxyClasses' => true + 'autoGenerateProxyClasses' => true, ); /** @@ -128,7 +130,7 @@ public function setDocumentNamespaces(array $documentNamespaces) } /** - * Sets the cache driver implementation that is used for metadata caching. + * Sets the driver implementation that is used to retrieve mapping metadata. * * @param Driver $driverImpl * @todo Force parameter to be a Closure to ensure lazy evaluation @@ -140,7 +142,7 @@ public function setMetadataDriverImpl(Driver $driverImpl) } /** - * Gets the cache driver implementation that is used for the mapping metadata. + * Gets the driver implementation that is used to retrieve mapping metadata. * * @return Mapping\Driver\Driver */ @@ -149,6 +151,26 @@ public function getMetadataDriverImpl() return $this->attributes['metadataDriverImpl']; } + /** + * Sets the cache driver implementation that is used for metadata caching. + * + * @param Cache $metadataCacheImpl + */ + public function setMetadataCacheImpl(Cache $metadataCacheImpl) + { + $this->attributes['metadataCacheImpl'] = $metadataCacheImpl; + } + + /** + * Gets the cache driver implementation that is used for the mapping metadata. + * + * @return Cache|null + */ + public function getMetadataCacheImpl() + { + return $this->attributes['metadataCacheImpl']; + } + /** * Gets the cache driver implementation that is used for metadata caching. * @@ -237,4 +259,4 @@ public function getAutoGenerateProxyClasses() { return $this->attributes['autoGenerateProxyClasses']; } -} +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php index 449d20f49..297e268ed 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php @@ -19,10 +19,10 @@ namespace Doctrine\ODM\PHPCR\Mapping; -use Doctrine\ODM\PHPCR\DocumentManager, - Doctrine\ODM\PHPCR\Mapping\ClassMetadata, - Doctrine\ODM\PHPCR\PHPCRException, - Doctrine\Common\Cache\Cache; +use Doctrine\ODM\PHPCR\DocumentManager; +use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Doctrine\ODM\PHPCR\PHPCRException; +use Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory; /** * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the @@ -35,244 +35,106 @@ * @author Benjamin Eberlei * @author Lukas Kahwe Smith */ -class ClassMetadataFactory +class ClassMetadataFactory extends AbstractClassMetadataFactory { - /** - * @var DocumentManager - */ - private $dm; /** - * @var array + * {@inheritdoc} */ - private $loadedMetadata = array(); - + protected $cacheSalt = '\$PHPCRODMCLASSMETADATA'; + /** - * @var array + * @var DocumentManager */ - private $loadedAliases = array(); + private $dm; /** * The used metadata driver. * - * @var Doctrine\ODM\PHPCR\Mapping\Driver\Driver + * @var \Doctrine\ODM\PHPCR\Mapping\Driver\Driver */ private $driver; - /** - * The used cache driver. - * - * @var Cache - */ - private $cacheDriver; - /** * Creates a new factory instance that uses the given DocumentManager instance. * - * @param $dm The DocumentManager instance + * @param $dm The DocumentManager instance */ public function __construct(DocumentManager $dm) { $this->dm = $dm; - $this->driver = $this->dm->getConfiguration()->getMetadataDriverImpl(); - } - - /** - * Sets the cache driver used by the factory to cache ClassMetadata instances. - * - * @param Doctrine\Common\Cache\Cache $cacheDriver - */ - public function setCacheDriver($cacheDriver) - { - $this->cacheDriver = $cacheDriver; + $conf = $this->dm->getConfiguration(); + $this->setCacheDriver($conf->getMetadataCacheImpl()); + $this->driver = $conf->getMetadataDriverImpl(); } /** - * Gets the cache driver used by the factory to cache ClassMetadata instances. - * - * @return Doctrine\Common\Cache\Cache + * {@inheritdoc} + * + * @throws MappingException */ - public function getCacheDriver() - { - return $this->cacheDriver; - } - - /** - * Gets the array of loaded ClassMetadata instances. - * - * @return array $loadedMetadata The loaded metadata. - */ - public function getLoadedMetadata() - { - return $this->loadedMetadata; - } - - /** - * Forces the factory to load the metadata of all classes known to the underlying - * mapping driver. - * - * @return array The ClassMetadata instances of all mapped classes. - */ - public function getAllMetadata() - { - $metadata = array(); - foreach ($this->driver->getAllClassNames() as $className) { - $metadata[] = $this->getMetadataFor($className); - } - - return $metadata; - } - - public function getMetadataForAlias($alias) + public function getMetadataFor($className) { - if (isset($this->loadedAliases[$alias])) { - return $this->loadedAliases[$alias]; + $metadata = parent::getMetadataFor($className); + if ($metadata) { + return $metadata; } - - if ($this->cacheDriver && ($cached = $this->cacheDriver->fetch("$alias\$PHPCRODMALIAS")) !== false) { - return $this->loadedAliases[$alias] = $cached; - } - - foreach ($this->loadedMetadata as $metadata) { - if ($metadata->alias === $alias) { - $this->loadedAliases[$alias] = $metadata; - if ($this->cacheDriver) { - $this->cacheDriver->save( - "$alias\$PHPCRODMALIAS", $this->loadedAliases[$alias], null - ); - } - return $metadata; - } - } - - foreach ($this->driver->getAllClassNames() as $className) { - $metadata = $this->getMetadataFor($className); - if ($metadata->alias === $alias) { - $this->loadedAliases[$alias] = $metadata; - if ($this->cacheDriver) { - $this->cacheDriver->save( - "$alias\$PHPCRODMALIAS", $this->loadedAliases[$alias], null - ); - } - return $metadata; - } - } - - throw new MappingException('Alias '.$alias.' could not be resolved to a document class name'); + throw MappingException::classNotMapped($className); } /** - * Gets the class metadata descriptor for a class. - * - * @param string $className The name of the class. - * @return Doctrine\ODM\PHPCR\Mapping\ClassMetadata + * {@inheritdoc} + * + * @throws MappingException */ - public function getMetadataFor($className) + function loadMetadata($className) { - if (!isset($this->loadedMetadata[$className])) { - $realClassName = $className; - - // Check for namespace alias - if (strpos($className, ':') !== false) { - list($namespaceAlias, $simpleClassName) = explode(':', $className); - $realClassName = $this->dm->getConfiguration()->getDocumentNamespace($namespaceAlias) . '\\' . $simpleClassName; - - if (isset($this->loadedMetadata[$realClassName])) { - // We do not have the alias name in the map, include it - $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName]; - - return $this->loadedMetadata[$realClassName]; - } - } - - if ($this->cacheDriver) { - if (($cached = $this->cacheDriver->fetch("$realClassName\$PHPCRODMCLASSMETADATA")) !== false) { - $this->loadedMetadata[$realClassName] = $cached; - } else { - foreach ($this->loadMetadata($realClassName) as $loadedClassName) { - $this->cacheDriver->save( - "$loadedClassName\$PHPCRODMCLASSMETADATA", $this->loadedMetadata[$loadedClassName], null - ); - } - } - } else { - $this->loadMetadata($realClassName); - } - - if ($className != $realClassName) { - // We do not have the alias name in the map, include it - $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName]; - } + if (class_exists($className)) { + return parent::loadMetadata($className); } - - if (!isset($this->loadedMetadata[$className])) { - throw MappingException::classNotMapped(); - } - - return $this->loadedMetadata[$className]; + throw MappingException::classNotFound($className); } + /** - * Loads the metadata of the class in question and all it's ancestors whose metadata - * is still not loaded. - * - * @param string $className The name of the class for which the metadata should get loaded. + * {@inheritdoc} */ - private function loadMetadata($className) + protected function newClassMetadataInstance($className) { - if (!class_exists($className)) { - throw MappingException::classNotFound($className); - } - - $this->loadedMetadata[$className] = new ClassMetadata($className); - $this->driver->loadMetadataForClass($className, $this->loadedMetadata[$className]); + return new ClassMetadata($className); } - + /** - * Checks whether the factory has the metadata for a class loaded already. - * - * @param string $className - * @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise. + * {@inheritdoc} */ - public function hasMetadataFor($className) + protected function getFqcnFromAlias($namespaceAlias, $simpleClassName) { - return isset($this->loadedMetadata[$className]); + return $this->dm->getConfiguration()->getDocumentNamespace($namespaceAlias) + . '\\' . $simpleClassName; } /** - * Sets the metadata descriptor for a specific class. - * - * NOTE: This is only useful in very special cases, like when generating proxy classes. - * - * @param string $className - * @param ClassMetadata $class + * {@inheritdoc} */ - public function setMetadataFor($className, $class) + protected function doLoadMetadata($class, $parent, $rootEntityFound) { - $this->loadedMetadata[$className] = $class; + $this->getDriver()->loadMetadataForClass($class->getName(), $class); } /** - * Creates a new ClassMetadata instance for the given class name. - * - * @param string $className - * @return Doctrine\ODM\PHPCR\Mapping\ClassMetadata + * {@inheritdoc} */ - protected function newClassMetadataInstance($className) + protected function getDriver() { - return new ClassMetadata($className); + return $this->driver; } /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped as an Entity or a - * MappedSuperclass. - * - * @param string $className - * @return boolean + * {@inheritdoc} */ - public function isTransient($className) + protected function initialize() { - return $this->driver->isTransient($className); + $this->initialized = true; } -} + +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php index 5c4614776..dc05ccd37 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php @@ -21,9 +21,10 @@ use Doctrine\Common\Annotations\AnnotationReader, Doctrine\Common\Annotations\Reader, + Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver as AbstractAnnotationDriver, + Doctrine\Common\Persistence\Mapping\ClassMetadata, Doctrine\ODM\PHPCR\Event, Doctrine\ODM\PHPCR\Mapping\Annotations as ODM, - Doctrine\ODM\PHPCR\Mapping\ClassMetadata, Doctrine\ODM\PHPCR\Mapping\MappingException; /** @@ -37,87 +38,29 @@ * @author Daniel Barsotti * @author David Buchmann */ -class AnnotationDriver implements Driver +class AnnotationDriver extends AbstractAnnotationDriver implements Driver { - /** - * The AnnotationReader. - * - * @var AnnotationReader - */ - private $reader; - - /** - * The paths where to look for mapping files. - * - * @var array - */ - private $paths = array(); - - /** - * The file extension of mapping documents. - * - * @var string - */ - private $fileExtension = '.php'; - - /** - * @param array - */ - private $classNames; /** + * {@inheritdoc} + * * Document annotation classes, ordered by precedence. */ - static private $documentAnnotationClasses = array( - 'Doctrine\\ODM\\PHPCR\\Mapping\\Annotations\\Document', - 'Doctrine\\ODM\\PHPCR\\Mapping\\Annotations\\MappedSuperclass', + protected $entityAnnotationClasses = array( + 'Doctrine\\ODM\\PHPCR\\Mapping\\Annotations\\Document' => 0, + 'Doctrine\\ODM\\PHPCR\\Mapping\\Annotations\\MappedSuperclass' => 1, ); - /** - * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading - * docblock annotations. - * - * @param $reader The AnnotationReader to use. - * @param string|array $paths One or multiple paths where mapping classes can be found. - */ - public function __construct(Reader $reader, $paths = null) - { - $this->reader = $reader; - if ($paths) { - $this->addPaths((array) $paths); - } - } - - /** - * Append lookup paths to metadata driver. - * - * @param array $paths - */ - public function addPaths(array $paths) - { - $this->paths = array_unique(array_merge($this->paths, $paths)); - } - - /** - * Retrieve the defined metadata lookup paths. - * - * @return array - */ - public function getPaths() - { - return $this->paths; - } - /** * {@inheritdoc} */ - public function loadMetadataForClass($className, ClassMetadata $class) + public function loadMetadataForClass($className, ClassMetadata $metadata) { - $reflClass = $class->getReflectionClass(); + $reflClass = $metadata->getReflectionClass(); $documentAnnots = array(); foreach ($this->reader->getClassAnnotations($reflClass) as $annot) { - foreach (self::$documentAnnotationClasses as $i => $annotClass) { + foreach ($this->entityAnnotationClasses as $annotClass => $i) { if ($annot instanceof $annotClass) { $documentAnnots[$i] = $annot; } @@ -135,22 +78,22 @@ public function loadMetadataForClass($className, ClassMetadata $class) throw new MappingException("Alias must be specified in the Document() annotation mapping of $className"); } - $class->setAlias($documentAnnot->alias); + $metadata->setAlias($documentAnnot->alias); if (isset($documentAnnot->versionable) && $documentAnnot->versionable) { - $class->setVersioned(true); + $metadata->setVersioned(true); } - $class->setNodeType($documentAnnot->nodeType); + $metadata->setNodeType($documentAnnot->nodeType); if (isset($documentAnnot->referenceable) && $documentAnnot->referenceable) { - $class->setReferenceable(true); + $metadata->setReferenceable(true); } if ($documentAnnot->repositoryClass) { - $class->setCustomRepositoryClassName($documentAnnot->repositoryClass); + $metadata->setCustomRepositoryClassName($documentAnnot->repositoryClass); } if ($documentAnnot->translator) { - $class->setTranslator($documentAnnot->translator); + $metadata->setTranslator($documentAnnot->translator); } foreach ($reflClass->getProperties() as $property) { @@ -158,39 +101,39 @@ public function loadMetadataForClass($className, ClassMetadata $class) $mapping['fieldName'] = $property->getName(); foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) { - if ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\Property) { + if ($fieldAnnot instanceof ODM\Property) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapField($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\Id) { + $metadata->mapField($mapping); + } elseif ($fieldAnnot instanceof ODM\Id) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapId($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\Node) { + $metadata->mapId($mapping); + } elseif ($fieldAnnot instanceof ODM\Node) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapNode($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\Nodename) { + $metadata->mapNode($mapping); + } elseif ($fieldAnnot instanceof ODM\Nodename) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapNodename($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\ParentDocument) { + $metadata->mapNodename($mapping); + } elseif ($fieldAnnot instanceof ODM\ParentDocument) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapParentDocument($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\Child) { + $metadata->mapParentDocument($mapping); + } elseif ($fieldAnnot instanceof ODM\Child) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapChild($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\Children) { + $metadata->mapChild($mapping); + } elseif ($fieldAnnot instanceof ODM\Children) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapChildren($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\ReferenceOne) { + $metadata->mapChildren($mapping); + } elseif ($fieldAnnot instanceof ODM\ReferenceOne) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapManyToOne($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\ReferenceMany) { + $metadata->mapManyToOne($mapping); + } elseif ($fieldAnnot instanceof ODM\ReferenceMany) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapManyToMany($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\Referrers) { + $metadata->mapManyToMany($mapping); + } elseif ($fieldAnnot instanceof ODM\Referrers) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapReferrers($mapping); - } elseif ($fieldAnnot instanceof \Doctrine\ODM\PHPCR\Mapping\Annotations\Locale) { + $metadata->mapReferrers($mapping); + } elseif ($fieldAnnot instanceof ODM\Locale) { $mapping = array_merge($mapping, (array) $fieldAnnot); - $class->mapLocale($mapping); + $metadata->mapLocale($mapping); } if (!isset($mapping['name'])) { @@ -203,106 +146,32 @@ public function loadMetadataForClass($className, ClassMetadata $class) if ($method->isPublic()) { foreach ($this->reader->getMethodAnnotations($method) as $annot) { if ($annot instanceof ODM\PrePersist) { - $class->addLifecycleCallback($method->getName(), \Doctrine\ODM\PHPCR\Event::prePersist); + $metadata->addLifecycleCallback($method->getName(), Event::prePersist); } elseif ($annot instanceof ODM\PostPersist) { - $class->addLifecycleCallback($method->getName(), \Doctrine\ODM\PHPCR\Event::postPersist); + $metadata->addLifecycleCallback($method->getName(), Event::postPersist); } elseif ($annot instanceof ODM\PreUpdate) { - $class->addLifecycleCallback($method->getName(), \Doctrine\ODM\PHPCR\Event::preUpdate); + $metadata->addLifecycleCallback($method->getName(), Event::preUpdate); } elseif ($annot instanceof ODM\PostUpdate) { - $class->addLifecycleCallback($method->getName(), \Doctrine\ODM\PHPCR\Event::postUpdate); + $metadata->addLifecycleCallback($method->getName(), Event::postUpdate); } elseif ($annot instanceof ODM\PreRemove) { - $class->addLifecycleCallback($method->getName(), \Doctrine\ODM\PHPCR\Event::preRemove); + $metadata->addLifecycleCallback($method->getName(), Event::preRemove); } elseif ($annot instanceof ODM\PostRemove) { - $class->addLifecycleCallback($method->getName(), \Doctrine\ODM\PHPCR\Event::postRemove); + $metadata->addLifecycleCallback($method->getName(), Event::postRemove); } elseif ($annot instanceof ODM\PreLoad) { - $class->addLifecycleCallback($method->getName(), \Doctrine\ODM\PHPCR\Event::preLoad); + $metadata->addLifecycleCallback($method->getName(), Event::preLoad); } elseif ($annot instanceof ODM\PostLoad) { - $class->addLifecycleCallback($method->getName(), \Doctrine\ODM\PHPCR\Event::postLoad); + $metadata->addLifecycleCallback($method->getName(), Event::postLoad); } } } } // Check there is a @Locale annotation for translatable documents - if (count($class->translatableFields)) { - if (!isset($class->localeMapping)) { + if (count($metadata->translatableFields)) { + if (!isset($metadata->localeMapping)) { throw new MappingException("You must define a @Locale field for translatable document '$className'"); } } } - /** - * Whether the class with the specified name is transient. Only non-transient - * classes, that is entities and mapped superclasses, should have their metadata loaded. - * A class is non-transient if it is annotated with either @Entity or - * @MappedSuperclass in the class doc block. - * - * @param string $className - * @return boolean - */ - public function isTransient($className) - { - $rc = new \ReflectionClass($className); - - if ($this->reader->getClassAnnotation($rc, 'Doctrine\ODM\PHPCR\Mapping\Annotations\Document')) { - return false; - } - - if ($this->reader->getClassAnnotation($rc, 'Doctrine\ODM\PHPCR\Mapping\Annotations\MappedSuperclass')) { - return false; - } - - return true; - } - - /** - * {@inheritDoc} - */ - public function getAllClassNames() - { - if ($this->classNames !== null) { - return $this->classNames; - } - - if (!$this->paths) { - throw MappingException::pathRequired(); - } - - $classes = array(); - $includedFiles = array(); - - foreach ($this->paths as $path) { - if (!is_dir($path)) { - throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath(); - } - - $iterator = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path), - \RecursiveIteratorIterator::LEAVES_ONLY - ); - - foreach ($iterator as $file) { - if (($file->getBasename($this->fileExtension)) == $file->getBasename()) { - continue; - } - - $sourceFile = realpath($file->getPathName()); - require_once $sourceFile; - $includedFiles[] = $sourceFile; - } - } - - $declared = get_declared_classes(); - - foreach ($declared as $className) { - $rc = new \ReflectionClass($className); - $sourceFile = $rc->getFileName(); - if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) { - $classes[] = $className; - } - } - $this->classNames = $classes; - - return $classes; - } -} +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php index 502b7c87b..f7fa48f0d 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/BuiltinDocumentsDriver.php @@ -3,7 +3,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Driver; use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\ODM\PHPCR\Mapping\MappingException; use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; @@ -90,4 +90,4 @@ public function isTransient($className) return $this->wrappedDriver->isTransient($className); } -} +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/Driver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/Driver.php index a82d8d4f5..28684e885 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/Driver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/Driver.php @@ -19,7 +19,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Driver; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; /** * Contract for metadata drivers. @@ -30,30 +30,7 @@ * @author Jonathan H. Wage * @author Roman Borschel */ -interface Driver +interface Driver extends MappingDriver { - /** - * Loads the metadata for the specified class into the provided container. - * - * @param string $className - * @param ClassMetadataInfo $metadata - */ - function loadMetadataForClass($className, ClassMetadata $metadata); - /** - * Gets the names of all mapped classes known to this driver. - * - * @return array The names of all mapped classes known to this driver. - */ - function getAllClassNames(); - - /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped as an Document or a - * MappedSuperclass. - * - * @param string $className - * @return boolean - */ - function isTransient($className); -} +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/DriverChain.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/DriverChain.php index 63600d6c2..503def4c8 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/DriverChain.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/DriverChain.php @@ -2,7 +2,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Driver; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\ODM\PHPCR\Mapping\MappingException; /** @@ -93,4 +93,4 @@ public function isTransient($className) // class isTransient, i.e. not an document or mapped superclass return true; } -} +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/PHPDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/PHPDriver.php index 8362808e8..4ef141ada 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/PHPDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/PHPDriver.php @@ -19,7 +19,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Driver; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; /** * The PHPDriver invokes a static PHP function on the document class itself passing diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/XmlDriver.php index 0c6487f21..b15b5c313 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/XmlDriver.php @@ -19,7 +19,7 @@ namespace Doctrine\ODM\PHPCR\Mapping\Driver; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\ODM\PHPCR\Mapping\MappingException; use SimpleXmlElement; @@ -204,4 +204,4 @@ protected function loadMappingFile($file) return $result; } -} +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/YamlDriver.php index 41bf6a23c..b6e2a57ac 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/YamlDriver.php @@ -19,8 +19,8 @@ namespace Doctrine\ODM\PHPCR\Mapping\Driver; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadata, - Doctrine\ODM\PHPCR\Mapping\MappingException; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\ODM\PHPCR\Mapping\MappingException; /** * The YamlDriver reads the mapping metadata from yaml schema files. @@ -194,4 +194,4 @@ protected function loadMappingFile($file) { return \Symfony\Component\Yaml\Yaml::parse($file); } -} +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php b/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php index 1f0ebc732..151028a51 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php @@ -49,7 +49,8 @@ public static function reflectionFailure($document, \ReflectionException $previo * @param string $document The document's name * @param string $fieldName The name of the field that was already declared */ - public static function duplicateFieldMapping($document, $fieldName) { + public static function duplicateFieldMapping($document, $fieldName) + { return new self('Property "'.$fieldName.'" in "'.$document.'" was already declared, but it must be declared only once'); } @@ -57,7 +58,8 @@ public static function duplicateFieldMapping($document, $fieldName) { * @param string $document The document's name * @param string $fieldName The name of the field that was already declared */ - public static function missingTypeDefinition($document, $fieldName) { + public static function missingTypeDefinition($document, $fieldName) + { return new self('Property "'.$fieldName.'" in "'.$document.'" must have a type attribute defined'); } @@ -71,9 +73,9 @@ public static function aliasIsNotSpecified($document) return new self('Document '.$document.' must specify an alias'); } - public static function classNotMapped() + public static function classNotMapped($className) { - return new self(); + return new self('Class ' . $className . ' is not mapped to a document'); } public static function noTypeSpecified() @@ -85,4 +87,4 @@ public static function mappingNotFound($className, $fieldName) { return new self("No mapping found for field '$fieldName' in class '$className'."); } -} +} \ No newline at end of file diff --git a/lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php b/lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php index fb83fcda6..5bfaf47ba 100644 --- a/lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php @@ -333,7 +333,11 @@ public function &__get($name) return $this->$name; } + public function __isInitialized() + { + return $this->__isInitialized__; + } + } PHP; -} - +} \ No newline at end of file diff --git a/lib/vendor/doctrine-common b/lib/vendor/doctrine-common index 583b0e1d4..16b2385b3 160000 --- a/lib/vendor/doctrine-common +++ b/lib/vendor/doctrine-common @@ -1 +1 @@ -Subproject commit 583b0e1d461d63d928cbf5ca18a6a408eeaaf1e9 +Subproject commit 16b2385b3ce5319d88969f18694e4b36533bd258