class TestExample

Same name and namespace in other branches
  1. 11.x 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

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 [];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.