コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $tempstore_id = NULL, $machine_name = NULL, $context_id = NULL)
 {
     $this->tempstore_id = $tempstore_id;
     $this->machine_name = $machine_name;
     $this->context_id = $context_id;
     return parent::buildForm($form, $form_state);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL, $fid = NULL, $pfid = NULL)
 {
     $this->node = $node;
     $this->featureId = $fid;
     $this->feature = uc_product_feature_load($pfid);
     return parent::buildForm($form, $form_state);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $actions = NULL)
 {
     $cart_links_config = $this->config('uc_cart_links.settings');
     $this->actions = $actions;
     // Fail if the link is restricted.
     $data = $cart_links_config->get('restrictions');
     if (!empty($data)) {
         $restrictions = explode("\n", $cart_links_config->get('restrictions'));
         $restrictions = array_map('trim', $restrictions);
         if (!empty($restrictions) && !in_array($this->actions, $restrictions)) {
             unset($_GET['destination']);
             $path = $cart_links_config->get('invalid_page');
             if (empty($path)) {
                 return $this->redirect('<front>', [], ['absolute' => TRUE]);
             }
             return new RedirectResponse(Url::fromUri('internal:/' . $path, ['absolute' => TRUE])->toString());
         }
     }
     // Confirm with the user if the form contains a destructive action.
     $cart = Cart::create(\Drupal::getContainer());
     $items = $cart->getContents();
     if ($cart_links_config->get('empty') && !empty($items)) {
         $actions = explode('-', urldecode($this->actions));
         foreach ($actions as $action) {
             $action = Unicode::substr($action, 0, 1);
             if ($action == 'e' || $action == 'E') {
                 $form = parent::buildForm($form, $form_state);
                 $form['actions']['cancel']['#href'] = $cart_links_config->get('invalid_page');
                 return $form;
             }
         }
     }
     // No destructive actions, so process the link immediately.
     return $this->submitForm($form, $form_state);
 }
コード例 #4
0
ファイル: BanDelete.php プロジェクト: papillon-cendre/d8
 /**
  * {@inheritdoc}
  *
  * @param string $ban_id
  *   The IP address record ID to unban.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $ban_id = '')
 {
     if (!($this->banIp = $this->ipManager->findById($ban_id))) {
         throw new NotFoundHttpException();
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $results = $_POST;
     $form['method'] = array('#type' => 'hidden', '#value' => $results['method']);
     if (!isset($results['reset'])) {
         $results['reset'] = 0;
     }
     $form['all'] = array('#type' => 'hidden', '#value' => $results['all']);
     if (isset($results['all'])) {
         // Only carry reset value through if delete all nodes is set
         $form['reset'] = array('#type' => 'hidden', '#value' => $results['reset']);
         $form['all_warning'] = array('#markup' => '<p>' . $this->t('All content in all content types will be deleted. Be sure to have a backup of any important data!') . '</p>');
         if (!empty($results['reset'])) {
             if ($results['all']) {
                 $form['all_reset'] = array('#markup' => '<p>' . $this->t('Node, revision and comment counts will be reset.') . '</p>');
             }
         }
     } elseif (isset($results['types'])) {
         if (is_array($results['types'])) {
             foreach ($results['types'] as $key_type => $type) {
                 /**
                  * @TODO, if we use the form array the value doesn't exist in the submit
                  */
                 $_SESSION['nodes_type'][$key_type] = $type;
                 $info = node_type_get_types('type', $type);
                 $info = $info[$type];
                 $form[$type . '_warning'] = array('#markup' => '<p>' . $this->t('All content in the %type content type will be deleted. Be sure to have a backup of any important data!', array('%type' => $info->get('name'))) . '</p>');
             }
         }
         if ($results['reset']) {
             $form['all_reset'] = array('#markup' => '<p>' . $this->t('Sorry, we can\'t reset the counters because you are not deleting all nodes.') . '</p>');
         }
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL, $component = NULL)
 {
     $this->node = $node;
     // @todo $component should be a fully loaded object, need to make our own ParamConverterInterface.
     $this->component = isset($node->webform['components'][$component]) ? $node->webform['components'][$component] : FALSE;
     return parent::buildForm($form, $form_state);
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $display_variant_id = NULL, $condition_id = NULL)
 {
     $this->page = $page;
     $this->displayVariant = $this->page->getVariant($display_variant_id);
     $this->selectionCondition = $this->displayVariant->getSelectionCondition($condition_id);
     return parent::buildForm($form, $form_state);
 }
