plugin/exo/Controller/Api/Item/ItemController.php
public function updateAction(Item $question, Request $request)
    {
        $errors = [];

        $data = $this->decodeRequestData($request);
        if (empty($data)) {
            // Invalid or empty JSON data received
            $errors[] = [
                'path' => '',
                'message' => 'Invalid JSON data',
            ];
        } else {
            // Try to update question with data
            try {
                $question = $this->manager->update($question, $data);
            } catch (InvalidDataException $e) {
                $errors = $e->getErrors();
            }
        }

        if (empty($errors)) {
            // Item updated
            return new JsonResponse(
                $this->manager->serialize($question, [Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META])
            );
        } else {
            // Invalid data received
            return new JsonResponse($errors, 422);
        }
    }
public function updateAction(Item $question, Request $request)
    {
        $errors = [];

        $data = $this->decodeRequestData($request);
        if (empty($data)) {
            // Invalid or empty JSON data received
            $errors[] = [
                'path' => '',
                'message' => 'Invalid JSON data',
            ];
        } else {
            // Try to update question with data
            try {
                $question = $this->manager->update($question, $data);
            } catch (InvalidDataException $e) {
                $errors = $e->getErrors();
            }
        }

        if (empty($errors)) {
            // Item updated
            return new JsonResponse(
                $this->manager->serialize($question, [Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META])
            );
        } else {
            // Invalid data received
            return new JsonResponse($errors, 422);
        }
    }
public function updateAction ( Item $ question , Request $ request ) { $ errors = [ ] ; $ data = $ this -> decodeRequestData ( $ request ) ; if ( empty ( $ data ) ) { // Invalid or empty JSON data received $ errors [ ] = [ 'path' => '' , 'message' => 'Invalid JSON data' , ] ; } else { // Try to update question with data try { $ question = $ this -> manager -> update ( $ question , $ data ) ; } catch ( InvalidDataException $ e ) { $ errors = $ e -> getErrors ( ) ; } } if ( empty ( $ errors ) ) { // Item updated return new JsonResponse ( $ this -> manager -> serialize ( $ question , [ Transfer :: INCLUDE_SOLUTIONS , Transfer :: INCLUDE_ADMIN_META ] ) ) ; } else { // Invalid data received return new JsonResponse ( $ errors , 422 ) ; } }
Updates a Item.

@EXT\Route("/{id}", name="question_update")
@EXT\Method("PUT")
@EXT\ParamConverter("question", class="UJMExoBundle:Item\Item", options={"mapping": {"id": "uuid"}})

@param Item    $question
@param Request $request

@return JsonResponse
Updates a Item .