private function ensureInitialized()
 {
     if (!CommandExecutor::isCurrentCommand('oro:entity-extend:cache:', true)) {
         ExtendClassLoadingUtils::ensureDirExists(ExtendClassLoadingUtils::getEntityCacheDir($this->cacheDir));
         if (!file_exists(ExtendClassLoadingUtils::getAliasesPath($this->cacheDir))) {
             $this->initializeCache();
         }
         $this->ensureAliasesSet();
     }
 }
 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();
 }
Esempio n. 3
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 ensureInitialized()
 {
     $this->ensureDirExists(ExtendClassLoadingUtils::getEntityCacheDir($this->kernel->getCacheDir()));
     $this->ensureCacheInitialized();
     $this->ensureAliasesSet();
 }
Esempio n. 5
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();
 }
Esempio n. 6
0
 /**
  * @param string $cacheDir
  */
 public function __construct($cacheDir)
 {
     $this->cacheDir = $cacheDir;
     $this->entityCacheDir = ExtendClassLoadingUtils::getEntityCacheDir($cacheDir);
 }
Esempio n. 7
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();
         }
     }
 }