/** * Deletes a section. * * @param mixed $sectionId * * @return \Symfony\Component\HttpFoundation\Response */ public function deleteAction(Request $request, $sectionId, $redirectErrorsTo = 'list') { $section = $this->sectionService->loadSection($sectionId); $deleteForm = $this->createForm(new SectionDeleteType($this->sectionService), ['sectionId' => $sectionId]); $deleteForm->handleRequest($request); if ($deleteForm->isValid()) { $this->sectionService->deleteSection($section); $this->notify('section.deleted', ['%sectionName%' => $section->name], 'section'); return $this->redirectToRouteAfterFormPost('admin_sectionlist'); } // Form validation failed. Send errors as notifications. foreach ($deleteForm->getErrors(true) as $error) { $this->notifyErrorPlural($error->getMessageTemplate(), $error->getMessagePluralization(), $error->getMessageParameters(), 'ezrepoforms_section'); } return $this->redirectToRouteAfterFormPost("admin_section{$redirectErrorsTo}", ['sectionId' => $sectionId]); }
/** * Deletes $section from content repository. * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified section is not found * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user user is not allowed to delete a section * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if section can not be deleted * because it is still assigned to some contents. * * @param \eZ\Publish\API\Repository\Values\Content\Section $section */ public function deleteSection(Section $section) { $returnValue = $this->service->deleteSection($section); $this->signalDispatcher->emit(new DeleteSectionSignal(array('sectionId' => $section->id))); return $returnValue; }
/** * Delete a section by ID. * * @param $sectionId * * @return \eZ\Publish\Core\REST\Server\Values\NoContent */ public function deleteSection($sectionId) { $this->sectionService->deleteSection($this->sectionService->loadSection($sectionId)); return new NoContent(); }