/** * Updates an object state. * * @param $objectStateGroupId * @param $objectStateId * * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException * * @return \eZ\Publish\Core\REST\Common\Values\RestObjectState */ public function updateObjectState($objectStateGroupId, $objectStateId, Request $request) { $updateStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent())); $objectState = $this->objectStateService->loadObjectState($objectStateId); try { $updatedObjectState = $this->objectStateService->updateObjectState($objectState, $updateStruct); return new RestObjectState($updatedObjectState, $objectStateGroupId); } catch (InvalidArgumentException $e) { throw new ForbiddenException($e->getMessage()); } }
/** * Updates an object state. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update an object state * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the object state with provided identifier already exists in the same group * * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateUpdateStruct $objectStateUpdateStruct * * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectState */ public function updateObjectState(ObjectState $objectState, ObjectStateUpdateStruct $objectStateUpdateStruct) { $returnValue = $this->service->updateObjectState($objectState, $objectStateUpdateStruct); $this->signalDispatcher->emit(new UpdateObjectStateSignal(array('objectStateId' => $objectState->id))); return $returnValue; }