You are here

ViewsContextTrait.php in Geolocation Field 8.3

Same filename and directory in other branches
  1. 8.2 src/ViewsContextTrait.php

Namespace

Drupal\geolocation

File

src/ViewsContextTrait.php
View source
<?php

namespace Drupal\geolocation;


/**
 * Trait ViewsContextTrait.
 */
trait ViewsContextTrait {

  /**
   * Get display handler from context.
   *
   * @param mixed $context
   *   Context.
   *
   * @return bool|\Drupal\views\Plugin\views\display\DisplayPluginBase
   *   Display handler or FALSE.
   */
  protected static function getViewsDisplayHandler($context = NULL) {
    if (!is_object($context)) {
      return FALSE;
    }
    if (is_subclass_of($context, 'Drupal\\views\\Plugin\\views\\style\\StylePluginBase')) {

      /** @var \Drupal\views\Plugin\views\display\DisplayPluginBase $context */
      return $context->displayHandler;
    }
    if (is_subclass_of($context, 'Drupal\\views\\Plugin\\views\\HandlerBase')) {

      /** @var \Drupal\views\Plugin\views\display\DisplayPluginBase $context */
      return $context->displayHandler;
    }
    return FALSE;
  }

}

Traits

Namesort descending Description
ViewsContextTrait Trait ViewsContextTrait.