class BaseUrlAttribute in Acquia Content Hub 8.2
Adds base url to all CDF documents.
Hierarchy
- class \Drupal\acquia_contenthub\EventSubscriber\CdfAttributes\BaseUrlAttribute implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of BaseUrlAttribute
1 string reference to 'BaseUrlAttribute'
1 service uses BaseUrlAttribute
File
- src/
EventSubscriber/ CdfAttributes/ BaseUrlAttribute.php, line 14
Namespace
Drupal\acquia_contenthub\EventSubscriber\CdfAttributesView source
class BaseUrlAttribute implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[AcquiaContentHubEvents::POPULATE_CDF_ATTRIBUTES][] = [
'onPopulateAttributes',
100,
];
return $events;
}
/**
* Adds base url to all CDF documents.
*
* @param \Drupal\acquia_contenthub\Event\CdfAttributesEvent $event
* The event being dispatched.
*
* @throws \Exception
*/
public function onPopulateAttributes(CdfAttributesEvent $event) {
$cdf = $event
->getCdf();
$url = Url::fromUserInput("/", [
'absolute' => TRUE,
]);
$cdf
->addAttribute('base_url', CDFAttribute::TYPE_STRING, $url
->toString());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseUrlAttribute:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
BaseUrlAttribute:: |
public | function | Adds base url to all CDF documents. |