コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->page->removeVariant($this->displayVariant->id());
     $this->page->save();
     drupal_set_message($this->t('The display variant %name has been removed.', ['%name' => $this->displayVariant->label()]));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->page->removeAccessCondition($this->accessCondition->getConfiguration()['uuid']);
     $this->page->save();
     drupal_set_message($this->t('The access condition %name has been removed.', ['%name' => $this->accessCondition->getPluginDefinition()['label']]));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     drupal_set_message($this->t('The static context %label has been removed.', ['%label' => $this->page->getStaticContext($this->staticContext)['label']]));
     $this->page->removeStaticContext($this->staticContext);
     $this->page->save();
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->displayVariant->removeBlock($this->block->getConfiguration()['uuid']);
     $this->page->save();
     drupal_set_message($this->t('The block %label has been removed.', ['%label' => $this->block->label()]));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     parent::submitForm($form, $form_state);
     $configuration = $this->condition->getConfiguration();
     // If this access condition is new, add it to the page.
     if (!isset($configuration['uuid'])) {
         $this->page->addAccessCondition($configuration);
     }
     // Save the page entity.
     $this->page->save();
     $form_state->setRedirectUrl($this->page->toUrl('edit-form'));
 }
コード例 #6
0
 /**
  * {@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->page->setStaticContext($form_state->getValue('machine_name'), $this->staticContext);
     $this->page->save();
     // Set the submission message.
     drupal_set_message($this->submitMessageText());
     $form_state->setRedirectUrl($this->page->toUrl('edit-form'));
 }
コード例 #7
0
 /**
  * Tests that a user role condition controls the node view page.
  */
 public function testUserRoleAccessCondition()
 {
     $node1 = $this->drupalCreateNode(['type' => 'page']);
     $node2 = $this->drupalCreateNode(['type' => 'article']);
     $this->drupalLogin($this->drupalCreateUser(['access content']));
     $this->drupalGet('node/' . $node1->id());
     $this->assertResponse(200);
     $this->assertText($node1->label());
     $this->assertTitle($node1->label() . ' | Drupal');
     // Add a variant and an access condition.
     /** @var \Drupal\page_manager\Entity\PageVariant $page_variant */
     $page_variant = PageVariant::create(['variant' => 'block_display', 'id' => 'block_page', 'label' => 'Block page', 'page' => $this->page->id()]);
     $page_variant->getVariantPlugin()->setConfiguration(['page_title' => 'The overridden page']);
     $page_variant->save();
     $this->page->addAccessCondition(['id' => 'user_role', 'roles' => [RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID], 'context_mapping' => ['user' => 'current_user']]);
     $this->page->addAccessCondition(['id' => 'node_type', 'bundles' => ['page' => 'page'], 'context_mapping' => ['node' => 'node']]);
     $this->page->save();
     $this->triggerRouterRebuild();
     $this->drupalLogout();
     $this->drupalGet('node/' . $node1->id());
     $this->assertResponse(403);
     $this->assertNoText($node1->label());
     $this->assertTitle('Access denied | Drupal');
     $this->drupalLogin($this->drupalCreateUser());
     $this->drupalGet('node/' . $node1->id());
     $this->assertResponse(403);
     $this->assertNoText($node1->label());
     $this->assertTitle('Access denied | Drupal');
     $this->drupalLogin($this->drupalCreateUser(['access content']));
     $this->drupalGet('node/' . $node1->id());
     $this->assertResponse(200);
     $this->assertNoText($node1->label());
     $this->assertTitle('The overridden page | Drupal');
     $this->drupalGet('node/' . $node2->id());
     $this->assertResponse(403);
     $this->assertNoText($node2->label());
     $this->assertTitle('Access denied | Drupal');
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $this->pageVariant->removeLayoutRegion($this->layoutRegion->id());
     $this->page->save();
     drupal_set_message($this->t('The layout region %name has been removed.', array('%name' => $this->layoutRegion->label())));
     if ($this->getRequest()->isXmlHttpRequest()) {
         $response = new AjaxResponse();
         $response->addCommand(new CloseDialogCommand());
         $response->addCommand(new LayoutReload($this->pageVariant));
         $form_state['response'] = $response;
         return $response;
     }
     $form_state['redirect_route'] = $this->getCancelRoute();
 }
コード例 #9
0
 /**
  * {@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->displayVariant->updateBlock($this->block->getConfiguration()['uuid'], ['region' => $form_state->getValue('region')]);
     $this->page->save();
     $form_state->setRedirect('page_manager.display_variant_edit', ['page' => $this->page->id(), 'display_variant_id' => $this->displayVariant->id()]);
 }
コード例 #10
0
 public function handlePut(PageInterface $page, LayoutPageVariantInterface $page_variant, $data = array())
 {
     foreach ($data['regions'] as $region) {
         foreach ($region['blocks'] as $block_data) {
             $block = $page_variant->getBlock($block_data['id']);
             if ($block) {
                 $configuration = $block->getConfiguration();
                 $configuration['region'] = $region['id'];
                 $configuration['weight'] = $block_data['weight'];
                 $block->setConfiguration($configuration);
             }
         }
     }
     $page->save();
     return new Response('{}', 200, array('Content-Type' => 'application/json'));
 }
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $name = $form_state->getValue('machine_name');
     $type = $form_state->getValue('type');
     if ($type === static::NO_CONTEXT_KEY) {
         $this->page->removeParameter($name);
         $label = NULL;
     } else {
         $label = $form_state->getValue('label');
         $this->page->setParameter($name, $type, $label);
     }
     $this->page->save();
     // Set the submission message.
     drupal_set_message($this->t('The %label parameter has been updated.', ['%label' => $label ?: $name]));
     $form_state->setRedirectUrl($this->page->toUrl('edit-form'));
 }
コード例 #12
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     // Allow the page variant to submit the form.
     $plugin_values = array('values' => &$form_state['values']['plugin']);
     $this->layoutRegion->submitConfigurationForm($form, $plugin_values);
     $this->pageVariant->updateLayoutRegion($this->layoutRegion->id(), array('label' => $this->layoutRegion->label(), 'parent' => $this->layoutRegion->getParentRegionId()));
     $this->page->save();
     if ($this->getRequest()->isXmlHttpRequest()) {
         $response = new AjaxResponse();
         $response->addCommand(new CloseDialogCommand());
         if ($this->getFormId() === 'layout_layout_region_add_form') {
             $response->addCommand(new LayoutReload($this->pageVariant));
         } else {
             $response->addCommand(new LayoutRegionReload($this->pageVariant, $this->layoutRegion));
         }
         $form_state['response'] = $response;
         return $response;
     }
     $form_state['redirect_route'] = new Url('page_manager.display_variant_edit', array('page' => $this->page->id(), 'display_variant_id' => $this->pageVariant->id()));
 }