/** * Returns the desired instance of the GenericORMapper configured for this application case. * * @param GenericDomainObject[] A list of generic entries. * @param boolean $addEditor Indicates, if the editor should be mapped to the entry object. * * @return Entry[] A list of guestbook domain objects. * * @author Christian Achatz * @version * Version 0.1, 06.05.2009<br /> */ private function mapGenericEntries2DomainObjects(array $entries = [], $addEditor = true) { // return empty array, because having no entries means nothing to do! if (count($entries) == 0) { return []; } // invoke benchmarker to be able to monitor the performance /* @var $t BenchmarkTimer */ $t = Singleton::getInstance(BenchmarkTimer::class); $t->start('mapGenericEntries2DomainObjects()'); // load the language object for the current language to enable // language dependent mapping! $lang = $this->getCurrentLanguage(); // define the criterion $critEntries = new GenericCriterionObject(); $critEntries->addRelationIndicator('Attribute2Language', $lang); $gbEntries = []; /* @var $current GenericDomainObject */ foreach ($entries as $current) { // Check, whether there are attributes related in the current language. // If not, do NOT add an entry, because it will be empty! $attributes = $this->orm->loadRelatedObjects($current, 'Entry2LangDepValues', $critEntries); if (count($attributes) > 0) { // load the entry itself $entry = new Entry(); $entry->setCreationTimestamp($current->getProperty('CreationTimestamp')); foreach ($attributes as $attribute) { if ($attribute->getProperty('Name') == 'title') { $entry->setTitle($attribute->getProperty('Value')); } if ($attribute->getProperty('Name') == 'text') { $entry->setText($attribute->getProperty('Value')); } } // add the editor's data if ($addEditor === true) { $editor = new User(); $user = $this->orm->loadRelatedObjects($current, 'Editor2Entry'); $editor->setName($user[0]->getProperty('Name')); $editor->setEmail($user[0]->getProperty('Email')); $editor->setWebsite($user[0]->getProperty('Website')); $editor->setId($user[0]->getProperty('UserID')); $entry->setEditor($editor); } $entry->setId($current->getProperty('EntryID')); $gbEntries[] = $entry; } } $t->stop('mapGenericEntries2DomainObjects()'); return $gbEntries; }