plugin/exo/Manager/ExerciseManager.php
public function update(Exercise $exercise, array $data)
    {
        // Validate received data
        $errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]);

        if (count($errors) > 0) {
            throw new InvalidDataException('Exercise is not valid', $errors);
        }
        // Start flush suite to avoid persisting and flushing tags before quiz
        $this->om->startFlushSuite();
        // Update Exercise with new data
        $this->serializer->deserialize($data, $exercise, [Transfer::PERSIST_TAG]);

        // Save to DB
        $this->om->persist($exercise);
        $this->om->endFlushSuite();

        // Invalidate unfinished papers
        $this->repository->invalidatePapers($exercise);

        // Log exercise update
        $event = new LogExerciseUpdateEvent($exercise, (array) $this->serializer->serialize($exercise));
        $this->eventDispatcher->dispatch('log', $event);

        return $exercise;
    }
public function update(Exercise $exercise, array $data)
    {
        // Validate received data
        $errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]);

        if (count($errors) > 0) {
            throw new InvalidDataException('Exercise is not valid', $errors);
        }
        // Start flush suite to avoid persisting and flushing tags before quiz
        $this->om->startFlushSuite();
        // Update Exercise with new data
        $this->serializer->deserialize($data, $exercise, [Transfer::PERSIST_TAG]);

        // Save to DB
        $this->om->persist($exercise);
        $this->om->endFlushSuite();

        // Invalidate unfinished papers
        $this->repository->invalidatePapers($exercise);

        // Log exercise update
        $event = new LogExerciseUpdateEvent($exercise, (array) $this->serializer->serialize($exercise));
        $this->eventDispatcher->dispatch('log', $event);

        return $exercise;
    }
public function update ( Exercise $ exercise , array $ data ) { // Validate received data $ errors = $ this -> validator -> validate ( $ data , [ Validation :: REQUIRE_SOLUTIONS ] ) ; if ( count ( $ errors ) > 0 ) { throw new InvalidDataException ( 'Exercise is not valid' , $ errors ) ; } // Start flush suite to avoid persisting and flushing tags before quiz $ this -> om -> startFlushSuite ( ) ; // Update Exercise with new data $ this -> serializer -> deserialize ( $ data , $ exercise , [ Transfer :: PERSIST_TAG ] ) ; // Save to DB $ this -> om -> persist ( $ exercise ) ; $ this -> om -> endFlushSuite ( ) ; // Invalidate unfinished papers $ this -> repository -> invalidatePapers ( $ exercise ) ; // Log exercise update $ event = new LogExerciseUpdateEvent ( $ exercise , ( array ) $ this -> serializer -> serialize ( $ exercise ) ) ; $ this -> eventDispatcher -> dispatch ( 'log' , $ event ) ; return $ exercise ; }
Validates and updates an Exercise entity with raw data.

@param Exercise $exercise
@param array    $data

@return Exercise

@throws InvalidDataException
Validates and updates an Exercise entity with raw data .