/** * Constructs an "frontLanguage" array, a mere structure for the Add / Update View that is just an array * of another array. The structure is as follows: * * frontLanguageArray[X] = * [0] = Lanugage Object * [1] = FrontAttribute Objects array * * So, you get all attributes for each language object to display * * @param $object Object - If specified, attribute values assigned to the object are extracted and filled in the FrontAttribute * @return array - the "FrontLanguage" array */ function constructFrontLanguageArray($object = null) { // Set all data needed // Takes all attributes for the class and for each language $languageMapper = new LanguageMapper(); $languageArray = $languageMapper->getAll(); // Generate FrontAttributes $frontLanguageArray = array(); foreach ($languageArray as $language) { $attributeArray = $this->class->getAttributesForLanguage($language); $frontAttributeArray = array(); foreach ($attributeArray as $classAttribute) { $variant = null; // Crossroad -> if the object was given, try to extract the ObjectAttribute if ($object != null) { $variant = $object->getAttributeForLanguage($classAttribute->getId(), $language->getId()); } // If the object was not received, or the object doesn't have this attribute assigned, use the basic attribute if ($variant == null) { $variant = $classAttribute; } $frontAttribute = FrontAttributeFactory::newInstance($language, $variant); array_push($frontAttributeArray, $frontAttribute); } $languageObject = array(0 => $language, 1 => $frontAttributeArray); array_push($frontLanguageArray, $languageObject); } return $frontLanguageArray; }