Exemplo n.º 1
0
 public function setUp()
 {
     $config = new Configuration();
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver("tests/Doctrine/Tests/OXM/Entities"));
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $this->metadataFactory = new ClassMetadataFactory($config);
     $this->marshaller = new XmlMarshaller($this->metadataFactory);
 }
Exemplo n.º 2
0
 /**
  * Creates a new XmlEntityManager that uses the given Configuration and EventManager implementations.
  *
  * @param Storage $storage
  * @param Configuration $config
  * @param \Doctrine\Common\EventManager $eventManager
  */
 public function __construct(Storage $storage, Configuration $config, EventManager $eventManager = null)
 {
     $this->storage = $storage;
     $this->config = $config;
     if (null === $eventManager) {
         $eventManager = new EventManager();
     }
     $this->eventManager = $eventManager;
     $metadataFactoryClassName = $config->getClassMetadataFactoryName();
     $this->metadataFactory = new $metadataFactoryClassName($config, $this->eventManager);
     $this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl());
     $marshallerClassName = $config->getMarshallerClassName();
     $this->marshaller = new $marshallerClassName($this->metadataFactory);
     $this->unitOfWork = new UnitOfWork($this);
 }
Exemplo n.º 3
0
 /**
  * Lazy initialization of this stuff, especially the metadata driver,
  * since these are not needed at all when a metadata cache is active.
  */
 private function initialize()
 {
     $this->cacheDriver = $this->configuration->getMetadataCacheImpl();
     $this->driver = $this->configuration->getMetadataDriverImpl();
     if (null === $this->evm) {
         $this->evm = new EventManager();
     }
     $this->initialized = true;
 }
Exemplo n.º 4
0
 /**
  * Gets the class metadata descriptor for a class.
  *
  * @param string $className The name of the class.
  * @return \Doctrine\OXM\Mapping\ClassMetadata
  */
 public function getMetadataFor($className)
 {
     if (!isset($this->loadedMetadata[$className])) {
         //            print_r('loading class ' . $className . "\n");
         $realClassName = $className;
         // Check for namespace alias
         if (strpos($className, ':') !== false) {
             list($namespaceAlias, $simpleClassName) = explode(':', $className);
             $realClassName = $this->configuration->getEntityNamespace($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}\$XMLCLASSMETADATA")) !== false) {
                 $this->loadedMetadata[$realClassName] = $cached;
                 if (!$cached->isMappedSuperclass) {
                     $this->xmlToClassMap[$cached->getXmlName()] = $realClassName;
                 }
             } else {
                 foreach ($this->loadMetadata($realClassName) as $loadedClassName) {
                     $this->cacheDriver->save("{$loadedClassName}\$XMLCLASSMETADATA", $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];
 }
 /**
  * {@inheritDoc}
  */
 protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
 {
     return $this->configuration->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
 }