class ConfigurableLanguageHandler in Acquia Content Hub 8.2
Handler for configurable languages.
@package Drupal\acquia_contenthub\EventSubscriber\Cdf
Hierarchy
- class \Drupal\acquia_contenthub\EventSubscriber\Cdf\ConfigurableLanguageHandler implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ConfigurableLanguageHandler
1 string reference to 'ConfigurableLanguageHandler'
1 service uses ConfigurableLanguageHandler
File
- src/
EventSubscriber/ Cdf/ ConfigurableLanguageHandler.php, line 14
Namespace
Drupal\acquia_contenthub\EventSubscriber\CdfView source
class ConfigurableLanguageHandler implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[AcquiaContentHubEvents::CREATE_CDF_OBJECT][] = [
'onCreateCdf',
50,
];
return $events;
}
/**
* Adds the langcode metadata to configurable_language cdf objects.
*
* @param \Drupal\acquia_contenthub\Event\CreateCdfEntityEvent $event
* The parse cdf entity event object.
*/
public function onCreateCdf(CreateCdfEntityEvent $event) {
$entity = $event
->getEntity();
if ($entity
->getEntityTypeId() !== 'configurable_language') {
return;
}
$cdf = $event
->getCdf($entity
->uuid());
$metadata = $cdf
->getMetadata();
$metadata['langcode'] = $entity
->id();
$cdf
->setMetadata($metadata);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableLanguageHandler:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ConfigurableLanguageHandler:: |
public | function | Adds the langcode metadata to configurable_language cdf objects. |