/** * Creates a new object state. * * @param $objectStateGroupId * * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException * * @return \eZ\Publish\Core\REST\Server\Values\CreatedObjectState */ public function createObjectState($objectStateGroupId, Request $request) { $objectStateGroup = $this->objectStateService->loadObjectStateGroup($objectStateGroupId); try { $createdObjectState = $this->objectStateService->createObjectState($objectStateGroup, $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()))); } catch (InvalidArgumentException $e) { throw new ForbiddenException($e->getMessage()); } return new Values\CreatedObjectState(array('objectState' => new RestObjectState($createdObjectState, $objectStateGroup->id))); }
/** * Creates a new object state in the given group. * * Note: in current kernel: If it is the first state all content objects will * set to this state. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create 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\ObjectStateGroup $objectStateGroup * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateCreateStruct $objectStateCreateStruct * * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectState */ public function createObjectState(ObjectStateGroup $objectStateGroup, ObjectStateCreateStruct $objectStateCreateStruct) { $returnValue = $this->service->createObjectState($objectStateGroup, $objectStateCreateStruct); $this->signalDispatcher->emit(new CreateObjectStateSignal(array('objectStateGroupId' => $objectStateGroup->id, 'objectStateId' => $returnValue->id))); return $returnValue; }