コード例 #8
0
 /**
  * Request new hash form.
  *
  * @param $key
  *   The mail key to be sent.
  * @param $context
  *   Necessary context to send the mail. Must at least include the simplenews
  *   subscriber.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $key = '', $context = array())
 {
     $form = parent::buildForm($form, $form_state);
     $form_state->set('key', $key);
     $form_state->set('context', $context);
     return $form;
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $display_variant_id = NULL, $block_id = NULL)
 {
     $this->page = $page;
     $this->displayVariant = $this->page->getVariant($display_variant_id);
     $this->block = $this->displayVariant->getBlock($block_id);
     return parent::buildForm($form, $form_state);
 }
コード例 #10
0
 /**
  * Builds the form array.
  *
  * Note that when adding arguments to buildForm(), you need to give
  * them default values, to avoid PHP errors.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $id = '')
 {
     // Sanitize and save the ID.
     $id = (int) $id;
     $this->to_delete_id = $id;
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, $browser_langcode = NULL)
 {
     $this->browserLangcode = $browser_langcode;
     $form = parent::buildForm($form, $form_state);
     // @todo Convert to getCancelRoute() after http://drupal.org/node/2082071.
     $form['actions']['cancel']['#href'] = 'admin/config/regional/language/detection/browser';
     return $form;
 }
コード例 #12
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state,
                            FlagInterface $flag = NULL, $entity_id = NULL) {

    $this->flag = $flag;
    $flag_service = \Drupal::service('flag');
    $this->entity = $flag_service->getFlaggableById($this->flag, $entity_id);
    return parent::buildForm($form, $form_state);
  }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $mail = '', NewsletterInterface $newsletter = NULL)
 {
     $form = parent::buildForm($form, $form_state);
     $form['question'] = array('#markup' => '<p>' . t('Are you sure you want to add %user to the %newsletter mailing list?', array('%user' => simplenews_mask_mail($mail), '%newsletter' => $newsletter->name)) . "<p>\n");
     $form['mail'] = array('#type' => 'value', '#value' => $mail);
     $form['newsletter'] = array('#type' => 'value', '#value' => $newsletter);
     return $form;
 }
コード例 #14
0
ファイル: DeleteForm.php プロジェクト: alnutile/drunatra
 /**
  * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm().
  */
 public function buildForm(array $form, array &$form_state, $pid = NULL)
 {
     $this->pathAlias = $this->aliasStorage->load(array('pid' => $pid));
     $form = parent::buildForm($form, $form_state);
     // @todo Convert to getCancelRoute() after http://drupal.org/node/1987802.
     $form['actions']['cancel']['#href'] = 'admin/config/search/path';
     return $form;
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL, $payment = NULL)
 {
     $this->payment = uc_payment_load($payment);
     // Make sure the payment is for the specified order.
     if ($this->payment->order_id != $uc_order->id()) {
         throw new NotFoundHttpException();
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #16
0
 /**
  * {@inheritdoc}
  *
  * @param int $id
  *   (optional) The ID of the item to be deleted.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $file = '') {
   // @todo update access!
   $this->id = $file;
   if (!$this->id) {
     throw new NotFoundHttpException();
   }
   // @todo set album type?
   return parent::buildForm($form, $form_state);
 }
コード例 #17
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, RdfInterface $rdf_entity = NULL)
 {
     // Store the collection on the object so it can be reused.
     $this->collection = $rdf_entity;
     $form = parent::buildForm($form, $form_state);
     // Hide the Cancel link when the form is displayed in a modal. The close
     // button should be used instead.
     $form['actions']['cancel']['#access'] = !$this->isModal();
     return $form;
 }
コード例 #18
0
ファイル: DeleteForm.php プロジェクト: eloiv/botafoc.cat
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, ProfileInterface $linkit_profile = NULL, $plugin_instance_id = NULL) {
    $this->linkitProfile = $linkit_profile;

    if (!$this->linkitProfile->getAttributes()->has($plugin_instance_id)) {
      throw new NotFoundHttpException();
    }

    $this->linkitAttribute = $this->linkitProfile->getAttribute($plugin_instance_id);
    return parent::buildForm($form, $form_state);
  }
コード例 #19
0
 /**
  * @param array $form
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  * @param null $backup_migrate_destination
  * @param null $backup_id
  * @return array
  */
 public function buildForm(array $form, FormStateInterface $form_state, $backup_migrate_destination = NULL, $backup_id = NULL)
 {
     $this->destination = $backup_migrate_destination;
     $this->backup_id = $backup_id;
     $bam = backup_migrate_get_service_object();
     $form['source_id'] = DrupalConfigHelper::getPluginSelector($bam->sources(), $this->t('Restore To'));
     $conf_schema = $bam->plugins()->map('configSchema', array('operation' => 'restore'));
     $form += DrupalConfigHelper::buildFormFromSchema($conf_schema, $bam->plugins()->config());
     return parent::buildForm($form, $form_state);
 }
コード例 #20
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, SubscriberInterface $subscriber = NULL)
 {
     $form = parent::buildForm($form, $form_state);
     $form['question'] = array('#markup' => '<p>' . t('Are you sure you want to confirm the following subscription changes for %user?', array('%user' => simplenews_mask_mail($subscriber->getMail()))) . "<p>\n");
     /** @var \Drupal\simplenews\Subscription\SubscriptionManagerInterface $subscription_manager */
     $subscription_manager = \Drupal::service('simplenews.subscription_manager');
     $form['changes'] = array('#theme' => 'item_list', '#items' => $subscription_manager->getChangesList($subscriber));
     $form['subscriber'] = array('#type' => 'value', '#value' => $subscriber);
     return $form;
 }
コード例 #21
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     // Remove the cancel button if this is an AJAX request since Drupals built
     // in modal dialogues does not handle buttons that are not a primary
     // button very well.
     if ($this->getRequest()->isXmlHttpRequest()) {
         unset($form['actions']['cancel']);
     }
     return $form;
 }
