public function toArray($filterVariableContent = false, &$filtered = array())
 {
     $data = parent::toArray($filterVariableContent, $filtered);
     //@todo : clean this please: do not use a class attributes to store childdren's ones.
     unset($data['attributes']['mapping']);
     unset($data['attributes']['areaMapping']);
     //prepare the protected data:
     $protectedData = array('correctResponses' => $this->getCorrectResponses(), 'mapping' => $this->mapping, 'areaMapping' => $this->areaMapping, 'howMatch' => $this->howMatch);
     //add mapping attributes
     $mappingAttributes = array('defaultValue' => $this->mappingDefaultValue);
     if (is_array($this->getAttributeValue('mapping'))) {
         $mappingAttributes = array_merge($mappingAttributes, $this->getAttributeValue('mapping'));
     } elseif (is_array($this->getAttributeValue('areaMapping'))) {
         $mappingAttributes = array_merge($mappingAttributes, $this->getAttributeValue('areaMapping'));
     }
     $protectedData['mappingAttributes'] = $mappingAttributes;
     //add simple feedbacks
     $protectedData['feedbackRules'] = $this->getArraySerializedElementCollection($this->getFeedbackRules(), $filterVariableContent, $filtered);
     if ($filterVariableContent) {
         $filtered[$this->getSerial()] = $protectedData;
     } else {
         $data = array_merge($data, $protectedData);
     }
     return $data;
 }
 public function toArray($filterVariableContent = false, &$filtered = array())
 {
     $data = parent::toArray($filterVariableContent, $filtered);
     //@todo : clean this please: do not use a class attributes to store childdren's ones.
     unset($data['attributes']['mapping']);
     unset($data['attributes']['areaMapping']);
     //prepare the protected data:
     $protectedData = array('mapping' => $this->mapping, 'areaMapping' => $this->areaMapping, 'howMatch' => $this->howMatch);
     $correct = [];
     $correctResponses = $this->getCorrectResponses();
     if (is_array($correctResponses)) {
         foreach ($correctResponses as $correctResponseKey => $value) {
             //if correct response has cardinality record:
             if ($this->getAttribute('cardinality') == 'record') {
                 $valueData = $value->toArray();
                 $correct[$valueData['fieldIdentifier']] = $valueData;
             } else {
                 $correct[$correctResponseKey] = (string) $value;
             }
         }
     }
     $protectedData['correctResponses'] = $correct;
     $defaultValues = $this->getDefaultValue();
     if (is_array($defaultValues)) {
         foreach ($defaultValues as $defaultValuesKey => $defaultValue) {
             $defaultValues[$defaultValuesKey] = (string) $defaultValue;
         }
     }
     $protectedData['defaultValue'] = $defaultValues;
     $data['defaultValue'] = $defaultValues;
     //add mapping attributes
     $mappingAttributes = array('defaultValue' => $this->mappingDefaultValue);
     if (is_array($this->getAttributeValue('mapping'))) {
         $mappingAttributes = array_merge($mappingAttributes, $this->getAttributeValue('mapping'));
     } elseif (is_array($this->getAttributeValue('areaMapping'))) {
         $mappingAttributes = array_merge($mappingAttributes, $this->getAttributeValue('areaMapping'));
     }
     $protectedData['mappingAttributes'] = $mappingAttributes;
     //add simple feedbacks
     $protectedData['feedbackRules'] = $this->getArraySerializedElementCollection($this->getFeedbackRules(), $filterVariableContent, $filtered);
     if ($filterVariableContent) {
         $filtered[$this->getSerial()] = $protectedData;
     } else {
         $data = array_merge($data, $protectedData);
     }
     return $data;
 }
 public function toArray($filterVariableContent = false, &$filtered = array())
 {
     $data = parent::toArray($filterVariableContent, $filtered);
     $data['defaultValue'] = $this->getDefaultValue();
     return $data;
 }