Loading src/Controller/EntityComparisonController.php +19 −3 Original line number Diff line number Diff line Loading @@ -165,8 +165,15 @@ class EntityComparisonController extends ControllerBase implements ContainerInje // Create a new AJAX response. $response = new AjaxResponse(); // Generate the link render array. $link = $entity_comparison->getLink($entity_id, TRUE); $link = $link->toRenderable(); $link = [ '#theme' => 'entity_comparison_link', '#id' => $entity_id, '#entity_comparison' => $entity_comparison_id, '#cache' => [ 'max-age' => 0, ], '#access' => $this->currentUser()->hasPermission("use {$entity_comparison_id} entity comparison"), ]; // Generate a CSS selector to use in a JQuery Replace command. $selector = '[data-entity-comparison=' . $entity_comparison->id() . '-' . $entity_id . ']'; Loading Loading @@ -376,7 +383,16 @@ class EntityComparisonController extends ControllerBase implements ContainerInje // Add the first row, where the user can remove the selected content. $row = [$this->t('Remove from the list')]; foreach (Element::children($comparison_fields) as $key) { $row[] = $entity_comparison->getLink($key, TRUE)->toString(); $link = [ '#theme' => 'entity_comparison_link', '#id' => $key, '#entity_comparison' => $entity_comparison_id, '#cache' => [ 'max-age' => 0, ], '#access' => $this->currentUser()->hasPermission("use {$entity_comparison_id} entity comparison"), ]; $row[] = $this->renderer->render($link); } $rows[] = $row; Loading src/Plugin/Block/EntityComparisonLinkBlock.php +10 −6 Original line number Diff line number Diff line Loading @@ -115,15 +115,19 @@ class EntityComparisonLinkBlock extends BlockBase implements ContainerFactoryPlu $node = \Drupal::routeMatch()->getParameter('node'); if ($node instanceof NodeInterface) { // You can get nid and anything else you need from the node object. $nid = $node->id(); /** * @var \Drupal\Core\Link $link */ $link = $entity_comparison->getLink($nid, TRUE); return [ '#theme' => 'entity_comparison_link', '#id' => $node->id(), '#entity_comparison' => $entity_comparison_id, '#cache' => [ 'max-age' => 0, ], '#access' => \Drupal::currentUser()->hasPermission("use {$entity_comparison_id} entity comparison"), ]; } return [ '#markup' => (isset($link)) ? $link->toString() : $entity_comparison->getAddLinkText(), '#markup' => $entity_comparison->getAddLinkText(), '#cache' => [ 'max-age' => 0, ], Loading Loading
src/Controller/EntityComparisonController.php +19 −3 Original line number Diff line number Diff line Loading @@ -165,8 +165,15 @@ class EntityComparisonController extends ControllerBase implements ContainerInje // Create a new AJAX response. $response = new AjaxResponse(); // Generate the link render array. $link = $entity_comparison->getLink($entity_id, TRUE); $link = $link->toRenderable(); $link = [ '#theme' => 'entity_comparison_link', '#id' => $entity_id, '#entity_comparison' => $entity_comparison_id, '#cache' => [ 'max-age' => 0, ], '#access' => $this->currentUser()->hasPermission("use {$entity_comparison_id} entity comparison"), ]; // Generate a CSS selector to use in a JQuery Replace command. $selector = '[data-entity-comparison=' . $entity_comparison->id() . '-' . $entity_id . ']'; Loading Loading @@ -376,7 +383,16 @@ class EntityComparisonController extends ControllerBase implements ContainerInje // Add the first row, where the user can remove the selected content. $row = [$this->t('Remove from the list')]; foreach (Element::children($comparison_fields) as $key) { $row[] = $entity_comparison->getLink($key, TRUE)->toString(); $link = [ '#theme' => 'entity_comparison_link', '#id' => $key, '#entity_comparison' => $entity_comparison_id, '#cache' => [ 'max-age' => 0, ], '#access' => $this->currentUser()->hasPermission("use {$entity_comparison_id} entity comparison"), ]; $row[] = $this->renderer->render($link); } $rows[] = $row; Loading
src/Plugin/Block/EntityComparisonLinkBlock.php +10 −6 Original line number Diff line number Diff line Loading @@ -115,15 +115,19 @@ class EntityComparisonLinkBlock extends BlockBase implements ContainerFactoryPlu $node = \Drupal::routeMatch()->getParameter('node'); if ($node instanceof NodeInterface) { // You can get nid and anything else you need from the node object. $nid = $node->id(); /** * @var \Drupal\Core\Link $link */ $link = $entity_comparison->getLink($nid, TRUE); return [ '#theme' => 'entity_comparison_link', '#id' => $node->id(), '#entity_comparison' => $entity_comparison_id, '#cache' => [ 'max-age' => 0, ], '#access' => \Drupal::currentUser()->hasPermission("use {$entity_comparison_id} entity comparison"), ]; } return [ '#markup' => (isset($link)) ? $link->toString() : $entity_comparison->getAddLinkText(), '#markup' => $entity_comparison->getAddLinkText(), '#cache' => [ 'max-age' => 0, ], Loading