comparison core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php
2
3 namespace Drupal\Core\Ajax;
4
5 use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
6
7 /**
8 * Provides a helper to determine if the current request is via AJAX.
9 *
10 * @internal
11 */
12 trait AjaxHelperTrait {
13
14 /**
15 * Determines if the current request is via AJAX.
16 *
17 * @return bool
18 * TRUE if the current request is via AJAX, FALSE otherwise.
19 */
20 protected function isAjax() {
21 foreach (['drupal_ajax', 'drupal_modal', 'drupal_dialog'] as $wrapper) {
22 if (strpos($this->getRequestWrapperFormat(), $wrapper) !== FALSE) {
23 return TRUE;
24 }
25 }
26 return FALSE;
27 }
28
29 /**
30 * Gets the wrapper format of the current request.
31 *
32 * @string
33 * The wrapper format.
34 */
35 protected function getRequestWrapperFormat() {
36 return \Drupal::request()->get(MainContentViewSubscriber::WRAPPER_FORMAT);
37 }
38
39 }