Commit 5c84cb1b authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2785135 by tedbow, RajeevK, effulgentsia, alexpott: Rename protected...

Issue #2785135 by tedbow, RajeevK, effulgentsia, alexpott: Rename protected property SystemMenuOffCanvasForm::$entity to $menu?
parent 85a7eb8b
......@@ -33,9 +33,11 @@ class SystemMenuOffCanvasForm extends PluginFormBase implements ContainerInjecti
protected $plugin;
/**
* The menu entity that the block uses and that will be edited in this form.
*
* @var \Drupal\system\MenuInterface
*/
protected $entity;
protected $menu;
/**
* @var \Drupal\Core\Entity\EntityStorageInterface
......@@ -81,10 +83,10 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$form['entity_form'] = [
'#type' => 'details',
'#title' => $this->t('Edit menu %label', ['%label' => $this->entity->label()]),
'#title' => $this->t('Edit menu %label', ['%label' => $this->menu->label()]),
'#open' => TRUE,
];
$form['entity_form'] += $this->getEntityForm($this->entity)->buildForm([], $form_state);
$form['entity_form'] += $this->getEntityForm($this->menu)->buildForm([], $form_state);
// Print the menu link titles as text instead of a link.
if (!empty($form['entity_form']['links']['links'])) {
......@@ -111,7 +113,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->plugin->validateConfigurationForm($form, $form_state);
$this->getEntityForm($this->entity)->validateForm($form, $form_state);
$this->getEntityForm($this->menu)->validateForm($form, $form_state);
}
/**
......@@ -119,22 +121,22 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->plugin->submitConfigurationForm($form, $form_state);
$this->getEntityForm($this->entity)->submitForm($form, $form_state);
$this->entity->save();
$this->getEntityForm($this->menu)->submitForm($form, $form_state);
$this->menu->save();
}
/**
* Gets the entity form for this menu.
*
* @param \Drupal\system\MenuInterface $entity
* @param \Drupal\system\MenuInterface $menu
* The menu entity.
*
* @return \Drupal\Core\Entity\EntityFormInterface
* The entity form.
*/
protected function getEntityForm(MenuInterface $entity) {
protected function getEntityForm(MenuInterface $menu) {
$entity_form = $this->entityTypeManager->getFormObject('menu', 'edit');
$entity_form->setEntity($entity);
$entity_form->setEntity($menu);
return $entity_form;
}
......@@ -143,7 +145,7 @@ protected function getEntityForm(MenuInterface $entity) {
*/
public function setPlugin(PluginInspectionInterface $plugin) {
$this->plugin = $plugin;
$this->entity = $this->menuStorage->load($this->plugin->getDerivativeId());
$this->menu = $this->menuStorage->load($this->plugin->getDerivativeId());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment