/** * {@inheritdoc} */ protected function executeAction($context) { $aclClass = $this->manager->getRepository('OroSecurityBundle:AclClass')->findOneBy(['classType' => $context->data->getClassName()]); $removeScopes = array_diff($context->old['security']['share_scopes'], $context->new['security']['share_scopes']); if (!$aclClass || empty($removeScopes)) { return; } $qb = $this->qbManager->getRemoveAceQueryBuilder($aclClass, $removeScopes); $qb->getQuery()->execute(); $this->aclCache->clearCache(); }
/** * 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(); } } }