/**
  * {@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());
 }
Ejemplo n.º 2
0
 /**
  * Implements \Drupal\Core\Form\FormInterface::submitForm().
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $this->condition->submitConfigurationForm($form, $form_state);
     $config = $this->condition->getConfig();
     $bundles = implode(' and ', $config['bundles']);
     drupal_set_message(t('The bundles are @bundles', array('@bundles' => $bundles)));
     $article = node_load(1);
     $this->condition->setContextValue('node', $article);
     if ($this->condition->execute()) {
         drupal_set_message(t('Executed successfully.'));
     }
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Allow the condition to submit the form.
     $condition_values = (new FormState())->setValues($form_state->getValue('condition'));
     $this->condition->submitConfigurationForm($form, $condition_values);
     // Update the original form values.
     $form_state->setValue('condition', $condition_values->getValues());
     if ($this->condition instanceof ContextAwarePluginInterface) {
         $this->condition->setContextMapping($condition_values->getValue('context_mapping', []));
     }
     // Set the submission message.
     drupal_set_message($this->submitMessageText());
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->condition->submitConfigurationForm($form, $form_state);
     $config = $this->condition->getConfig();
     foreach ($config['bundles'] as $bundle) {
         drupal_set_message('Bundle: ' . $bundle);
     }
     $article = Node::load(1);
     $this->condition->setContextValue('node', $article);
     if ($this->condition->execute()) {
         drupal_set_message(t('Executed successfully.'));
     }
 }
Ejemplo n.º 5
0
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Allow the condition to submit the form.
    $condition_values = (new FormState())->setValues($form_state->getValue('condition'));
    $this->condition->submitConfigurationForm($form, $condition_values);
    // Update the original form values.
    $form_state->setValue('condition', $condition_values->getValues());

    if ($this->condition instanceof ContextAwarePluginInterface) {
      $this->condition->setContextMapping($condition_values->getValue('context_mapping', []));
    }

    // Set the submission message.
    drupal_set_message($this->submitMessageText());

    $configuration = $this->condition->getConfiguration();
    // If this condition is new, add it to the block_visibility_group.
    if (!isset($configuration['uuid'])) {
      $this->block_visibility_group->addCondition($configuration);
    }

    // Save the block_visibility_group entity.
    $this->block_visibility_group->save();

    $this->setConditionRedirect($form_state);

  }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state) {
   $this->block_visibility_group->removeCondition($this->condition->getConfiguration()['uuid']);
   $this->block_visibility_group->save();
   drupal_set_message($this->t('The condition %name has been removed.', ['%name' => $this->condition->getPluginDefinition()['label']]));
   $this->setConditionRedirect($form_state);
 }