Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $form_state->setRedirect('entity.node.canonical', array('node' => $this->entity->id()));
     $book_link = $form_state->getValue('book');
     if (!$book_link['bid']) {
         drupal_set_message($this->t('No changes were made'));
         return;
     }
     $this->entity->book = $book_link;
     if ($this->bookManager->updateOutline($this->entity)) {
         if (isset($this->entity->book['parent_mismatch']) && $this->entity->book['parent_mismatch']) {
             // This will usually only happen when JS is disabled.
             drupal_set_message($this->t('The post has been added to the selected book. You may now position it relative to other pages.'));
             $form_state->setRedirectUrl($this->entity->urlInfo('book-outline-form'));
         } else {
             drupal_set_message($this->t('The book outline has been updated.'));
         }
     } else {
         drupal_set_message($this->t('There was an error adding the post to the book.'), 'error');
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * @see book_remove_button_submit()
  */
 public function submit(array $form, array &$form_state)
 {
     $form_state['redirect_route'] = array('route_name' => 'node.view', 'route_parameters' => array('node' => $this->entity->id()));
     $book_link = $form_state['values']['book'];
     if (!$book_link['bid']) {
         drupal_set_message($this->t('No changes were made'));
         return;
     }
     $this->entity->book = $book_link;
     if ($this->bookManager->updateOutline($this->entity)) {
         if (isset($this->entity->book['parent_mismatch']) && $this->entity->book['parent_mismatch']) {
             // This will usually only happen when JS is disabled.
             drupal_set_message($this->t('The post has been added to the selected book. You may now position it relative to other pages.'));
             $form_state['redirect_route'] = $this->entity->urlInfo('book-outline-form');
         } else {
             drupal_set_message($this->t('The book outline has been updated.'));
         }
     } else {
         drupal_set_message($this->t('There was an error adding the post to the book.'), 'error');
     }
 }