plugin/exo/Serializer/Item/ItemSerializer.php
private function deserializeHints(Item $question, array $hints = [], array $options = [])
    {
        $hintEntities = $question->getHints()->toArray();

        foreach ($hints as $hintData) {
            $existingHint = null;

            // Searches for an existing hint entity.
            foreach ($hintEntities as $entityIndex => $entityHint) {
                /** @var Hint $entityHint */
                if ($entityHint->getUuid() === $hintData['id']) {
                    $existingHint = $entityHint;
                    unset($hintEntities[$entityIndex]);
                    break;
                }
            }

            $entity = $this->hintSerializer->deserialize($hintData, $existingHint, $options);

            if (empty($existingHint)) {
                // Creation of a new hint (we need to link it to the question)
                $question->addHint($entity);
            }
        }

        // Remaining hints are no longer in the Exercise
        if (0 < count($hintEntities)) {
            foreach ($hintEntities as $hintToRemove) {
                $question->removeHint($hintToRemove);
            }
        }
    }
private function deserializeHints(Item $question, array $hints = [], array $options = [])
    {
        $hintEntities = $question->getHints()->toArray();

        foreach ($hints as $hintData) {
            $existingHint = null;

            // Searches for an existing hint entity.
            foreach ($hintEntities as $entityIndex => $entityHint) {
                /** @var Hint $entityHint */
                if ($entityHint->getUuid() === $hintData['id']) {
                    $existingHint = $entityHint;
                    unset($hintEntities[$entityIndex]);
                    break;
                }
            }

            $entity = $this->hintSerializer->deserialize($hintData, $existingHint, $options);

            if (empty($existingHint)) {
                // Creation of a new hint (we need to link it to the question)
                $question->addHint($entity);
            }
        }

        // Remaining hints are no longer in the Exercise
        if (0 < count($hintEntities)) {
            foreach ($hintEntities as $hintToRemove) {
                $question->removeHint($hintToRemove);
            }
        }
    }
private function deserializeHints ( Item $ question , array $ hints = [ ] , array $ options = [ ] ) { $ hintEntities = $ question -> getHints ( ) -> toArray ( ) ; foreach ( $ hints as $ hintData ) { $ existingHint = null ; // Searches for an existing hint entity. foreach ( $ hintEntities as $ entityIndex => $ entityHint ) { /** @var Hint $entityHint */ if ( $ entityHint -> getUuid ( ) === $ hintData [ 'id' ] ) { $ existingHint = $ entityHint ; unset ( $ hintEntities [ $ entityIndex ] ) ; break ; } } $ entity = $ this -> hintSerializer -> deserialize ( $ hintData , $ existingHint , $ options ) ; if ( empty ( $ existingHint ) ) { // Creation of a new hint (we need to link it to the question) $ question -> addHint ( $ entity ) ; } } // Remaining hints are no longer in the Exercise if ( 0 < count ( $ hintEntities ) ) { foreach ( $ hintEntities as $ hintToRemove ) { $ question -> removeHint ( $ hintToRemove ) ; } } }
Deserializes Item hints.
Forwards the hint deserialization to HintSerializer.

@param Item  $question
@param array $hints
@param array $options
Deserializes Item hints . Forwards the hint deserialization to HintSerializer .