コード例 #22
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $user = NULL, $role = NULL)
 {
     $expiration = db_query('SELECT expiration FROM {uc_roles_expirations} WHERE uid = :uid AND rid = :rid', [':uid' => $user->id(), ':rid' => $role])->fetchField();
     if ($expiration) {
         $role_name = _uc_role_get_name($role);
         $form['user'] = array('#type' => 'value', '#value' => $user->getUsername());
         $form['uid'] = array('#type' => 'value', '#value' => $user->id());
         $form['role'] = array('#type' => 'value', '#value' => $role_name);
         $form['rid'] = array('#type' => 'value', '#value' => $role);
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #23
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, PageInterface $page = NULL, $page_variant_id = NULL, $layout_region_id = NULL, $block_id = NULL)
 {
     $this->page = $page;
     $this->displayVariant = $this->page->getVariant($page_variant_id);
     $this->displayVariant->init($this->page->getExecutable());
     $this->block = $this->displayVariant->getBlock($block_id);
     $form = parent::buildForm($form, $form_state, $page, $page_variant_id, $layout_region_id, $block_id);
     if ($this->getRequest()->isXmlHttpRequest()) {
         $form['actions']['submit']['#ajax'] = array('callback' => array($this, 'submitForm'));
     }
     return $form;
 }
コード例 #24
0
 public function buildForm(array $form, FormStateInterface $form_state, $field_group_name = NULL, $entity_type_id = NULL, $bundle = NULL, $context = NULL)
 {
     if ($context == 'form') {
         $mode = $this->getRequest()->attributes->get('form_mode_name');
     } else {
         $mode = $this->getRequest()->attributes->get('view_mode_name');
     }
     if (empty($mode)) {
         $mode = 'default';
     }
     $this->fieldGroup = field_group_load_field_group($field_group_name, $entity_type_id, $bundle, $context, $mode);
     return parent::buildForm($form, $form_state);
 }
コード例 #25
0
ファイル: BlockDeleteForm.php プロジェクト: oddhill/mega_menu
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, MegaMenuInterface $mega_menu = NULL, $block_id = NULL)
 {
     $form_state->set('link', $request->query->get('link'));
     $this->megaMenu = $mega_menu;
     $this->block = $this->megaMenu->getBlock($form_state->get('link'), $block_id);
     $form = parent::buildForm($form, $form_state);
     // Remove the cancel button if this is an AJAX request since Drupals built
     // in modal dialogues does not handle buttons that are not a primary
     // button very well.
     if ($this->getRequest()->isXmlHttpRequest()) {
         unset($form['actions']['cancel']);
     }
     return $form;
 }
