public function ClientCdfLanguage::onBuildClientCdf in Acquia Content Hub 8.2
Adds language information to ClientCDF documents.
Parameters
\Drupal\acquia_contenthub\Event\BuildClientCdfEvent $event: The event being dispatched.
Throws
\Exception
File
- src/
EventSubscriber/ ClientCdf/ ClientCdfLanguage.php, line 71
Class
- ClientCdfLanguage
- Adds base url to all CDF documents.
Namespace
Drupal\acquia_contenthub\EventSubscriber\ClientCdfCode
public function onBuildClientCdf(BuildClientCdfEvent $event) {
$cdf = $event
->getCdf();
$metadata = $cdf
->getMetadata();
// Set a default language if translation is not enabled.
if (!$this->moduleHandler
->moduleExists('language')) {
$default_language = [
'direction' => $this->languageDefault
->get()
->getDirection(),
'id' => $this->languageDefault
->get()
->getId(),
'label' => $this->languageDefault
->get()
->getName(),
'langcode' => $this->languageDefault
->get()
->getId(),
'locked' => $this->languageDefault
->get()
->isLocked(),
'status' => 1,
'weight' => $this->languageDefault
->get()
->getWeight(),
];
$metadata['languages'][$default_language['langcode']] = $default_language;
}
else {
$metadata['languages'] = $this
->getLanguages();
}
$cdf
->setMetadata($metadata);
}