PK .CV兄2 2 phpunit.xml.distnu W+A
./tests/Doctrine/
./lib/Doctrine/
performance
PK .CV( ' lib/Doctrine/Common/EventSubscriber.phpnu W+A .
*/
namespace Doctrine\Common;
/**
* An EventSubscriber knows himself what events he is interested in.
* If an EventSubscriber is added to an EventManager, the manager invokes
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @author Guilherme Blanco
* @author Jonathan Wage
* @author Roman Borschel
*/
interface EventSubscriber
{
/**
* Returns an array of events this subscriber wants to listen to.
*
* @return array
*/
function getSubscribedEvents();
}
PK .CV~Li i 3 lib/Doctrine/Common/Persistence/ManagerRegistry.phpnu W+A .
*/
namespace Doctrine\Common\Persistence;
/**
* Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.2
* @author Fabien Potencier
* @author Benjamin Eberlei
* @author Lukas Kahwe Smith
*/
interface ManagerRegistry extends ConnectionRegistry
{
/**
* Gets the default object manager name.
*
* @return string The default object manager name
*/
function getDefaultManagerName();
/**
* Gets a named object manager.
*
* @param string $name The object manager name (null for the default one)
*
* @return \Doctrine\Common\Persistence\ObjectManager
*/
function getManager($name = null);
/**
* Gets an array of all registered object managers
*
* @return \Doctrine\Common\Persistence\ObjectManager[] An array of ObjectManager instances
*/
function getManagers();
/**
* Resets a named object manager.
*
* This method is useful when an object manager has been closed
* because of a rollbacked transaction AND when you think that
* it makes sense to get a new one to replace the closed one.
*
* Be warned that you will get a brand new object manager as
* the existing one is not useable anymore. This means that any
* other object with a dependency on this object manager will
* hold an obsolete reference. You can inject the registry instead
* to avoid this problem.
*
* @param string $name The object manager name (null for the default one)
*
* @return \Doctrine\Common\Persistence\ObjectManager
*/
function resetManager($name = null);
/**
* Resolves a registered namespace alias to the full namespace.
*
* This method looks for the alias in all registered object managers.
*
* @param string $alias The alias
*
* @return string The full namespace
*/
function getAliasNamespace($alias);
/**
* Gets all connection names.
*
* @return array An array of connection names
*/
function getManagerNames();
/**
* Gets the ObjectRepository for an persistent object.
*
* @param string $persistentObject The name of the persistent object.
* @param string $persistentManagerName The object manager name (null for the default one)
*
* @return \Doctrine\Common\Persistence\ObjectRepository
*/
function getRepository($persistentObject, $persistentManagerName = null);
/**
* Gets the object manager associated with a given class.
*
* @param string $class A persistent object class name
*
* @return \Doctrine\Common\Persistence\ObjectManager|null
*/
function getManagerForClass($class);
}
PK .CVX X 6 lib/Doctrine/Common/Persistence/ObjectManagerAware.phpnu W+A .
*/
namespace Doctrine\Common\Persistence;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
/**
* Makes a Persistent Objects aware of its own object-manager.
*
* Using this interface the managing object manager and class metadata instances
* are injected into the persistent object after construction. This allows
* you to implement ActiveRecord functionality on top of the persistance-ignorance
* that Doctrine propagates.
*
* Word of Warning: This is a very powerful hook to change how you can work with your domain models.
* Using this hook will break the Single Responsibility Principle inside your Domain Objects
* and increase the coupling of database and objects.
*
* Every ObjectManager has to implement this functionality itself.
*
* @author Benjamin Eberlei
*/
interface ObjectManagerAware
{
/**
* Injects responsible ObjectManager and the ClassMetadata into this persistent object.
*
* @param ObjectManager $objectManager
* @param ClassMetadata $classMetadata
*/
public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata);
}
PK .CVܠ+. . H lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.phpnu W+A .
*/
namespace Doctrine\Common\Persistence\Mapping;
use Doctrine\Common\Cache\Cache,
Doctrine\Common\Util\ClassUtils;
/**
* 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
* to a relational database.
*
* This class was abstracted from the ORM ClassMetadataFactory
*
* @since 2.2
* @author Benjamin Eberlei
* @author Guilherme Blanco
* @author Jonathan Wage
* @author Roman Borschel
*/
abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
{
/**
* Salt used by specific Object Manager implementation.
*
* @var string
*/
protected $cacheSalt = "\$CLASSMETADATA";
/**
* @var \Doctrine\Common\Cache\Cache
*/
private $cacheDriver;
/**
* @var array
*/
private $loadedMetadata = array();
/**
* @var bool
*/
protected $initialized = false;
/**
* @var ReflectionService
*/
private $reflectionService;
/**
* Sets the cache driver used by the factory to cache ClassMetadata instances.
*
* @param Doctrine\Common\Cache\Cache $cacheDriver
*/
public function setCacheDriver(Cache $cacheDriver = null)
{
$this->cacheDriver = $cacheDriver;
}
/**
* Gets the cache driver used by the factory to cache ClassMetadata instances.
*
* @return Doctrine\Common\Cache\Cache
*/
public function getCacheDriver()
{
return $this->cacheDriver;
}
/**
* Return an array of all the loaded metadata currently in memory.
*
* @return array
*/
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()
{
if ( ! $this->initialized) {
$this->initialize();
}
$driver = $this->getDriver();
$metadata = array();
foreach ($driver->getAllClassNames() as $className) {
$metadata[] = $this->getMetadataFor($className);
}
return $metadata;
}
/**
* Lazy initialization of this stuff, especially the metadata driver,
* since these are not needed at all when a metadata cache is active.
*
* @return void
*/
abstract protected function initialize();
/**
* Get the fully qualified class-name from the namespace alias.
*
* @param string $namespaceAlias
* @param string $simpleClassName
* @return string
*/
abstract protected function getFqcnFromAlias($namespaceAlias, $simpleClassName);
/**
* Return the mapping driver implementation.
*
* @return \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver
*/
abstract protected function getDriver();
/**
* Wakeup reflection after ClassMetadata gets unserialized from cache.
*
* @param ClassMetadata $class
* @param ReflectionService $reflService
* @return void
*/
abstract protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService);
/**
* Initialize Reflection after ClassMetadata was constructed.
*
* @param ClassMetadata $class
* @param ReflectionService $reflService
* @return void
*/
abstract protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService);
/**
* Checks whether the class metadata is an entity.
*
* This method should false for mapped superclasses or
* embedded classes.
*
* @param ClassMetadata $class
* @return boolean
*/
abstract protected function isEntity(ClassMetadata $class);
/**
* Gets the class metadata descriptor for a class.
*
* @param string $className The name of the class.
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
*/
public function getMetadataFor($className)
{
if (isset($this->loadedMetadata[$className])) {
return $this->loadedMetadata[$className];
}
$realClassName = $className;
// Check for namespace alias
if (strpos($className, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $className);
$realClassName = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName);
} else {
$realClassName = ClassUtils::getRealClass($realClassName);
}
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 . $this->cacheSalt)) !== false) {
$this->loadedMetadata[$realClassName] = $cached;
$this->wakeupReflection($cached, $this->getReflectionService());
} else {
foreach ($this->loadMetadata($realClassName) as $loadedClassName) {
$this->cacheDriver->save(
$loadedClassName . $this->cacheSalt, $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];
}
return $this->loadedMetadata[$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.
*/
public function hasMetadataFor($className)
{
return isset($this->loadedMetadata[$className]);
}
/**
* 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
*/
public function setMetadataFor($className, $class)
{
$this->loadedMetadata[$className] = $class;
}
/**
* Get array of parent classes for the given entity class
*
* @param string $name
* @return array $parentClasses
*/
protected function getParentClasses($name)
{
// Collect parent classes, ignoring transient (not-mapped) classes.
$parentClasses = array();
foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) {
if ( ! $this->getDriver()->isTransient($parentClass)) {
$parentClasses[] = $parentClass;
}
}
return $parentClasses;
}
/**
* Loads the metadata of the class in question and all it's ancestors whose metadata
* is still not loaded.
*
* @param string $name The name of the class for which the metadata should get loaded.
*
* @return array
*/
protected function loadMetadata($name)
{
if ( ! $this->initialized) {
$this->initialize();
}
$loaded = array();
$parentClasses = $this->getParentClasses($name);
$parentClasses[] = $name;
// Move down the hierarchy of parent classes, starting from the topmost class
$parent = null;
$rootEntityFound = false;
$visited = array();
$reflService = $this->getReflectionService();
foreach ($parentClasses as $className) {
if (isset($this->loadedMetadata[$className])) {
$parent = $this->loadedMetadata[$className];
if ($this->isEntity($parent)) {
$rootEntityFound = true;
array_unshift($visited, $className);
}
continue;
}
$class = $this->newClassMetadataInstance($className);
$this->initializeReflection($class, $reflService);
$this->doLoadMetadata($class, $parent, $rootEntityFound, $visited);
$this->loadedMetadata[$className] = $class;
$parent = $class;
if ($this->isEntity($class)) {
$rootEntityFound = true;
array_unshift($visited, $className);
}
$this->wakeupReflection($class, $reflService);
$loaded[] = $className;
}
return $loaded;
}
/**
* Actually load the metadata from the underlying metadata
*
* @param ClassMetadata $class
* @param ClassMetadata|null $parent
* @param bool $rootEntityFound
* @param array $nonSuperclassParents classnames all parent classes that are not marked as mapped superclasses
* @return void
*/
abstract protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents);
/**
* Creates a new ClassMetadata instance for the given class name.
*
* @param string $className
* @return ClassMetadata
*/
abstract protected function newClassMetadataInstance($className);
/**
* Check if this class is mapped by this Object Manager + ClassMetadata configuration
*
* @param $class
* @return bool
*/
public function isTransient($class)
{
if ( ! $this->initialized) {
$this->initialize();
}
// Check for namespace alias
if (strpos($class, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $class);
$class = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName);
}
return $this->getDriver()->isTransient($class);
}
/**
* Set reflectionService.
*
* @param ReflectionService $reflectionService
*/
public function setReflectionService(ReflectionService $reflectionService)
{
$this->reflectionService = $reflectionService;
}
/**
* Get the reflection service associated with this metadata factory.
*
* @return ReflectionService
*/
public function getReflectionService()
{
if ($this->reflectionService === null) {
$this->reflectionService = new RuntimeReflectionService();
}
return $this->reflectionService;
}
}
PK .CVڿ
@ lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.phpnu W+A .
*/
namespace Doctrine\Common\Persistence\Mapping;
/**
* Contract for a Doctrine persistence layer ClassMetadata class to implement.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.1
* @author Benjamin Eberlei
* @author Jonathan Wage
*/
interface ClassMetadataFactory
{
/**
* 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.
*/
function getAllMetadata();
/**
* Gets the class metadata descriptor for a class.
*
* @param string $className The name of the class.
* @return ClassMetadata
*/
function getMetadataFor($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.
*/
function hasMetadataFor($className);
/**
* Sets the metadata descriptor for a specific class.
*
* @param string $className
* @param ClassMetadata $class
*/
function setMetadataFor($className, $class);
/**
* Whether the class with the specified name should have its metadata loaded.
* This is only the case if it is either mapped directly or as a
* MappedSuperclass.
*
* @param string $className
* @return boolean
*/
function isTransient($className);
}
PK .CVnf f 9 lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.phpnu W+A .
*/
namespace Doctrine\Common\Persistence\Mapping;
/**
* Contract for a Doctrine persistence layer ClassMetadata class to implement.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.1
* @author Benjamin Eberlei
* @author Jonathan Wage
*/
interface ClassMetadata
{
/**
* Get fully-qualified class name of this persistent class.
*
* @return string
*/
function getName();
/**
* Gets the mapped identifier field name.
*
* The returned structure is an array of the identifier field names.
*
* @return array
*/
function getIdentifier();
/**
* Gets the ReflectionClass instance for this mapped class.
*
* @return \ReflectionClass
*/
function getReflectionClass();
/**
* Checks if the given field name is a mapped identifier for this class.
*
* @param string $fieldName
* @return boolean
*/
function isIdentifier($fieldName);
/**
* Checks if the given field is a mapped property for this class.
*
* @param string $fieldName
* @return boolean
*/
function hasField($fieldName);
/**
* Checks if the given field is a mapped association for this class.
*
* @param string $fieldName
* @return boolean
*/
function hasAssociation($fieldName);
/**
* Checks if the given field is a mapped single valued association for this class.
*
* @param string $fieldName
* @return boolean
*/
function isSingleValuedAssociation($fieldName);
/**
* Checks if the given field is a mapped collection valued association for this class.
*
* @param string $fieldName
* @return boolean
*/
function isCollectionValuedAssociation($fieldName);
/**
* A numerically indexed list of field names of this persistent class.
*
* This array includes identifier fields if present on this class.
*
* @return array
*/
function getFieldNames();
/**
* Returns an array of identifier field names numerically indexed.
*
* @return array
*/
function getIdentifierFieldNames();
/**
* A numerically indexed list of association names of this persistent class.
*
* This array includes identifier associations if present on this class.
*
* @return array
*/
function getAssociationNames();
/**
* Returns a type name of this field.
*
* This type names can be implementation specific but should at least include the php types:
* integer, string, boolean, float/double, datetime.
*
* @param string $fieldName
* @return string
*/
function getTypeOfField($fieldName);
/**
* Returns the target class name of the given association.
*
* @param string $assocName
* @return string
*/
function getAssociationTargetClass($assocName);
/**
* Checks if the association is the inverse side of a bidirectional association
*
* @param string $assocName
* @return boolean
*/
function isAssociationInverseSide($assocName);
/**
* Returns the target field of the owning side of the association
*
* @param string $assocName
* @return string
*/
function getAssociationMappedByTargetField($assocName);
/**
* Return the identifier of this object as an array with field name as key.
*
* Has to return an empty array if no identifier isset.
*
* @param object $object
* @return array
*/
function getIdentifierValues($object);
}
PK .CVII I D lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.phpnu W+A .
*/
namespace Doctrine\Common\Persistence\Mapping;
use ReflectionClass;
use ReflectionProperty;
/**
* PHP Runtime Reflection Service
*
* @author Benjamin Eberlei
*/
class RuntimeReflectionService implements ReflectionService
{
/**
* Return an array of the parent classes (not interfaces) for the given class.
*
* @param string $class
* @return array
*/
public function getParentClasses($class)
{
return class_parents($class);
}
/**
* Return the shortname of a class.
*
* @param string $class
* @return string
*/
public function getClassShortName($class)
{
$r = new ReflectionClass($class);
return $r->getShortName();
}
/**
* @param string $class
* @return string
*/
public function getClassNamespace($class)
{
$r = new ReflectionClass($class);
return $r->getNamespaceName();
}
/**
* Return a reflection class instance or null
*
* @param string $class
* @return ReflectionClass|null
*/
public function getClass($class)
{
return new ReflectionClass($class);
}
/**
* Return an accessible property (setAccessible(true)) or null.
*
* @param string $class
* @param string $property
* @return ReflectionProperty|null
*/
public function getAccessibleProperty($class, $property)
{
$property = new ReflectionProperty($class, $property);
$property->setAccessible(true);
return $property;
}
/**
* Check if the class have a public method with the given name.
*
* @param mixed $class
* @param mixed $method
* @return bool
*/
public function hasPublicMethod($class, $method)
{
return method_exists($class, $method) && is_callable(array($class, $method));
}
}
PK .CV#X E lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.phpnu W+A .
*/
namespace Doctrine\Common\Persistence\Mapping\Driver;
use Doctrine\Common\Persistence\Mapping\MappingException;
/**
* The Symfony File Locator makes a simplifying assumptions compared
* to the DefaultFileLocator. By assuming paths only contain entities of a certain
* namespace the mapping files consists of the short classname only.
*
* @author Fabien Potencier
* @author Benjamin Eberlei
* @license MIT
*/
class SymfonyFileLocator implements FileLocator
{
/**
* The paths where to look for mapping files.
*
* @var array
*/
protected $paths = array();
/**
* A map of mapping directory path to namespace prefix used to expand class shortnames.
*
* @var array
*/
protected $prefixes = array();
/**
* File extension that is searched for.
*
* @var string
*/
protected $fileExtension;
/**
* Constructor
*
* @param array $prefixes
* @param string|null $fileExtension
*/
public function __construct(array $prefixes, $fileExtension = null)
{
$this->addNamespacePrefixes($prefixes);
$this->fileExtension = $fileExtension;
}
/**
* Add Namespace Prefixes
*
* @param array $prefixes
*/
public function addNamespacePrefixes(array $prefixes)
{
$this->prefixes = array_merge($this->prefixes, $prefixes);
$this->paths = array_merge($this->paths, array_keys($prefixes));
}
/**
* Get Namespace Prefixes
*
* @return array
*/
public function getNamespacePrefixes()
{
return $this->prefixes;
}
/**
* {@inheritDoc}
*/
public function getPaths()
{
return $this->paths;
}
/**
* {@inheritDoc}
*/
public function getFileExtension()
{
return $this->fileExtension;
}
/**
* Set the file extension used to look for mapping files under
*
* @param string $fileExtension The file extension to set
* @return void
*/
public function setFileExtension($fileExtension)
{
$this->fileExtension = $fileExtension;
}
/**
* {@inheritDoc}
*/
public function fileExists($className)
{
$defaultFileName = str_replace('\\', '.', $className).$this->fileExtension;
foreach ($this->paths as $path) {
if (!isset($this->prefixes[$path])) {
// global namespace class
if (is_file($path.DIRECTORY_SEPARATOR.$defaultFileName)) {
return true;
}
continue;
}
$prefix = $this->prefixes[$path];
if (0 !== strpos($className, $prefix.'\\')) {
continue;
}
$filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->fileExtension;
return is_file($filename);
}
return false;
}
/**
* {@inheritDoc}
*/
public function getAllClassNames($globalBasename = null)
{
$classes = array();
if ($this->paths) {
foreach ((array) $this->paths as $path) {
if (!is_dir($path)) {
throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
}
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($path),
\RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($iterator as $file) {
$fileName = $file->getBasename($this->fileExtension);
if ($fileName == $file->getBasename() || $fileName == $globalBasename) {
continue;
}
// NOTE: All files found here means classes are not transient!
if (isset($this->prefixes[$path])) {
$classes[] = $this->prefixes[$path].'\\'.str_replace('.', '\\', $fileName);
} else {
$classes[] = str_replace('.', '\\', $fileName);
}
}
}
}
return $classes;
}
/**
* {@inheritDoc}
*/
public function findMappingFile($className)
{
$defaultFileName = str_replace('\\', '.', $className).$this->fileExtension;
foreach ($this->paths as $path) {
if (!isset($this->prefixes[$path])) {
if (is_file($path.DIRECTORY_SEPARATOR.$defaultFileName)) {
return $path.DIRECTORY_SEPARATOR.$defaultFileName;
}
continue;
}
$prefix = $this->prefixes[$path];
if (0 !== strpos($className, $prefix.'\\')) {
continue;
}
$filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->fileExtension;
if (is_file($filename)) {
return $filename;
}
throw MappingException::mappingFileNotFound($className, $filename);
}
throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1).$this->fileExtension);
}
}
PK .CVCZ2 C lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.phpnu W+A .
*/
namespace Doctrine\Common\Persistence\Mapping\Driver;
use Doctrine\Common\Cache\ArrayCache,
Doctrine\Common\Annotations\AnnotationReader,
Doctrine\Common\Annotations\AnnotationRegistry,
Doctrine\Common\Persistence\Mapping\MappingException;
/**
* The AnnotationDriver reads the mapping metadata from docblock annotations.
*
* @since 2.2
* @author Benjamin Eberlei
* @author Guilherme Blanco
* @author Jonathan H. Wage
* @author Roman Borschel
*/
abstract class AnnotationDriver implements MappingDriver
{
/**
* The AnnotationReader.
*
* @var AnnotationReader
*/
protected $reader;
/**
* The paths where to look for mapping files.
*
* @var array
*/
protected $paths = array();
/**
* The file extension of mapping documents.
*
* @var string
*/
protected $fileExtension = '.php';
/**
* Cache for AnnotationDriver#getAllClassNames()
*
* @var array
*/
protected $classNames;
/**
* Name of the entity annotations as keys
*
* @var array
*/
protected $entityAnnotationClasses = array();
/**
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
* docblock annotations.
*
* @param AnnotationReader $reader The AnnotationReader to use, duck-typed.
* @param string|array $paths One or multiple paths where mapping classes can be found.
*/
public function __construct($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;
}
/**
* Retrieve the current annotation reader
*
* @return AnnotationReader
*/
public function getReader()
{
return $this->reader;
}
/**
* Get the file extension used to look for mapping files under
*
* @return string
*/
public function getFileExtension()
{
return $this->fileExtension;
}
/**
* Set the file extension used to look for mapping files under
*
* @param string $fileExtension The file extension to set
* @return void
*/
public function setFileExtension($fileExtension)
{
$this->fileExtension = $fileExtension;
}
/**
* 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 an annotation
* from the {@see AnnotationDriver::entityAnnotationClasses}.
*
* @param string $className
* @return boolean
*/
public function isTransient($className)
{
$classAnnotations = $this->reader->getClassAnnotations(new \ReflectionClass($className));
foreach ($classAnnotations as $annot) {
if (isset($this->entityAnnotationClasses[get_class($annot)])) {
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($path);
}
$iterator = new \RegexIterator(
new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::LEAVES_ONLY
),
'/^.+' . str_replace('.', '\.', $this->fileExtension) . '$/i',
\RecursiveRegexIterator::GET_MATCH
);
foreach ($iterator as $file) {
$sourceFile = realpath($file[0]);
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;
}
}
PK .CVހ5 5 <