container = $container; } public function run(array $options) : ?string { $userId = $options['userId'] ?? null; $scope = $options['scope'] ?? null; $id = $options['id'] ?? null; $action = $options['action'] ?? null; if (empty($userId)) { return null; } if (empty($scope)) { return null; } if (empty($id)) { return null; } $container = $this->container; $entityManager = $container->get('entityManager'); $user = $entityManager->getEntity('User', $userId); if (!$user) { return null; } if ($user->isPortal()) { $portalIdList = $user->getLinkMultipleIdList('portals'); foreach ($portalIdList as $portalId) { $application = new PortalApplication($portalId); $containerPortal = $application->getContainer(); $entityManager = $containerPortal->get('entityManager'); $user = $entityManager->getEntity('User', $userId); if (!$user) { return null; } $result = $this->check($user, $scope, $id, $action, $containerPortal); if ($result) { return 'true'; } } return null; } if ($this->check($user, $scope, $id, $action, $container)) { return 'true'; } return null; } protected function check($user, $scope, $id, $action, $container) { $entityManager = $container->get('entityManager'); $entity = $entityManager->getEntity($scope, $id); if (!$entity) { return false; } $aclManager = $container->get('aclManager'); if ($aclManager->check($user, $entity, $action)) { return true; } return false; } }