ViewsMenuLinkForm.php in Zircon Profile 8
File
core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php
View source
<?php
namespace Drupal\views\Plugin\Menu\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Menu\Form\MenuLinkDefaultForm;
class ViewsMenuLinkForm extends MenuLinkDefaultForm {
protected $menuLink;
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Title'),
'#default_value' => $this->menuLink
->getTitle(),
'#weight' => -10,
);
$form['description'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Description'),
'#description' => $this
->t('Shown when hovering over the menu link.'),
'#default_value' => $this->menuLink
->getDescription(),
'#weight' => -5,
);
$form += parent::buildConfigurationForm($form, $form_state);
$form['info']['#weight'] = -8;
$form['path']['#weight'] = -7;
$view = $this->menuLink
->loadView();
$id = $view->storage
->id();
$label = $view->storage
->label();
if ($this->moduleHandler
->moduleExists('views_ui')) {
$message = $this
->t('This link is provided by the Views module. The path can be changed by editing the view <a href=":url">@label</a>', array(
':url' => \Drupal::url('entity.view.edit_form', array(
'view' => $id,
)),
'@label' => $label,
));
}
else {
$message = $this
->t('This link is provided by the Views module from view %label.', array(
'%label' => $label,
));
}
$form['info']['#title'] = $message;
return $form;
}
public function extractFormValues(array &$form, FormStateInterface $form_state) {
$definition = parent::extractFormValues($form, $form_state);
$definition['title'] = $form_state
->getValue('title');
$definition['description'] = $form_state
->getValue('description');
return $definition;
}
}