/**
  * @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('email');
     if (null === $config || $event->isEntityConfig()) {
         return;
     }
     $changeSet = $event->getConfigManager()->getConfigChangeSet($config);
     if (isset($changeSet['available_in_template'])) {
         $this->cache->delete($this->cacheKey);
     }
 }
示例#3
0
 /**
  * @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);
         }
     }
 }