/**
  * @see SpecialSetEntity::getValue()
  *
  * @since 0.4
  *
  * @param Fingerprint $fingerprint
  * @param string $languageCode
  *
  * @return string
  */
 protected function getValue(Fingerprint $fingerprint, $languageCode)
 {
     if ($fingerprint->hasAliasGroup($languageCode)) {
         return implode('|', $fingerprint->getAliasGroup($languageCode)->getAliases());
     }
     return '';
 }
Exemplo n.º 2
0
 public function testHasAliasGroupReturnsTrueOnlyWhenAliasGroupExists()
 {
     $fingerprint = new Fingerprint();
     $fingerprint->setAliasGroup('en', array('foo'));
     $this->assertTrue($fingerprint->hasAliasGroup('en'));
     $this->assertFalse($fingerprint->hasAliasGroup('de'));
 }
 /**
  * @param Fingerprint $fingerprint
  *
  * @return ChangeOp[]
  */
 private function getChangeOps(Fingerprint $fingerprint)
 {
     $changeOpFactory = $this->changeOpFactory;
     $changeOps = array();
     if ($this->label !== '') {
         if (!$fingerprint->hasLabel($this->languageCode) || $fingerprint->getLabel($this->languageCode)->getText() !== $this->label) {
             $changeOps['wbsetlabel'] = $changeOpFactory->newSetLabelOp($this->languageCode, $this->label);
         }
     } elseif ($fingerprint->hasLabel($this->languageCode)) {
         $changeOps['wbsetlabel'] = $changeOpFactory->newRemoveLabelOp($this->languageCode);
     }
     if ($this->description !== '') {
         if (!$fingerprint->hasDescription($this->languageCode) || $fingerprint->getDescription($this->languageCode)->getText() !== $this->description) {
             $changeOps['wbsetdescription'] = $changeOpFactory->newSetDescriptionOp($this->languageCode, $this->description);
         }
     } elseif ($fingerprint->hasDescription($this->languageCode)) {
         $changeOps['wbsetdescription'] = $changeOpFactory->newRemoveDescriptionOp($this->languageCode);
     }
     if (!empty($this->aliases)) {
         if (!$fingerprint->hasAliasGroup($this->languageCode) || $fingerprint->getAliasGroup($this->languageCode)->getAliases() !== $this->aliases) {
             $changeOps['wbsetaliases'] = $changeOpFactory->newSetAliasesOp($this->languageCode, $this->aliases);
         }
     } elseif ($fingerprint->hasAliasGroup($this->languageCode)) {
         $changeOps['wbsetaliases'] = $changeOpFactory->newRemoveAliasesOp($this->languageCode, $fingerprint->getAliasGroup($this->languageCode)->getAliases());
     }
     return $changeOps;
 }