Esempio n. 1
0
 /**
  * @param EntityConfigEvent $event
  */
 public function updateEntity(EntityConfigEvent $event)
 {
     $className = $event->getClassName();
     $parentClassName = get_parent_class($className);
     if (!$parentClassName) {
         return;
     }
     if (ExtendHelper::isExtendEntityProxy($parentClassName)) {
         // When application is installed parent class will be replaced (via class_alias)
         $extendClass = $parentClassName;
     } else {
         // During install parent class is not replaced (via class_alias)
         $shortClassName = ExtendHelper::getShortClassName($className);
         if (ExtendHelper::getShortClassName($parentClassName) !== 'Extend' . $shortClassName) {
             return;
         }
         $extendClass = ExtendHelper::getExtendEntityProxyClassName($parentClassName);
     }
     $configManager = $event->getConfigManager();
     $config = $configManager->getProvider('extend')->getConfig($className);
     $hasChanges = false;
     if (!$config->is('is_extend')) {
         $config->set('is_extend', true);
         $hasChanges = true;
     }
     if (!$config->is('extend_class', $extendClass)) {
         $config->set('extend_class', $extendClass);
         $hasChanges = true;
     }
     if ($hasChanges) {
         $configManager->persist($config);
     }
 }
Esempio n. 2
0
 /**
  * @param EntityConfigEvent $event
  */
 public function updateEntityConfig(EntityConfigEvent $event)
 {
     $parentClassName = get_parent_class($event->getClassName());
     if (!$parentClassName) {
         return;
     }
     $shortClassName = ExtendHelper::getShortClassName($event->getClassName());
     if (ExtendHelper::getShortClassName($parentClassName) !== 'Extend' . $shortClassName) {
         return;
     }
     $config = $event->getConfigManager()->getProvider('extend')->getConfig($event->getClassName());
     $hasChanges = false;
     if (!$config->is('is_extend')) {
         $config->set('is_extend', true);
         $hasChanges = true;
     }
     $extendClass = ExtendHelper::getExtendEntityProxyClassName($parentClassName);
     if (!$config->is('extend_class', $extendClass)) {
         $config->set('extend_class', $extendClass);
         $hasChanges = true;
     }
     if ($hasChanges) {
         $event->getConfigManager()->persist($config);
     }
 }
Esempio n. 3
0
 public function testEvent()
 {
     $configManager = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock();
     $event = new EntityConfigEvent('Test\\Class', $configManager);
     $this->assertEquals('Test\\Class', $event->getClassName());
     $this->assertSame($configManager, $event->getConfigManager());
 }
Esempio n. 4
0
 /**
  * @param EntityConfigEvent $event
  */
 public function newEntityConfig(EntityConfigEvent $event)
 {
     // clear cache when new entity added to configurator
     // in case if default value for some fields will equal true
     $cp = $event->getConfigManager()->getProvider('email');
     $fieldConfigs = $cp->filter(function (ConfigInterface $config) {
         return $config->is('available_in_template');
     }, $event->getClassName());
     if (count($fieldConfigs)) {
         $this->cache->delete($this->cacheKey);
     }
 }