plugin/lesson/Controller/API/ChapterController.php
public function deleteAction(Request $request, Lesson $lesson, Chapter $chapter)
    {
        $previousChapter = $this->chapterRepository->getPreviousChapter($chapter);
        $previousSlug = $previousChapter ? $previousChapter->getSlug() : null;

        $this->checkPermission('EDIT', $lesson->getResourceNode(), [], true);

        $payload = json_decode($request->getContent(), true);
        $deleteChildren = $payload['deleteChildren'];

        $this->chapterManager->deleteChapter($lesson, $chapter, $deleteChildren);

        return new JsonResponse([
            'tree' => $this->chapterManager->serializeChapterTree($lesson),
            'slug' => $previousSlug,
        ]);
    }
public function deleteAction(Request $request, Lesson $lesson, Chapter $chapter)
    {
        $previousChapter = $this->chapterRepository->getPreviousChapter($chapter);
        $previousSlug = $previousChapter ? $previousChapter->getSlug() : null;

        $this->checkPermission('EDIT', $lesson->getResourceNode(), [], true);

        $payload = json_decode($request->getContent(), true);
        $deleteChildren = $payload['deleteChildren'];

        $this->chapterManager->deleteChapter($lesson, $chapter, $deleteChildren);

        return new JsonResponse([
            'tree' => $this->chapterManager->serializeChapterTree($lesson),
            'slug' => $previousSlug,
        ]);
    }
public function deleteAction ( Request $ request , Lesson $ lesson , Chapter $ chapter ) { $ previousChapter = $ this -> chapterRepository -> getPreviousChapter ( $ chapter ) ; $ previousSlug = $ previousChapter ? $ previousChapter -> getSlug ( ) : null ; $ this -> checkPermission ( 'EDIT' , $ lesson -> getResourceNode ( ) , [ ] , true ) ; $ payload = json_decode ( $ request -> getContent ( ) , true ) ; $ deleteChildren = $ payload [ 'deleteChildren' ] ; $ this -> chapterManager -> deleteChapter ( $ lesson , $ chapter , $ deleteChildren ) ; return new JsonResponse ( [ 'tree' => $ this -> chapterManager -> serializeChapterTree ( $ lesson ) , 'slug' => $ previousSlug , ] ) ; }
Delete existing chapter.

@EXT\Route("/chapters/{chapterSlug}/delete", name="apiv2_lesson_chapter_delete")
@EXT\Method("DELETE")
@EXT\ParamConverter("chapter", class="IcapLessonBundle:Chapter", options={"mapping": {"chapterSlug": "slug"}})

@param Request $request
@param Lesson  $lesson
@param Chapter $chapter

@return JsonResponse
Delete existing chapter .