container = $container; } public function run(Params $params, IO $io): void { $options = $params->getOptions(); $userId = $options['userId'] ?? null; $scope = $options['scope'] ?? null; $id = $options['id'] ?? null; $action = $options['action'] ?? null; if (empty($userId)) { return; } if (empty($scope)) { return; } if (empty($id)) { return; } $container = $this->container; $entityManager = $container->get('entityManager'); $user = $entityManager->getEntity('User', $userId); if (!$user) { return; } 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; } $result = $this->check($user, $scope, $id, $action, $containerPortal); if ($result) { $io->write('true');; return; } } return; } if ($this->check($user, $scope, $id, $action, $container)) { $io->write('true'); return; } } protected function check($user, $scope, $id, $action, $container): bool { $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; } }