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

getConcreteLocales() public method

Return locales which are not shadows.
public getConcreteLocales ( Sulu\Component\Content\Document\Behavior\ShadowLocaleBehavior $document ) : array
$document Sulu\Component\Content\Document\Behavior\ShadowLocaleBehavior
return array
    public function getConcreteLocales($document)
    {
        $locales = $this->getLocales($document);
        if ($document instanceof ShadowLocaleBehavior) {
            $locales = array_diff($locales, $this->getShadowLocales($document));
        }
        return array_values($locales);
    }

Usage Example

コード例 #1
0
ファイル: LocaleSubscriber.php プロジェクト: sulu/sulu
 /**
  * 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()]);
     }
 }
All Usage Examples Of Sulu\Bundle\DocumentManagerBundle\Bridge\DocumentInspector::getConcreteLocales