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)); } /** @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(); } }