annotate core/modules/layout_builder/src/Controller/AjaxHelperTrait.php @ 15:e200cb7efeb3

Update Drupal core to 8.5.3 via Composer
author Chris Cannam
date Thu, 26 Apr 2018 11:26:54 +0100
parents 1fec387a4317
children
rev   line source
Chris@14 1 <?php
Chris@14 2
Chris@14 3 namespace Drupal\layout_builder\Controller;
Chris@14 4
Chris@14 5 use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
Chris@14 6
Chris@14 7 /**
Chris@14 8 * Provides a helper to determine if the current request is via AJAX.
Chris@14 9 *
Chris@14 10 * @internal
Chris@14 11 *
Chris@14 12 * @todo Move to \Drupal\Core in https://www.drupal.org/node/2896535.
Chris@14 13 */
Chris@14 14 trait AjaxHelperTrait {
Chris@14 15
Chris@14 16 /**
Chris@14 17 * Determines if the current request is via AJAX.
Chris@14 18 *
Chris@14 19 * @return bool
Chris@14 20 * TRUE if the current request is via AJAX, FALSE otherwise.
Chris@14 21 */
Chris@14 22 protected function isAjax() {
Chris@14 23 return in_array($this->getRequestWrapperFormat(), [
Chris@14 24 'drupal_ajax',
Chris@14 25 'drupal_dialog',
Chris@14 26 'drupal_dialog.off_canvas',
Chris@14 27 'drupal_modal',
Chris@14 28 ]);
Chris@14 29 }
Chris@14 30
Chris@14 31 /**
Chris@14 32 * Gets the wrapper format of the current request.
Chris@14 33 *
Chris@14 34 * @string
Chris@14 35 * The wrapper format.
Chris@14 36 */
Chris@14 37 protected function getRequestWrapperFormat() {
Chris@14 38 return \Drupal::request()->get(MainContentViewSubscriber::WRAPPER_FORMAT);
Chris@14 39 }
Chris@14 40
Chris@14 41 }