Tree.php in Views tree 8.2
File
src/Plugin/views/style/Tree.php
View source
<?php
namespace Drupal\views_tree\Plugin\views\style;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\style\HtmlList;
use Drupal\views_tree\TreeStyleTrait;
class Tree extends HtmlList {
use TreeStyleTrait;
protected $usesRowPlugin = TRUE;
protected $usesFields = TRUE;
protected $usesGrouping = FALSE;
protected function defineOptions() {
$options = parent::defineOptions();
$this
->defineCommonOptions($options);
$options['class'] = [
'default' => '',
];
$options['wrapper_class'] = [
'default' => 'item-list',
];
$options['collapsible_tree'] = [
'default' => 0,
];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$this
->getCommonOptionsForm($form, $form_state);
$events = [
'click' => $this
->t('On Click'),
'mouseover' => $this
->t('On Mouseover'),
];
$form['type']['#description'] = $this
->t('Whether to use an ordered or unordered list for the retrieved items. Most use cases will prefer Unordered.');
unset($form['wrapper_class']);
unset($form['class']);
$form['collapsible_tree'] = [
'#type' => 'radios',
'#title' => $this
->t('Collapsible view'),
'#default_value' => $this->options['collapsible_tree'],
'#options' => [
0 => $this
->t('Off'),
'expanded' => $this
->t('Expanded'),
'collapsed' => $this
->t('Collapsed'),
],
];
}
}
Classes
Name |
Description |
Tree |
Style plugin to render each item as hierarchy. |