You are here

class TestExample in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php \Drupal\views_test_data\Plugin\views\area\TestExample
  2. 9 core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php \Drupal\views_test_data\Plugin\views\area\TestExample

Test area plugin.

Plugin annotation

@ViewsArea("test_example");

Hierarchy

  • class \Drupal\views\Plugin\views\area\AreaPluginBase extends \Drupal\views\Plugin\views\HandlerBase
    • class \Drupal\views_test_data\Plugin\views\area\TestExample

Expanded class hierarchy of TestExample

See also

\Drupal\views\Tests\Handler\AreaTest

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php, line 16

Namespace

Drupal\views_test_data\Plugin\views\area
View source
class TestExample extends AreaPluginBase {

  /**
   * {@inheritdoc}
   */
  public function access(AccountInterface $account) {
    return $this->options['custom_access'];
  }

  /**
   * {@inheritdoc}
   */
  public function defineOptions() {
    $options = parent::defineOptions();
    $options['string'] = [
      'default' => '',
    ];
    $options['custom_access'] = [
      'default' => TRUE,
    ];
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $this
      ->globalTokenForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function render($empty = FALSE) {
    if (!$empty || !empty($this->options['empty'])) {
      return [
        '#markup' => $this
          ->globalTokenReplace($this->options['string']),
      ];
    }
    return [];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AreaPluginBase::$areaType public property The type of this area handler, i.e. 'header', 'footer', or 'empty'.
AreaPluginBase::adminSummary public function
AreaPluginBase::init public function Overrides Drupal\views\Plugin\views\HandlerBase::init(). 1
AreaPluginBase::isEmpty public function Does that area have nothing to show. 1
AreaPluginBase::preRender public function Performs any operations needed before full rendering. 1
AreaPluginBase::usesGroupBy public function
TestExample::access public function
TestExample::buildOptionsForm public function Overrides AreaPluginBase::buildOptionsForm
TestExample::defineOptions public function Overrides AreaPluginBase::defineOptions
TestExample::render public function Render the area. Overrides AreaPluginBase::render