Same filename and directory in other branches
- 8.9.x core/modules/views/src/Plugin/views/area/AreaPluginBase.php
- 9 core/modules/views/src/Plugin/views/area/AreaPluginBase.php
Namespace
Drupal\views\Plugin\views\area
File
core/modules/views/src/Plugin/views/area/AreaPluginBase.php
View source
<?php
namespace Drupal\views\Plugin\views\area;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\HandlerBase;
abstract class AreaPluginBase extends HandlerBase {
public $areaType;
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
if ($this->areaType == 'empty') {
$this->options['empty'] = TRUE;
}
}
public function usesGroupBy() {
return FALSE;
}
protected function defineOptions() {
$options = parent::defineOptions();
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
$options['admin_label']['default'] = $label;
$options['empty'] = [
'default' => FALSE,
];
return $options;
}
public function adminSummary() {
return $this
->adminLabel();
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
if ($form_state
->get('type') != 'empty') {
$form['empty'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Display even if view has no result'),
'#default_value' => $this->options['empty'] ?? 0,
];
}
}
public function preRender(array $results) {
}
public abstract function render($empty = FALSE);
public function isEmpty() {
return empty($this->options['empty']);
}
}
Classes