/**
* 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()]);
}
}