Esempio n. 1
0
 public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL)
 {
     // Redirect to the edit path on the discussion type
     if ($node->getType() == 'discussion') {
         $url = Url::fromRoute('entity.node.ahs_discuss', ['node' => $node->id()]);
         return \Drupal::service('entity.form_builder')->getForm($node, 'ahs_discuss');
         //return new RedirectResponse($url->toString());
     } else {
         return parent::view($node, $view_mode, $langcode);
     }
 }
Esempio n. 2
0
 public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL)
 {
     // Redirect the discussion type
     if ($node->getType() == 'discussion') {
         $user = $this->currentUser->id();
         $participants = array_column($node->field_participants->getValue(), 'target_id');
         // If it is a private discussion & the user is not a participant, block access.
         if ($node->field_private->value && !in_array($user, $participants)) {
             //$url = Url::fromRoute('entity.node.ahs_discuss', ['node' => $node->id()]);
             //return new RedirectResponse($url->toString());
             drupal_set_message(t('Sorry, this discussion is private and you are not listed as a participant.'), 'warning');
             return array();
         } else {
             return \Drupal::service('entity.form_builder')->getForm($node, 'ahs_discuss');
         }
     } else {
         return parent::view($node, $view_mode, $langcode);
     }
 }
Esempio n. 3
0
 /**
  * Displays a node revision.
  *
  * @param int $node_revision
  *   The node revision ID.
  *
  * @return array
  *   An array suitable for drupal_render().
  */
 public function revisionShow($node_revision)
 {
     $node = $this->entityManager()->getStorage('node')->loadRevision($node_revision);
     $node_view_controller = new NodeViewController($this->entityManager, $this->renderer);
     $page = $node_view_controller->view($node);
     unset($page['nodes'][$node->id()]['#cache']);
     return $page;
 }