Mercurial > hg > isophonics-drupal-site
comparison core/modules/layout_builder/src/Controller/AjaxHelperTrait.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\layout_builder\Controller; | |
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 * @todo Move to \Drupal\Core in https://www.drupal.org/node/2896535. | |
13 */ | |
14 trait AjaxHelperTrait { | |
15 | |
16 /** | |
17 * Determines if the current request is via AJAX. | |
18 * | |
19 * @return bool | |
20 * TRUE if the current request is via AJAX, FALSE otherwise. | |
21 */ | |
22 protected function isAjax() { | |
23 return in_array($this->getRequestWrapperFormat(), [ | |
24 'drupal_ajax', | |
25 'drupal_dialog', | |
26 'drupal_dialog.off_canvas', | |
27 'drupal_modal', | |
28 ]); | |
29 } | |
30 | |
31 /** | |
32 * Gets the wrapper format of the current request. | |
33 * | |
34 * @string | |
35 * The wrapper format. | |
36 */ | |
37 protected function getRequestWrapperFormat() { | |
38 return \Drupal::request()->get(MainContentViewSubscriber::WRAPPER_FORMAT); | |
39 } | |
40 | |
41 } |