plugin/exo/Serializer/StepSerializer.php
public function deserializeItems(Step $step, array $items = [], array $options = [])
    {
        $stepQuestions = $step->getStepQuestions()->toArray();

        foreach ($items as $index => $itemData) {
            $item = null;
            $stepQuestion = null;

            // Searches for an existing item entity.
            foreach ($stepQuestions as $entityIndex => $entityStepQuestion) {
                /** @var StepItem $entityStepQuestion */
                if ($entityStepQuestion->getQuestion()->getUuid() === $itemData['id']) {
                    $stepQuestion = $entityStepQuestion;
                    $item = $stepQuestion->getQuestion();
                    unset($stepQuestions[$entityIndex]);
                    break;
                }
            }

            $entity = $this->itemSerializer->deserialize($itemData, $item, $options);

            if (empty($stepQuestion)) {
                // Creation of a new item (we need to link it to the Step)
                $stepQuestion = $step->addQuestion($entity);
            } else {
                // Update order of the Item in the Step
                $stepQuestion->setOrder($index);
            }

            if (isset($itemData['meta']['mandatory'])) {
                $stepQuestion->setMandatory($itemData['meta']['mandatory']);
            }
        }

        // Remaining items are no longer in the Step
        if (0 < count($stepQuestions)) {
            foreach ($stepQuestions as $stepQuestionToRemove) {
                $step->removeStepQuestion($stepQuestionToRemove);
            }
        }
    }
public function deserializeItems(Step $step, array $items = [], array $options = [])
    {
        $stepQuestions = $step->getStepQuestions()->toArray();

        foreach ($items as $index => $itemData) {
            $item = null;
            $stepQuestion = null;

            // Searches for an existing item entity.
            foreach ($stepQuestions as $entityIndex => $entityStepQuestion) {
                /** @var StepItem $entityStepQuestion */
                if ($entityStepQuestion->getQuestion()->getUuid() === $itemData['id']) {
                    $stepQuestion = $entityStepQuestion;
                    $item = $stepQuestion->getQuestion();
                    unset($stepQuestions[$entityIndex]);
                    break;
                }
            }

            $entity = $this->itemSerializer->deserialize($itemData, $item, $options);

            if (empty($stepQuestion)) {
                // Creation of a new item (we need to link it to the Step)
                $stepQuestion = $step->addQuestion($entity);
            } else {
                // Update order of the Item in the Step
                $stepQuestion->setOrder($index);
            }

            if (isset($itemData['meta']['mandatory'])) {
                $stepQuestion->setMandatory($itemData['meta']['mandatory']);
            }
        }

        // Remaining items are no longer in the Step
        if (0 < count($stepQuestions)) {
            foreach ($stepQuestions as $stepQuestionToRemove) {
                $step->removeStepQuestion($stepQuestionToRemove);
            }
        }
    }
public function deserializeItems ( Step $ step , array $ items = [ ] , array $ options = [ ] ) { $ stepQuestions = $ step -> getStepQuestions ( ) -> toArray ( ) ; foreach ( $ items as $ index => $ itemData ) { $ item = null ; $ stepQuestion = null ; // Searches for an existing item entity. foreach ( $ stepQuestions as $ entityIndex => $ entityStepQuestion ) { /** @var StepItem $entityStepQuestion */ if ( $ entityStepQuestion -> getQuestion ( ) -> getUuid ( ) === $ itemData [ 'id' ] ) { $ stepQuestion = $ entityStepQuestion ; $ item = $ stepQuestion -> getQuestion ( ) ; unset ( $ stepQuestions [ $ entityIndex ] ) ; break ; } } $ entity = $ this -> itemSerializer -> deserialize ( $ itemData , $ item , $ options ) ; if ( empty ( $ stepQuestion ) ) { // Creation of a new item (we need to link it to the Step) $ stepQuestion = $ step -> addQuestion ( $ entity ) ; } else { // Update order of the Item in the Step $ stepQuestion -> setOrder ( $ index ) ; } if ( isset ( $ itemData [ 'meta' ] [ 'mandatory' ] ) ) { $ stepQuestion -> setMandatory ( $ itemData [ 'meta' ] [ 'mandatory' ] ) ; } } // Remaining items are no longer in the Step if ( 0 < count ( $ stepQuestions ) ) { foreach ( $ stepQuestions as $ stepQuestionToRemove ) { $ step -> removeStepQuestion ( $ stepQuestionToRemove ) ; } } }
Deserializes Step items.
Forwards the item deserialization to ItemSerializer.

@param Step  $step
@param array $items
@param array $options
Deserializes Step items . Forwards the item deserialization to ItemSerializer .