diff --git a/panelizer.routing.yml b/panelizer.routing.yml index acf8e36..5240094 100644 --- a/panelizer.routing.yml +++ b/panelizer.routing.yml @@ -41,3 +41,21 @@ panelizer.wizard.step.context.add: tempstore_id: 'panelizer.wizard' requirements: _permission: 'administer pages' + +panelizer.wizard.step.context.edit: + path: '/admin/panelizer/wizard/{machine_name}/contexts/edit/{context_id}' + defaults: + _form: '\Drupal\panelizer\Form\PanelizerWizardContextConfigure' + _title: 'Edit context' + tempstore_id: 'panelizer.wizard' + requirements: + _permission: 'administer pages' + +panelizer.wizard.step.context.delete: + path: '/admin/panelizer/wizard/{machine_name}/context/delete/{context_id}' + defaults: + _form: '\Drupal\panelizer\Form\PanelizerWizardContextDeleteForm' + _title: 'Delete static context' + tempstore_id: 'panelizer.wizard' + requirements: + _permission: 'administer pages' diff --git a/src/Form/PanelizerWizardContextConfigure.php b/src/Form/PanelizerWizardContextConfigure.php index d297498..3b14868 100644 --- a/src/Form/PanelizerWizardContextConfigure.php +++ b/src/Form/PanelizerWizardContextConfigure.php @@ -16,8 +16,9 @@ class PanelizerWizardContextConfigure extends ContextConfigure { * {@inheritdoc} */ protected function getParentRouteInfo($cached_values) { + $a = 'b'; return ['panelizer.wizard.step', [ - 'machine_name' => $cached_values['machine_name'], + 'machine_name' => $cached_values['id'], 'step' => 'contexts', ]]; } @@ -33,6 +34,7 @@ class PanelizerWizardContextConfigure extends ContextConfigure { * {@inheritdoc} */ protected function addContext($cached_values, $context_id, ContextInterface $context) { + $a = 'b'; $context_config = [ 'label' => $context->getContextDefinition()->getLabel(), 'type' => $context->getContextDefinition()->getDataType(), diff --git a/src/Form/PanelizerWizardContextDeleteForm.php b/src/Form/PanelizerWizardContextDeleteForm.php new file mode 100644 index 0000000..783eff9 --- /dev/null +++ b/src/Form/PanelizerWizardContextDeleteForm.php @@ -0,0 +1,57 @@ +getTempstore(); + return $this->t('Are you sure you want to delete the context @label?', ['@label' => $cached_values['contexts'][$this->context_id]['label']]); + } + + /** + * {@inheritdoc} + */ + public function getCancelUrl() { + $cached_values = $this->getTempstore(); + + return new Url('panelizer.wizard.step', [ + 'machine_name' => $cached_values['id'], + 'step' => 'contexts', + ]); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $cached_values = $this->getTempstore(); + drupal_set_message($this->t('The static context %label has been removed.', ['%label' => $cached_values['contexts'][$this->context_id]['label']])); + unset($cached_values['contexts'][$this->context_id]); + $this->setTempstore($cached_values); + parent::submitForm($form, $form_state); + } + +} diff --git a/src/Form/PanelizerWizardContextForm.php b/src/Form/PanelizerWizardContextForm.php index 2046049..dd3556a 100644 --- a/src/Form/PanelizerWizardContextForm.php +++ b/src/Form/PanelizerWizardContextForm.php @@ -88,7 +88,7 @@ class PanelizerWizardContextForm extends ManageContext { * {@inheritdoc} */ protected function getContextOperationsRouteInfo($cached_values, $machine_name, $row) { - return ['panelizer.wizard.step.context.add', [ + return ['panelizer.wizard.step.context', [ 'machine_name' => $machine_name, 'context_id' => $row, ]]; @@ -98,7 +98,7 @@ class PanelizerWizardContextForm extends ManageContext { * {@inheritdoc} */ protected function getRelationshipOperationsRouteInfo($cached_values, $machine_name, $row) { - return ['panelizer.wizard.step.context.add', [ + return ['panelizer.wizard.step.context', [ 'machine_name' => $machine_name, 'context_id' => $row, ]];