ViewsAttachLibraryDisplayExtender.php in Views Attach Library 8.x
File
src/Plugin/views/display_extender/ViewsAttachLibraryDisplayExtender.php
View source
<?php
namespace Drupal\views_attach_library\Plugin\views\display_extender;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase;
class ViewsAttachLibraryDisplayExtender extends DisplayExtenderPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
if ($form_state
->get('section') == 'attach_library') {
$form['attach_library'] = [
'#type' => 'textfield',
'#title' => 'Add Libraries',
'#description' => $this
->t('Add library name in textfield , for exmaple ' . 'add <b>"abc/xyz"</b> where <b>abc</b> is module or theme name and ' . '<b>xyz</b> is library name. For more info please read README.txt file.'),
'#default_value' => !empty($this->options['attach_library']['attach_library']) ? $this->options['attach_library']['attach_library'] : '',
];
}
}
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
}
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
if ($form_state
->get('section') == 'attach_library') {
$this->options['attach_library'] = $form_state
->cleanValues()
->getValue($section);
}
}
public function preExecute() {
}
public function query() {
}
public function optionsSummary(&$categories, &$options) {
$categories['attach_library'] = [
'title' => t('Attach Library'),
'column' => 'second',
];
$options['attach_library'] = [
'category' => 'attach_library',
'title' => t('Attach Library'),
'value' => empty($this->options['attach_library']['attach_library']) ? $this
->t('Add Library') : $this
->t('Edit Library'),
];
}
public function defaultableSections(&$sections, $section = NULL) {
}
}