예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->taxonomyTerm->delete();
     drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label())));
     $this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
예제 #2
0
파일: DeleteForm.php 프로젝트: shumer/blog
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $this->taxonomyTerm->delete();
     drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label())));
     watchdog('forum', 'forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()), WATCHDOG_NOTICE);
     $form_state['redirect_route'] = $this->getCancelUrl();
 }
 /**
  * Tests Quick Edit autocomplete term behavior.
  */
 public function testAutocompleteQuickEdit()
 {
     $this->drupalLogin($this->editorUser);
     $quickedit_uri = 'quickedit/form/node/' . $this->node->id() . '/' . $this->fieldName . '/' . $this->node->language()->getId() . '/full';
     $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
     $response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
     $ajax_commands = Json::decode($response);
     // Prepare form values for submission. drupalPostAJAX() is not suitable for
     // handling pages with JSON responses, so we need our own solution here.
     $form_tokens_found = preg_match('/\\sname="form_token" value="([^"]+)"/', $ajax_commands[0]['data'], $token_match) && preg_match('/\\sname="form_build_id" value="([^"]+)"/', $ajax_commands[0]['data'], $build_id_match);
     $this->assertTrue($form_tokens_found, 'Form tokens found in output.');
     if ($form_tokens_found) {
         $post = array('form_id' => 'quickedit_field_form', 'form_token' => $token_match[1], 'form_build_id' => $build_id_match[1], $this->fieldName => implode(', ', array($this->term1->getName(), 'new term', $this->term2->getName())), 'op' => t('Save'));
         // Submit field form and check response. Should render back all the terms.
         $response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
         $this->assertResponse(200);
         $ajax_commands = Json::decode($response);
         $this->setRawContent($ajax_commands[0]['data']);
         $this->assertLink($this->term1->getName());
         $this->assertLink($this->term2->getName());
         $this->assertText('new term');
         $this->assertNoLink('new term');
         // Load the form again, which should now get it back from
         // PrivateTempStore.
         $quickedit_uri = 'quickedit/form/node/' . $this->node->id() . '/' . $this->fieldName . '/' . $this->node->language()->getId() . '/full';
         $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
         $response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
         $ajax_commands = Json::decode($response);
         // The AjaxResponse's first command is an InsertCommand which contains
         // the form to edit the taxonomy term field, it should contain all three
         // taxonomy terms, including the one that has just been newly created and
         // which is not yet stored.
         $this->setRawContent($ajax_commands[0]['data']);
         $this->assertFieldByName($this->fieldName, implode(', ', array($this->term1->getName(), 'new term', $this->term2->label())));
         // Save the entity.
         $post = array('nocssjs' => 'true');
         $response = $this->drupalPost('quickedit/entity/node/' . $this->node->id(), 'application/json', $post);
         $this->assertResponse(200);
         // The full node display should now link to all entities, with the new
         // one created in the database as well.
         $this->drupalGet('node/' . $this->node->id());
         $this->assertLink($this->term1->getName());
         $this->assertLink($this->term2->getName());
         $this->assertLink('new term');
     }
 }
 /**
  * Title callback for term pages.
  *
  * @param \Drupal\taxonomy\TermInterface $term
  *   A taxonomy term entity.
  *
  * @return
  *   The term name to be used as the page title.
  */
 public function getTitle(TermInterface $term)
 {
     return $term->label();
 }