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(); }
/** * 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(); }
/** * 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(); }
/** * @param string $cacheDir */ public function __construct($cacheDir) { $this->cacheDir = $cacheDir; $this->entityCacheDir = ExtendClassLoadingUtils::getEntityCacheDir($cacheDir); }
/** * 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(); } } }