/** * Create new section. * * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException * * @return \eZ\Publish\Core\REST\Server\Values\CreatedSection */ public function createSection(Request $request) { try { $createdSection = $this->sectionService->createSection($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\CreatedSection(array('section' => $createdSection)); }
public function processUpdate(FormActionEvent $event) { /** @var \EzSystems\RepositoryForms\Data\Section\SectionUpdateData|\EzSystems\RepositoryForms\Data\Section\SectionCreateData $sectionData */ $sectionData = $event->getData(); if ($sectionData->isNew()) { $section = $this->sectionService->createSection($sectionData); } else { $section = $this->sectionService->updateSection($sectionData->section, $sectionData); } $sectionData->setSection($section); }
/** * Creates the a new Section in the content repository. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user user is not allowed to create a section * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the new identifier in $sectionCreateStruct already exists * * @param \eZ\Publish\API\Repository\Values\Content\SectionCreateStruct $sectionCreateStruct * * @return \eZ\Publish\API\Repository\Values\Content\Section The newly create section */ public function createSection(SectionCreateStruct $sectionCreateStruct) { $returnValue = $this->service->createSection($sectionCreateStruct); $this->signalDispatcher->emit(new CreateSectionSignal(array('sectionId' => $returnValue->id))); return $returnValue; }