TestExample.php in Zircon Profile 8
File
core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php
View source
<?php
namespace Drupal\views_test_data\Plugin\views\area;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\views\Plugin\views\area\AreaPluginBase;
class TestExample extends AreaPluginBase {
public function access(AccountInterface $account) {
return $this->options['custom_access'];
}
public function defineOptions() {
$options = parent::defineOptions();
$options['string'] = array(
'default' => '',
);
$options['custom_access'] = array(
'default' => TRUE,
);
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$this
->globalTokenForm($form, $form_state);
}
public function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
return array(
'#markup' => $this
->globalTokenReplace($this->options['string']),
);
}
return array();
}
}