コード例 #26
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $entry_id = NULL)
 {
     try {
         $this->entry = BlacklistStorage::getEntry($entry_id);
     } catch (\Exception $e) {
         drupal_set_message(t('There was an error loading the entry to delete.'));
         return array();
     }
     if (empty($this->entry)) {
         drupal_set_message(t('There was an error loading the entry to delete.'));
         return array();
     }
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $link = '')
 {
     $query = db_select('xmlsitemap');
     $query->fields('xmlsitemap');
     $query->condition('type', 'custom');
     $query->condition('id', $link);
     $result = $query->execute();
     $link = $result->fetchAssoc();
     if (!$link) {
         drupal_set_message(t('No valid custom link specified.'), 'error');
         return new RedirectResponse('/admin/config/search/xmlsitemap/custom/');
     } else {
         $this->custom_link = $link;
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #28
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     // Retrieve the list of modules from the key value store.
     $account = $this->currentUser()->id();
     $this->modules = $this->keyValueExpirable->get($account);
     // Prevent this page from showing when the module list is empty.
     if (empty($this->modules)) {
         return new RedirectResponse('/admin/modules/uninstall');
     }
     $data = system_rebuild_module_data();
     $form['text']['#markup'] = '<p>' . $this->t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>';
     $form['modules'] = array('#theme' => 'item_list', '#items' => array_map(function ($module) use($data) {
         return $data[$module]->info['name'];
     }, $this->modules));
     $form['entities'] = array('#type' => 'details', '#title' => $this->t('Configuration deletions'), '#description' => $this->t('The listed configuration will be deleted.'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#access' => FALSE);
     // Get the dependent entities.
     $entity_types = array();
     $dependent_entities = $this->configManager->findConfigEntityDependentsAsEntities('module', $this->modules);
     foreach ($dependent_entities as $entity) {
         $entity_type_id = $entity->getEntityTypeId();
         if (!isset($form['entities'][$entity_type_id])) {
             $entity_type = $this->entityManager->getDefinition($entity_type_id);
             // Store the ID and label to sort the entity types and entities later.
             $label = $entity_type->getLabel();
             $entity_types[$entity_type_id] = $label;
             $form['entities'][$entity_type_id] = array('#theme' => 'item_list', '#title' => $label, '#items' => array());
         }
         $form['entities'][$entity_type_id]['#items'][] = $entity->label();
     }
     if (!empty($dependent_entities)) {
         $form['entities']['#access'] = TRUE;
         // Add a weight key to the entity type sections.
         asort($entity_types, SORT_FLAG_CASE);
         $weight = 0;
         foreach ($entity_types as $entity_type_id => $label) {
             $form['entities'][$entity_type_id]['#weight'] = $weight;
             // Sort the list of entity labels alphabetically.
             sort($form['entities'][$entity_type_id]['#items'], SORT_FLAG_CASE);
             $weight++;
         }
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #29
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $this->profiles = $this->privateTempStoreFactory->get('profile_multiple_delete_confirm')->get(\Drupal::currentUser()->id());
     if (empty($this->profiles)) {
         return new RedirectResponse(\Drupal::url('admin/config/people/profiles', ['absolute' => TRUE]));
     }
     $form['profiles'] = ['#theme' => 'item_list', '#items' => array_map(function ($profile) {
         return $profile->label();
     }, $this->profiles)];
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
コード例 #30
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, $node_revision = NULL)
 {
     $this->revision = $this->nodeStorage->loadRevision($node_revision);
     $form = parent::buildForm($form, $form_state);
     // @todo Convert to getCancelRoute() after http://drupal.org/node/1863906.
     $form['actions']['cancel']['#href'] = 'node/' . $this->revision->id() . '/revisions';
     return $form;
 }