Ejemplo n.º 1
0
 /**
  * @param array[] $patchedAliases
  *
  * @return AliasGroupList
  */
 private function getAliasesFromArrayForPatching(array $patchedAliases)
 {
     $aliases = new AliasGroupList();
     foreach ($patchedAliases as $languageCode => $aliasList) {
         $aliases->setAliasesForLanguage($languageCode, $aliasList);
     }
     return $aliases;
 }
 /**
  * @param array $serialization
  *
  * @return AliasGroupList
  */
 private function getDeserialized($serialization)
 {
     $aliasGroupList = new AliasGroupList();
     foreach ($serialization as $languageCode => $aliasGroupSerialization) {
         $aliasGroupList->setGroup($this->deserializeAliasGroup($aliasGroupSerialization, $languageCode));
     }
     return $aliasGroupList;
 }
 /**
  * @param AliasGroupList $aliasGroupList
  *
  * @return array
  */
 private function getSerialized(AliasGroupList $aliasGroupList)
 {
     $serialization = array();
     foreach ($aliasGroupList->getIterator() as $aliasGroup) {
         $serialization[$aliasGroup->getLanguageCode()] = $this->aliasGroupSerializer->serialize($aliasGroup);
     }
     if ($this->useObjectsForMaps) {
         $serialization = (object) $serialization;
     }
     return $serialization;
 }
Ejemplo n.º 4
0
 public function testToTextArray()
 {
     $list = new AliasGroupList();
     $list->setAliasesForLanguage('en', array('foo', 'baz'));
     $list->setAliasesForLanguage('de', array('bar'));
     $expected = array('en' => array('foo', 'baz'), 'de' => array('bar'));
     $this->assertEquals($expected, $list->toTextArray());
 }
 /**
  * @param AliasGroupList $aliasGroups
  * @param string $languageCode
  *
  * @return string HTML
  */
 private function getAliasesView(AliasGroupList $aliasGroups, $languageCode)
 {
     if (!$aliasGroups->hasGroupForLanguage($languageCode)) {
         return $this->templateFactory->render('wikibase-aliasesview', 'wb-empty', '', '');
     } else {
         $aliasesHtml = '';
         $aliases = $aliasGroups->getByLanguage($languageCode)->getAliases();
         foreach ($aliases as $alias) {
             $aliasesHtml .= $this->templateFactory->render('wikibase-aliasesview-list-item', htmlspecialchars($alias));
         }
         return $this->templateFactory->render('wikibase-aliasesview', '', $aliasesHtml, '');
     }
 }
 private function injectAliases(array &$entityRecord, AliasGroupList $aliasGroups)
 {
     if (!isset($entityRecord['aliases'])) {
         $entityRecord['aliases'] = array();
     }
     foreach ($aliasGroups->toArray() as $aliasGroup) {
         $lang = $aliasGroup->getLanguageCode();
         $entityRecord['aliases'][$lang] = array();
         foreach ($aliasGroup->getAliases() as $text) {
             $entityRecord['aliases'][$lang][] = array('language' => $lang, 'value' => $text);
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * @since 0.7.4
  *
  * @return bool
  */
 public function isEmpty()
 {
     return $this->labels->isEmpty() && $this->descriptions->isEmpty() && $this->aliasGroups->isEmpty();
 }