/** * Creates a new content type group * * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException * @return \eZ\Publish\Core\REST\Server\Values\CreatedContentTypeGroup */ public function createContentTypeGroup(Request $request) { $createStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent())); try { return new Values\CreatedContentTypeGroup(array('contentTypeGroup' => $this->contentTypeService->createContentTypeGroup($createStruct))); } catch (InvalidArgumentException $e) { throw new ForbiddenException($e->getMessage()); } }
public function processUpdate(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\ContentTypeGroup\ContentTypeGroupUpdateData|\EzSystems\RepositoryForms\Data\ContentTypeGroup\ContentTypeGroupCreateData $data */ $data = $event->getData(); if ($data->isNew()) { $contentTypeGroup = $this->contentTypeService->createContentTypeGroup($data); } else { $this->contentTypeService->updateContentTypeGroup($data->contentTypeGroup, $data); $contentTypeGroup = $this->contentTypeService->loadContentTypeGroup($data->getId()); } $data->setContentTypeGroup($contentTypeGroup); }
/** * Create a Content Type Group object * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create a content type group * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If a group with the same identifier already exists * * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroupCreateStruct $contentTypeGroupCreateStruct * * @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup */ public function createContentTypeGroup(ContentTypeGroupCreateStruct $contentTypeGroupCreateStruct) { $returnValue = $this->service->createContentTypeGroup($contentTypeGroupCreateStruct); $this->signalDispatcher->emit(new CreateContentTypeGroupSignal(array('groupId' => $returnValue->id))); return $returnValue; }