Пример #1
0
 /**
  * @dataProvider isFieldConfigDataProvider
  */
 public function testIsFieldConfig($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->isFieldConfig());
     // test that a local cache is used
     $this->assertEquals($expectedResult, $event->isFieldConfig());
 }
Пример #2
0
 /**
  * @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'));
     }
 }
Пример #4
0
 /**
  * @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);
     }
 }