/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The static context %label has been removed.', ['%label' => $this->pageVariant->getStaticContext($this->staticContext)['label']])); $this->pageVariant->removeStaticContext($this->staticContext); $this->pageVariant->save(); $form_state->setRedirectUrl($this->getCancelUrl()); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->getVariantPlugin()->removeBlock($this->block->getConfiguration()['uuid']); $this->pageVariant->save(); drupal_set_message($this->t('The block %label has been removed.', ['%label' => $this->block->label()])); $form_state->setRedirectUrl($this->getCancelUrl()); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->pageVariant->removeSelectionCondition($this->selectionCondition->getConfiguration()['uuid']); $this->pageVariant->save(); drupal_set_message($this->t('The selection condition %name has been removed.', ['%name' => $this->selectionCondition->getPluginDefinition()['label']])); $form_state->setRedirectUrl($this->getCancelUrl()); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $configuration = $this->condition->getConfiguration(); // If this selection condition is new, add it to the page. if (!isset($configuration['uuid'])) { $this->pageVariant->addSelectionCondition($configuration); } // Save the page entity. $this->pageVariant->save(); $form_state->setRedirectUrl($this->pageVariant->toUrl('edit-form')); }
/** * @covers ::save * * @expectedException \Exception * @expectedExceptionMessage Page variant doesn't use a Panels display variant */ public function testSaveNotPanels() { $this->storage->load('not_a_panel')->willReturn($this->pageVariantNotPanels->reveal()); $this->panelsDisplay->setConfiguration(Argument::cetera())->shouldNotBeCalled(); $this->pageVariant->save()->shouldNotBeCalled(); $panels_display = $this->prophesize(PanelsDisplayVariant::class); $panels_display->getStorageId()->willReturn('not_a_panel'); $panels_display->getConfiguration()->shouldNotBeCalled(); $panels_storage = new PageManagerPanelsStorage([], '', [], $this->entityTypeManager->reveal()); $panels_storage->save($panels_display->reveal()); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $selection = $form_state->getValue('selection'); $entity_type = $form_state->getValue('entity_type'); $entity = $this->getEntityFromSelection($entity_type, $selection); $this->staticContext = ['label' => $form_state->getValue('label'), 'type' => 'entity:' . $entity_type, 'value' => $entity->uuid()]; $this->pageVariant->setStaticContext($form_state->getValue('machine_name'), $this->staticContext); $this->pageVariant->save(); // Set the submission message. drupal_set_message($this->submitMessageText()); $form_state->setRedirectUrl($this->pageVariant->toUrl('edit-form')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $settings = (new FormState())->setValues($form_state->getValue('settings')); // Call the plugin submit handler. $this->block->submitConfigurationForm($form, $settings); // Update the original form values. $form_state->setValue('settings', $settings->getValues()); if ($this->block instanceof ContextAwarePluginInterface) { $this->block->setContextMapping($form_state->getValue('context_mapping', [])); } $this->getVariantPlugin()->updateBlock($this->block->getConfiguration()['uuid'], ['region' => $form_state->getValue('region')]); $this->pageVariant->save(); $form_state->setRedirectUrl($this->pageVariant->toUrl('edit-form')); }
/** * Takes the current Page Variant and saves it, optionally deleting anything * that may be in temp store. * * @param \Drupal\page_manager\PageVariantInterface $page_variant * The current Page Variant. * @param bool $temp * Whether or not to save to temp store. * * @return \Drupal\page_manager\PageVariantInterface */ protected function savePageVariant(PageVariantInterface $page_variant, $temp = TRUE) { $temp_store_key = 'variant.' . $page_variant->id(); // Save configuration to temp store. if ($temp) { /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $variant_plugin */ $variant_plugin = $page_variant->getVariantPlugin(); $this->tempStore->set($temp_store_key, $variant_plugin->getConfiguration()); } else { // Check to see if temp store has configuration saved. if ($variant_config = $this->tempStore->get($temp_store_key)) { // Delete the existing temp store value. $this->tempStore->delete($temp_store_key); } // Save the real entity. $page_variant->save(); } return $page_variant; }