private function deserializeAreas(GraphicQuestion $graphicQuestion, array $solutions)
    {
        $areaEntities = $graphicQuestion->getAreas()->toArray();

        foreach ($solutions as $solutionData) {
            $area = null;

            // Searches for an existing area entity.
            foreach ($areaEntities as $entityIndex => $entityArea) {
                /** @var Area $entityArea */
                if ($entityArea->getUuid() === $solutionData['area']['id']) {
                    $area = $entityArea;
                    unset($areaEntities[$entityIndex]);
                    break;
                }
            }

            $area = $area ?: new Area();
            $area->setUuid($solutionData['area']['id']);
            $area->setScore($solutionData['score']);

            if (!empty($solutionData['feedback'])) {
                $area->setFeedback($solutionData['feedback']);
            }

            // Deserializes area definition
            $this->deserializeArea($area, $solutionData['area']);

            $graphicQuestion->addArea($area);
        }

        // Remaining areas are no longer in the question
        foreach ($areaEntities as $areaToRemove) {
            $graphicQuestion->removeArea($areaToRemove);
        }
    }
private function deserializeAreas(GraphicQuestion $graphicQuestion, array $solutions)
    {
        $areaEntities = $graphicQuestion->getAreas()->toArray();

        foreach ($solutions as $solutionData) {
            $area = null;

            // Searches for an existing area entity.
            foreach ($areaEntities as $entityIndex => $entityArea) {
                /** @var Area $entityArea */
                if ($entityArea->getUuid() === $solutionData['area']['id']) {
                    $area = $entityArea;
                    unset($areaEntities[$entityIndex]);
                    break;
                }
            }

            $area = $area ?: new Area();
            $area->setUuid($solutionData['area']['id']);
            $area->setScore($solutionData['score']);

            if (!empty($solutionData['feedback'])) {
                $area->setFeedback($solutionData['feedback']);
            }

            // Deserializes area definition
            $this->deserializeArea($area, $solutionData['area']);

            $graphicQuestion->addArea($area);
        }

        // Remaining areas are no longer in the question
        foreach ($areaEntities as $areaToRemove) {
            $graphicQuestion->removeArea($areaToRemove);
        }
    }
private function deserializeAreas ( GraphicQuestion $ graphicQuestion , array $ solutions ) { $ areaEntities = $ graphicQuestion -> getAreas ( ) -> toArray ( ) ; foreach ( $ solutions as $ solutionData ) { $ area = null ; // Searches for an existing area entity. foreach ( $ areaEntities as $ entityIndex => $ entityArea ) { /** @var Area $entityArea */ if ( $ entityArea -> getUuid ( ) === $ solutionData [ 'area' ] [ 'id' ] ) { $ area = $ entityArea ; unset ( $ areaEntities [ $ entityIndex ] ) ; break ; } } $ area = $ area ? : new Area ( ) ; $ area -> setUuid ( $ solutionData [ 'area' ] [ 'id' ] ) ; $ area -> setScore ( $ solutionData [ 'score' ] ) ; if ( ! empty ( $ solutionData [ 'feedback' ] ) ) { $ area -> setFeedback ( $ solutionData [ 'feedback' ] ) ; } // Deserializes area definition $ this -> deserializeArea ( $ area , $ solutionData [ 'area' ] ) ; $ graphicQuestion -> addArea ( $ area ) ; } // Remaining areas are no longer in the question foreach ( $ areaEntities as $ areaToRemove ) { $ graphicQuestion -> removeArea ( $ areaToRemove ) ; } }
Deserializes Question areas.

@param GraphicQuestion $graphicQuestion
@param array           $solutions
Deserializes Question areas .