public function testEvent()
 {
     $models = [new EntityConfigModel()];
     $configManager = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock();
     $event = new PostFlushConfigEvent($models, $configManager);
     $this->assertEquals($models, $event->getModels());
     $this->assertSame($configManager, $event->getConfigManager());
 }
示例#2
0
 /**
  * Deletes tags relations for $className in cases when "tagging" option has been disabled for it.
  *
  * @param PostFlushConfigEvent $event
  */
 public function postFlush(PostFlushConfigEvent $event)
 {
     foreach ($event->getModels() as $model) {
         if ($model instanceof EntityConfigModel) {
             $configManager = $event->getConfigManager();
             $className = $model->getClassName();
             $changeSet = $configManager->getConfigChangeSet($configManager->getProvider('tag')->getConfig($className));
             if (isset($changeSet['enabled']) && $changeSet['enabled'][0] && !$changeSet['enabled'][1]) {
                 $this->tagManager->deleteRelations($className);
             }
         }
     }
 }
示例#3
0
 /**
  * Removes ACEs if share scope was removed from entity config
  *
  * @param PostFlushConfigEvent $event
  */
 public function postFlushConfig(PostFlushConfigEvent $event)
 {
     $configManager = $event->getConfigManager();
     foreach ($event->getModels() as $model) {
         /** @var EntityConfigModel $model */
         if ($model instanceof EntityConfigModel) {
             $aclClass = $this->registry->getRepository('OroSecurityBundle:AclClass')->findOneBy(['classType' => $model->getClassName()]);
             if (!$aclClass) {
                 continue;
             }
             $changeSet = $configManager->getConfigChangeSet($configManager->getProvider('security')->getConfig($model->getClassName()));
             $removeScopes = [];
             if ($changeSet) {
                 $removeScopes = array_diff($changeSet['share_scopes'][0], $changeSet['share_scopes'][1]);
             }
             if (empty($removeScopes)) {
                 continue;
             }
             $qb = $this->qbManager->getRemoveAceQueryBuilder($aclClass, $removeScopes);
             $qb->getQuery()->execute();
             $this->aclCache->clearCache();
         }
     }
 }