Пример #1
0
 public function testEvent()
 {
     $configManager = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock();
     $event = new RenameFieldEvent('Test\\Class', 'testField', 'newField', $configManager);
     $this->assertEquals('Test\\Class', $event->getClassName());
     $this->assertEquals('testField', $event->getFieldName());
     $this->assertEquals('newField', $event->getNewFieldName());
     $this->assertSame($configManager, $event->getConfigManager());
 }
Пример #2
0
 /**
  * @param RenameFieldEvent $event
  */
 public function renameField(RenameFieldEvent $event)
 {
     $configManager = $event->getConfigManager();
     $entityConfig = $configManager->getProvider('extend')->getConfig($event->getClassName());
     if ($entityConfig->has('index')) {
         $index = $entityConfig->get('index');
         if (isset($index[$event->getFieldName()])) {
             $index[$event->getNewFieldName()] = $index[$event->getFieldName()];
             unset($index[$event->getFieldName()]);
             $entityConfig->set('index', $index);
             $configManager->persist($entityConfig);
         }
     }
 }