/** * Load entity configs from annotations to a database * * @param bool $force Force overwrite config's option values * @param callable|null $filter function (ClassMetadata[] $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 { $entityManagers = $this->entityManagerBag->getEntityManagers(); foreach ($entityManagers as $em) { /** @var ClassMetadata[] $doctrineAllMetadata */ $doctrineAllMetadata = $em->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->flushAllCaches(); } } catch (\Exception $ex) { $this->logger = null; throw $ex; } }
/** * {@inheritdoc} */ public function up(Schema $schema, QueryBag $queries) { $this->configManager->flushAllCaches(); 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)); } }
/** * {@inheritdoc} */ public function warmUp($cacheDir) { $this->configManager->flushAllCaches(); $this->configCacheWarmer->warmUpCache(ConfigCacheWarmer::MODE_CONFIGURABLE_ENTITY_ONLY); $this->dumper->dump(); }