class EventSubscriber in JS Callback Handler 8.3
Same name in this branch
- 8.3 src/EventSubscriber.php \Drupal\js\EventSubscriber
- 8.3 js_callback_examples/src/EventSubscriber.php \Drupal\js_callback_examples\EventSubscriber
EventSubscriber.
Hierarchy
- class \Drupal\js_callback_examples\EventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of EventSubscriber
1 string reference to 'EventSubscriber'
- js_callback_examples.services.yml in js_callback_examples/
js_callback_examples.services.yml - js_callback_examples/js_callback_examples.services.yml
1 service uses EventSubscriber
File
- js_callback_examples/
src/ EventSubscriber.php, line 13
Namespace
Drupal\js_callback_examplesView source
class EventSubscriber implements EventSubscriberInterface {
/**
* @var \Drupal\js\Js
*/
protected $js;
/**
* EventSubscriber constructor.
*
* @param \Drupal\js\Js $js
* The JS Callback service.
*/
public function __construct(Js $js) {
$this->js = $js;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
KernelEvents::REQUEST => [
'onRequest',
],
];
}
/**
* For
*/
public function onRequest() {
// Only show this message if not executing a JS Callback.
if (!$this->js
->isExecuting()) {
drupal_set_message(t('You have the JS Example module enabled. Please make sure you disable it when you are done. View <a href=":url">example page</a>.', [
':url' => Url::fromRoute('js_callback_examples.form')
->toString(),
]), 'status');
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EventSubscriber:: |
protected | property | ||
EventSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
EventSubscriber:: |
public | function | For | |
EventSubscriber:: |
public | function | EventSubscriber constructor. |