/**
  * @throws \Doctrine\ORM\ORMException
  */
 public function boot()
 {
     $this->serializer = SerializerBuilder::create()->setDebug($this->devMode)->build();
     $this->entityFolder->create();
     AnnotationRegistry::registerAutoloadNamespace('JMS\\Serializer\\Annotation', __DIR__ . '/../../../../vendor/jms/serializer/src');
     $proxyDoctrineFolder = new Folder(sys_get_temp_dir() . '/doctrine');
     $config = Setup::createAnnotationMetadataConfiguration([$this->entityFolder->absolute()], $this->isDevMode(), $proxyDoctrineFolder->absolute());
     if ($this->cache !== null) {
         $config->setQueryCacheImpl($this->getCache());
         $config->setResultCacheImpl($this->getCache());
     }
     $this->entityManager = $this->createEntityManager($config);
     $debugStack = new DebugStack();
     $this->entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack);
     if ($this->getFileCreation()->getContent() == 1) {
         return;
     }
     if ($proxyDoctrineFolder->isFolder()) {
         $proxyDoctrineFolder->removeFiles();
     }
     $tool = new SchemaTool($this->entityManager);
     $metadatas = $this->entityManager->getMetadataFactory()->getAllMetadata();
     $proxyDoctrineFolder->create();
     $this->entityManager->getProxyFactory()->generateProxyClasses($metadatas, $proxyDoctrineFolder->absolute());
     if ($this->cloudFoundryBoot->isInCloudFoundry()) {
         $tool->updateSchema($metadatas);
     } else {
         $tool->createSchema($metadatas);
     }
     $this->getFileCreation()->setContent(1);
 }
Exemplo n.º 2
0
 private function loadAnnotationFromCache()
 {
     $annotationsFolder = new Folder(sys_get_temp_dir() . DIRECTORY_SEPARATOR . SphringCacheEnum::CACHE_FOLDER . DIRECTORY_SEPARATOR . SphringCacheEnum::CACHE_FOLDER_ANNOTATIONS);
     $annotationsFolder->create();
     $reader = new CachedReader(new AnnotationReader(), new FilesystemCache($annotationsFolder->absolute()));
     $sphringBoot = $this->sphring->getSphringEventDispatcher()->getSphringBoot();
     $sphringBoot->getSphringAnnotationReader()->setReader($reader);
 }
 private function removeAnnotation()
 {
     if ($this->cacheManager->isCacheSphringAnnotation()) {
         return;
     }
     $annotationsFolder = new Folder(sys_get_temp_dir() . DIRECTORY_SEPARATOR . SphringCacheEnum::CACHE_FOLDER . DIRECTORY_SEPARATOR . SphringCacheEnum::CACHE_FOLDER_ANNOTATIONS);
     $annotationsFolder->removeFiles('#.*#i', true);
     $annotationsFolder->removeFolders('#.*#i', true);
     $annotationsFolder->remove();
 }
Exemplo n.º 4
0
 public function loadEntitiesByFolder($folderPath, $recursive = false, $namespace = null)
 {
     $folder = new Folder($folderPath, $recursive);
     $files = $folder->getFiles('/\\.php$/');
     foreach ($files as $file) {
         include_once $file->absolute();
         $entitieName = $file->getBase();
         $entitieName = $namespace . '\\' . $entitieName;
         $this->addEntitie(new $entitieName());
     }
     $this->load();
 }