You are here

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'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses ConfigurableLanguageHandler
configurable_language.cdf.handler in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\EventSubscriber\Cdf\ConfigurableLanguageHandler

File

src/EventSubscriber/Cdf/ConfigurableLanguageHandler.php, line 14

Namespace

Drupal\acquia_contenthub\EventSubscriber\Cdf
View 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

Namesort descending Modifiers Type Description Overrides
ConfigurableLanguageHandler::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ConfigurableLanguageHandler::onCreateCdf public function Adds the langcode metadata to configurable_language cdf objects.