Sulu\Bundle\DocumentManagerBundle\Bridge\DocumentInspector::getShadowLocales PHP Method

getShadowLocales() public method

Return the enabled shadow locales for the given document.
public getShadowLocales ( Sulu\Component\Content\Document\Behavior\ShadowLocaleBehavior $document ) : array
$document Sulu\Component\Content\Document\Behavior\ShadowLocaleBehavior
return array
    public function getShadowLocales(ShadowLocaleBehavior $document)
    {
        $shadowLocales = [];
        $locales = $this->getLocales($document);
        $node = $this->getNode($document);
        foreach ($locales as $locale) {
            $shadowEnabledName = $this->encoder->localizedSystemName(ShadowLocaleSubscriber::SHADOW_ENABLED_FIELD, $locale);
            $shadowLocaleName = $this->encoder->localizedSystemName(ShadowLocaleSubscriber::SHADOW_LOCALE_FIELD, $locale);
            if ($node->getPropertyValueWithDefault($shadowEnabledName, false)) {
                $shadowLocales[$node->getPropertyValue($shadowLocaleName)] = $locale;
            }
        }
        return $shadowLocales;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Adds the enabled shadow languages to the serialization.
  *
  * @param ObjectEvent $event
  */
 public function onPostSerialize(ObjectEvent $event)
 {
     $document = $event->getObject();
     if (!$document instanceof ShadowLocaleBehavior || !$this->documentRegistry->hasDocument($document)) {
         return;
     }
     $visitor = $event->getVisitor();
     $visitor->addData('enabledShadowLanguages', $this->documentInspector->getShadowLocales($document));
 }
All Usage Examples Of Sulu\Bundle\DocumentManagerBundle\Bridge\DocumentInspector::getShadowLocales