factory = $factory; $this->acl = $acl; $this->recordServiceContainer = $recordServiceContainer; } /** * Perform an action. * * @throws Forbidden * @throws BadRequest * @throws NotFound */ public function process(string $entityType, string $action, string $id, stdClass $data): Entity { if (!$this->acl->checkScope($entityType)) { throw new ForbiddenSilent(); } if (!$action || !$id) { throw new BadRequest(); } $actionParams = new Params($entityType, $id); $actionProcessor = $this->factory->create($action, $entityType); $actionProcessor->process( $actionParams, Data::fromRaw($data) ); $service = $this->recordServiceContainer->get($entityType); $entity = $service->read($id, ReadParams::create()); return $entity; } }