コード例 #1
0
 /**
  * @param array                $configs
  * @param LoggerInterface|null $logger
  * @param bool                 $dryRun Log modifications without apply them
  * @throws \Exception
  */
 public function processConfigs(array $configs, LoggerInterface $logger = null, $dryRun = false)
 {
     $this->logger = $logger ?: new NullLogger();
     try {
         if (!empty($configs)) {
             $this->appendConfigs = $this->getAndRemoveElement($configs, self::APPEND_CONFIGS, []);
             $renameConfigs = $this->getAndRemoveElement($configs, self::RENAME_CONFIGS, []);
             $this->filterConfigs($configs);
             $hasChanges = false;
             if (!empty($configs)) {
                 foreach ($configs as $className => $entityConfigs) {
                     $this->processEntityConfigs($className, $entityConfigs);
                 }
                 $hasChanges = true;
             }
             if ($this->renameFields($renameConfigs)) {
                 $hasChanges = true;
             }
             if ($hasChanges) {
                 if ($dryRun) {
                     $this->configManager->clear();
                 } else {
                     $this->configManager->flush();
                     $this->configManager->clearCache();
                 }
             }
         }
     } catch (\Exception $ex) {
         $this->logger = null;
         throw $ex;
     }
 }
コード例 #2
0
 /**
  * @inheritdoc
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $this->configManager->clearCache();
     $this->configManager->clearConfigurableCache();
     if ($schema instanceof ExtendSchema) {
         $queries->addQuery(new RefreshExtendCacheMigrationQuery($this->commandExecutor));
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $this->configManager->clearCache();
     $this->configManager->clearConfigurableCache();
     if ($schema instanceof ExtendSchema) {
         $queries->addQuery(new RefreshExtendConfigMigrationQuery($this->commandExecutor, $this->dataStorageExtension->get('initial_entity_config_state', []), $this->initialEntityConfigStatePath));
         $queries->addQuery(new RefreshExtendCacheMigrationQuery($this->commandExecutor));
     }
 }
コード例 #4
0
ファイル: ConfigLoader.php プロジェクト: xamin123/platform
 /**
  * Load entity configs from annotations to a database
  *
  * @param bool                 $force  Force overwrite config's option values
  * @param callable|null        $filter function (ClassMetadataInfo[] $doctrineAllMetadata)
  * @param LoggerInterface|null $logger
  * @param bool                 $dryRun Log modifications without apply them
  * @throws \Exception
  */
 public function load($force = false, \Closure $filter = null, LoggerInterface $logger = null, $dryRun = false)
 {
     $this->logger = $logger ?: new NullLogger();
     try {
         /** @var ClassMetadataInfo[] $doctrineAllMetadata */
         $doctrineAllMetadata = $this->configManager->getEntityManager()->getMetadataFactory()->getAllMetadata();
         if (null !== $filter) {
             $doctrineAllMetadata = $filter($doctrineAllMetadata);
         }
         foreach ($doctrineAllMetadata as $metadata) {
             $this->loadEntityConfigs($metadata, $force);
         }
         if ($dryRun) {
             $this->configManager->clear();
         } else {
             $this->configManager->flush();
             $this->configManager->clearCache();
             $this->configManager->clearConfigurableCache();
         }
     } catch (\Exception $ex) {
         $this->logger = null;
         throw $ex;
     }
 }
コード例 #5
0
 public function testClearCacheAll()
 {
     $this->configCache->expects($this->once())->method('deleteAllConfigs');
     $this->configManager->clearCache();
 }
コード例 #6
0
 /**
  * Removes configuration data for the given object (entity or field) from the cache.
  *
  * @param string      $className
  * @param string|null $fieldName
  */
 public function clearCache($className, $fieldName = null)
 {
     $this->configManager->clearCache($this->getId($className, $fieldName));
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     $this->configManager->clearCache();
     $this->configManager->clearConfigurableCache();
     $this->dumper->dump();
 }