public function updateAction(Exercise $exercise, Request $request)
    {
        $this->assertHasPermission('EDIT', $exercise);

        $errors = [];

        $data = $this->decodeRequestData($request);

        if (null === $data) {
            $errors[] = [
                'path' => '',
                'message' => 'Invalid JSON data',
            ];
        } else {
            // Try to update exercise
            try {
                $this->exerciseManager->update($exercise, $data);
            } catch (InvalidDataException $e) {
                $errors = $e->getErrors();
            }
        }

        if (!empty($errors)) {
            // Invalid data received
            return new JsonResponse($errors, 422);
        }

        // Exercise updated
        return new JsonResponse(
            $this->exerciseManager->serialize($exercise, [Transfer::INCLUDE_SOLUTIONS])
        );
    }
public function updateAction(Exercise $exercise, Request $request)
    {
        $this->assertHasPermission('EDIT', $exercise);

        $errors = [];

        $data = $this->decodeRequestData($request);

        if (null === $data) {
            $errors[] = [
                'path' => '',
                'message' => 'Invalid JSON data',
            ];
        } else {
            // Try to update exercise
            try {
                $this->exerciseManager->update($exercise, $data);
            } catch (InvalidDataException $e) {
                $errors = $e->getErrors();
            }
        }

        if (!empty($errors)) {
            // Invalid data received
            return new JsonResponse($errors, 422);
        }

        // Exercise updated
        return new JsonResponse(
            $this->exerciseManager->serialize($exercise, [Transfer::INCLUDE_SOLUTIONS])
        );
    }
public function updateAction ( Exercise $ exercise , Request $ request ) { $ this -> assertHasPermission ( 'EDIT' , $ exercise ) ; $ errors = [ ] ; $ data = $ this -> decodeRequestData ( $ request ) ; if ( null === $ data ) { $ errors [ ] = [ 'path' => '' , 'message' => 'Invalid JSON data' , ] ; } else { // Try to update exercise try { $ this -> exerciseManager -> update ( $ exercise , $ data ) ; } catch ( InvalidDataException $ e ) { $ errors = $ e -> getErrors ( ) ; } } if ( ! empty ( $ errors ) ) { // Invalid data received return new JsonResponse ( $ errors , 422 ) ; } // Exercise updated return new JsonResponse ( $ this -> exerciseManager -> serialize ( $ exercise , [ Transfer :: INCLUDE_SOLUTIONS ] ) ) ; }
Updates an Exercise.

@EXT\Route("/{id}", name="exercise_update")
@EXT\ParamConverter("exercise", class="UJMExoBundle:Exercise", options={"mapping": {"id": "uuid"}})
@EXT\Method("PUT")

@param Exercise $exercise
@param Request  $request

@return JsonResponse
Updates an Exercise .