/** * @param $id * @return ExecutionResult */ public function execute($id) { if (!$this->access->isPermitted($id)) { return new NotPermittedResult(); } try { $action = $this->actions->getAction($id); list($params, $missing) = $this->readParameters($action); if (!empty($missing)) { return new MissingParametersResult($missing); } if (!$this->access->isExecutionPermitted($id, $params)) { return new NotPermittedResult(); } $returned = $action->execute($params); if (is_null($returned)) { return new NoResult(); } else { if ($returned instanceof ExecutionResult) { return $returned; } else { return new ValueResult($returned); } } } catch (\Exception $e) { return new FailedResult($e); } }
private function assembleActions() { $actions = []; foreach ($this->actions->getAllActions() as $id => $action) { if ($id != WebApplication::INDEX_ACTION && $this->access->isPermitted($id)) { $actions[] = new ActionListItem($id, $action->caption(), $this->parser->shorten($action->description())); } } return $actions; }
private function givenExeutionOf_With_IsNotPermitted($action, $params) { $this->access->add((new GenericAccessRestriction($action))->denyExecutionWith($params)); }