/**
  * @param PreFlushConfigEvent $event
  */
 public function preFlush(PreFlushConfigEvent $event)
 {
     $config = $event->getConfig('ownership');
     if (null === $config || $event->isFieldConfig()) {
         return;
     }
     $haveChanges = false;
     $ownerType = $config->get('owner_type');
     if ($ownerType === 'NONE') {
         $ownerType = null;
         $config->remove('owner_type');
         $haveChanges = true;
     }
     if ($ownerType && $this->isCustomEntity($config->getId()->getClassName(), $event->getConfigManager())) {
         if (!$config->has('owner_field_name')) {
             // update 'ownership' config for entity
             $config->set('owner_field_name', 'owner');
             $config->set('owner_column_name', 'owner_id');
             $haveChanges = true;
         }
         if (!$config->has('organization_field_name') && in_array($ownerType, [OwnershipType::OWNER_TYPE_USER, OwnershipType::OWNER_TYPE_BUSINESS_UNIT], true)) {
             // update organization config for entity
             $config->set('organization_field_name', 'organization');
             $config->set('organization_column_name', 'organization_id');
             $haveChanges = true;
         }
     }
     if ($haveChanges) {
         $configManager = $event->getConfigManager();
         $configManager->persist($config);
         $configManager->calculateConfigChangeSet($config);
     }
 }
 /**
  * @param PreFlushConfigEvent $event
  */
 public function preFlush(PreFlushConfigEvent $event)
 {
     if ($event->isFieldConfig()) {
         return;
     }
     $className = $event->getClassName();
     $configProvider = $event->getConfigManager()->getProvider('security');
     if ($configProvider->hasConfig($className)) {
         $this->provider->clearCache($configProvider->getConfig($className)->get('type'));
     }
 }
 /**
  * @param PreFlushConfigEvent $event
  */
 public function preFlush(PreFlushConfigEvent $event)
 {
     $config = $event->getConfig('email');
     if (null === $config || $event->isEntityConfig()) {
         return;
     }
     $changeSet = $event->getConfigManager()->getConfigChangeSet($config);
     if (isset($changeSet['available_in_template'])) {
         $this->cache->delete($this->cacheKey);
     }
 }
 /**
  * @dataProvider isEntityConfigDataProvider
  */
 public function testIsEntityConfig($configId, $expectedResult)
 {
     $config1 = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $config2 = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $configs = ['scope1' => $config1, 'scope2' => $config2];
     $configManager = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock();
     $event = new PreFlushConfigEvent($configs, $configManager);
     $config1->expects($this->once())->method('getId')->willReturn($configId);
     $config2->expects($this->never())->method('getId');
     $this->assertEquals($expectedResult, $event->isEntityConfig());
     // test that a local cache is used
     $this->assertEquals($expectedResult, $event->isEntityConfig());
 }
 /**
  * @param PreFlushConfigEvent $event
  */
 public function preFlush(PreFlushConfigEvent $event)
 {
     $config = $event->getConfig('extend');
     if (null === $config || $event->isFieldConfig()) {
         return;
     }
     $className = $config->getId()->getClassName();
     $this->provider->clearCache($className);
     $changeSet = $event->getConfigManager()->getConfigChangeSet($config);
     $isDeleted = isset($changeSet['state']) && $changeSet['state'][1] === ExtendScope::STATE_DELETE;
     if (!$isDeleted) {
         $this->provider->warmUpCache($className);
     }
 }
 /**
  * @param PreFlushConfigEvent $event
  */
 public function preFlush(PreFlushConfigEvent $event)
 {
     $config = $event->getConfig('extend');
     if (null === $config || $event->isEntityConfig()) {
         return;
     }
     $configManager = $event->getConfigManager();
     $changeSet = $configManager->getConfigChangeSet($config);
     // synchronize field state with entity state, when custom field state changed
     if (isset($changeSet['state']) && $changeSet['state'][1] !== ExtendScope::STATE_ACTIVE && $config->is('owner', ExtendScope::OWNER_CUSTOM)) {
         $entityConfig = $configManager->getEntityConfig('extend', $config->getId()->getClassName());
         if ($entityConfig->in('state', [ExtendScope::STATE_ACTIVE, ExtendScope::STATE_DELETE])) {
             $entityConfig->set('state', ExtendScope::STATE_UPDATE);
             $configManager->persist($entityConfig);
             $configManager->calculateConfigChangeSet($entityConfig);
         }
     }
 }
 /**
  * @param PreFlushConfigEvent $event
  */
 public function preFlush(PreFlushConfigEvent $event)
 {
     $config = $event->getConfig('search');
     if (null === $config) {
         return;
     }
     $configManager = $event->getConfigManager();
     $changeSet = $configManager->getConfigChangeSet($config);
     if (!isset($changeSet['searchable'])) {
         return;
     }
     $className = $config->getId()->getClassName();
     $extendConfig = $configManager->getProvider('extend')->getConfig($className);
     if ($extendConfig->get('state') === ExtendScope::STATE_ACTIVE) {
         $this->addReindexJob($className);
     } else {
         $this->addPostponeJob($className);
     }
 }