Пример #1
0
 /**
  * Generates extended entities
  *
  * @param array $schemas
  */
 public function generate(array $schemas)
 {
     $aliases = [];
     foreach ($schemas as $schema) {
         $this->generateSchemaFiles($schema);
         if ($schema['type'] == 'Extend') {
             $aliases[$schema['entity']] = $schema['parent'];
         }
     }
     // write PHP class aliases to the file
     file_put_contents(ExtendClassLoadingUtils::getAliasesPath($this->cacheDir), serialize($aliases));
 }
 public function clear()
 {
     $filesystem = new Filesystem();
     $baseCacheDir = ExtendClassLoadingUtils::getEntityBaseCacheDir($this->cacheDir);
     if ($filesystem->exists($baseCacheDir)) {
         $filesystem->remove([$baseCacheDir]);
     }
     $filesystem->mkdir(ExtendClassLoadingUtils::getEntityCacheDir($this->cacheDir));
     /** @var ExtendClassMetadataFactory $metadataFactory */
     $metadataFactory = $this->em->getMetadataFactory();
     $metadataFactory->clearCache();
 }
Пример #3
0
 /**
  * Generates extended entities
  *
  * @param array $config
  */
 public function generate(array $config)
 {
     $aliases = array();
     foreach ($config as $item) {
         $this->generateYaml($item);
         $this->generateClass($item);
         if ($item['type'] == 'Extend') {
             $aliases[$item['entity']] = $item['parent'];
         }
     }
     file_put_contents(ExtendClassLoadingUtils::getAliasesPath($this->cacheDir), Yaml::dump($aliases));
 }
Пример #4
0
 /**
  * Removes the entity proxies and metadata from the cache
  *
  * @param bool $keepEntityProxies Set TRUE if proxies for custom and extend entities should not be deleted
  */
 public function clear($keepEntityProxies = false)
 {
     $filesystem = new Filesystem();
     if ($keepEntityProxies) {
         $aliasesPath = ExtendClassLoadingUtils::getAliasesPath($this->cacheDir);
         if ($filesystem->exists($aliasesPath)) {
             $filesystem->remove($aliasesPath);
         }
     } else {
         $baseCacheDir = ExtendClassLoadingUtils::getEntityBaseCacheDir($this->cacheDir);
         if ($filesystem->exists($baseCacheDir)) {
             $filesystem->remove([$baseCacheDir]);
         }
         $filesystem->mkdir(ExtendClassLoadingUtils::getEntityCacheDir($this->cacheDir));
     }
     $metadataCacheDriver = $this->em->getMetadataFactory()->getCacheDriver();
     if ($metadataCacheDriver instanceof ClearableCache) {
         $metadataCacheDriver->deleteAll();
     }
 }
 private function ensureAliasesSet()
 {
     if (!$this->isCommandExecuting('oro:entity-extend:update-config')) {
         ExtendClassLoadingUtils::setAliases($this->kernel->getCacheDir());
     }
 }
Пример #6
0
 /**
  * Removes the entity proxies and metadata from the cache
  *
  * @param bool $keepEntityProxies Set TRUE if proxies for custom and extend entities should not be deleted
  */
 public function clear($keepEntityProxies = false)
 {
     $filesystem = new Filesystem();
     if ($keepEntityProxies) {
         $aliasesPath = ExtendClassLoadingUtils::getAliasesPath($this->cacheDir);
         if ($filesystem->exists($aliasesPath)) {
             $filesystem->remove($aliasesPath);
         }
     } else {
         $baseCacheDir = ExtendClassLoadingUtils::getEntityBaseCacheDir($this->cacheDir);
         if ($filesystem->exists($baseCacheDir)) {
             $filesystem->remove([$baseCacheDir]);
         }
         $filesystem->mkdir(ExtendClassLoadingUtils::getEntityCacheDir($this->cacheDir));
     }
     /** @var ExtendClassMetadataFactory $metadataFactory */
     $metadataFactory = $this->em->getMetadataFactory();
     $metadataFactory->clearCache();
 }
Пример #7
0
 /**
  * Sets class aliases for extended entities.
  *
  * @param string $cacheDir The cache directory
  *
  * @throws \ReflectionException
  */
 protected function setClassAliases($cacheDir)
 {
     $aliases = ExtendClassLoadingUtils::getAliases($cacheDir);
     foreach ($aliases as $className => $alias) {
         if (class_exists($className)) {
             if (class_exists($alias, false)) {
                 /*throw new \ReflectionException(
                       sprintf(
                           'The alias "%1$s" for the class "%2$s" cannot be registered '
                           . 'because the class "%1$s" is already loaded. '
                           . 'This may happen if this class or a derived class '
                           . 'is used in EntityConfigDumperExtension or EntityGeneratorExtension.',
                           $alias,
                           $className
                       )
                   );*/
             } else {
                 class_alias($className, $alias);
             }
         }
     }
 }
 private function ensureAliasesSet()
 {
     if (!CommandExecutor::isCurrentCommand('oro:entity-extend:update-config')) {
         ExtendClassLoadingUtils::setAliases($this->cacheDir);
     }
 }
Пример #9
0
 /**
  * Removes the entity proxies and metadata from the cache
  *
  * @param bool $keepEntityProxies Set TRUE if proxies for custom and extend entities should not be deleted
  */
 public function clear($keepEntityProxies = false)
 {
     $filesystem = new Filesystem();
     if ($keepEntityProxies) {
         $aliasesPath = ExtendClassLoadingUtils::getAliasesPath($this->cacheDir);
         if ($filesystem->exists($aliasesPath)) {
             $filesystem->remove($aliasesPath);
         }
     } else {
         $baseCacheDir = ExtendClassLoadingUtils::getEntityBaseCacheDir($this->cacheDir);
         if ($filesystem->exists($baseCacheDir)) {
             $filesystem->remove([$baseCacheDir]);
         }
         $filesystem->mkdir(ExtendClassLoadingUtils::getEntityCacheDir($this->cacheDir));
     }
     foreach ($this->entityManagerBag->getEntityManagers() as $em) {
         /** @var ClassMetadataFactory $metadataFactory */
         $metadataFactory = $em->getMetadataFactory();
         $metadataCache = $metadataFactory->getCacheDriver();
         if ($metadataCache instanceof ClearableCache) {
             $metadataCache->deleteAll();
         }
     }
 }