getConcreteLocales() 공개 메소드

Return locales which are not shadows.
public getConcreteLocales ( Sulu\Component\Content\Document\Behavior\ShadowLocaleBehavior $document ) : array
$document Sulu\Component\Content\Document\Behavior\ShadowLocaleBehavior
리턴 array
예제 #1
0
 /**
  * Adds the concrete languages available and the type (ghost or shadow) of the document to the serialization.
  *
  * @param ObjectEvent $event
  */
 public function onPostSerialize(ObjectEvent $event)
 {
     $document = $event->getObject();
     if (!$document instanceof LocaleBehavior || !$this->documentRegistry->hasDocument($document)) {
         return;
     }
     $visitor = $event->getVisitor();
     $visitor->addData('concreteLanguages', $this->documentInspector->getConcreteLocales($document));
     $localizationState = $this->documentInspector->getLocalizationState($document);
     if ($localizationState === LocalizationState::GHOST) {
         $visitor->addData('type', ['name' => 'ghost', 'value' => $document->getLocale()]);
     }
     if ($localizationState === LocalizationState::SHADOW) {
         $visitor->addData('type', ['name' => 'shadow', 'value' => $document->getLocale()]);
     }
 }
예제 #2
0
 private function validateShadow(ShadowLocaleBehavior $document)
 {
     if ($document->getLocale() === $document->getShadowLocale()) {
         throw new \RuntimeException(sprintf('Document cannot be a shadow of itself for locale "%s"', $document->getLocale()));
     }
     $locales = $this->inspector->getConcreteLocales($document);
     if (!in_array($document->getShadowLocale(), $locales)) {
         $this->inspector->getNode($document)->revert();
         throw new \RuntimeException(sprintf('Attempting to create shadow for "%s" on a non-concrete locale "%s" for document at "%s". Concrete languages are "%s"', $document->getLocale(), $document->getShadowLocale(), $this->inspector->getPath($document), implode('", "', $locales)));
     }
 }
예제 #3
0
 public function getConcreteLanguages()
 {
     return $this->inspector->getConcreteLocales($this->getDocument());
 }