From 47ba1638d00077a1b99a328ae12a4d672cbdae98 Mon Sep 17 00:00:00 2001 From: qadan Date: Fri, 31 Jul 2020 13:52:31 -0300 Subject: [PATCH] cache tag all the things also fixes --- src/Access/EmbargoedAccessResult.php | 2 +- .../EmbargoesNodeEmbargoesController.php | 4 +++- .../Block/EmbargoesEmbargoPoliciesBlock.php | 19 ++++++------------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Access/EmbargoedAccessResult.php b/src/Access/EmbargoedAccessResult.php index 644a21e..f95eb74 100644 --- a/src/Access/EmbargoedAccessResult.php +++ b/src/Access/EmbargoedAccessResult.php @@ -145,7 +145,7 @@ public function setEmbargoMessage(EntityInterface $entity) { $expiration_date = $expiration ? $embargo->getExpirationDate() : ''; $args = [ '%date' => $expiration_date, - '%ip_range' => $ip_range->label(), + '%ip_range' => $ip_range ? $ip_range->label() : '', ]; // Determine a message to set. if (!$type && is_null($ip_range) && !$expiration) { diff --git a/src/Controller/EmbargoesNodeEmbargoesController.php b/src/Controller/EmbargoesNodeEmbargoesController.php index 3c8c657..2226005 100644 --- a/src/Controller/EmbargoesNodeEmbargoesController.php +++ b/src/Controller/EmbargoesNodeEmbargoesController.php @@ -107,7 +107,9 @@ public function showEmbargoes(NodeInterface $node = NULL) { } $formatted_emails = [ - '#markup' => implode('
', $embargo->getAdditionalEmails()), + 'data' => [ + '#markup' => implode('
', $embargo->getAdditionalEmails()), + ], ]; $row = [ diff --git a/src/Plugin/Block/EmbargoesEmbargoPoliciesBlock.php b/src/Plugin/Block/EmbargoesEmbargoPoliciesBlock.php index c71c628..78f364c 100644 --- a/src/Plugin/Block/EmbargoesEmbargoPoliciesBlock.php +++ b/src/Plugin/Block/EmbargoesEmbargoPoliciesBlock.php @@ -72,7 +72,7 @@ public static function create(ContainerInterface $container, array $configuratio * An entity type manager. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, ResettableStackedRouteMatchInterface $route_match, EmbargoesEmbargoesServiceInterface $embargoes, EntityTypeManagerInterface $entity_manager) { - parent::construct($configuration, $plugin_id, $plugin_definition); + parent::__construct($configuration, $plugin_id, $plugin_definition); $this->routeMatch = $route_match; $this->embargoes = $embargoes; $this->entityManager = $entity_manager; @@ -103,7 +103,7 @@ public function build() { $embargo_info['expiration'] = $t->translate('Duration: Indefinite'); } else { - $embargo_info['expiration'] = $t->translate('Duration: @duration', [ + $embargo_info['expiration'] = $t->translate('Duration: Until @duration', [ '@duration' => $embargo->getExpirationDate(), ]); } @@ -115,7 +115,7 @@ public function build() { $embargo_info['type'] = $t->translate('Disallow Access To: Resource'); } // Exempt IP string. - if (is_null($embargo->getExemptIps())) { + if (!($embargo->getExemptIps())) { $embargo_info['exempt_ips'] = ''; } else { @@ -129,12 +129,12 @@ public function build() { } return [ - '#theme' => 'embargo_policies', + '#theme' => 'embargoes_policies', '#count' => $embargoes_count, - '#embargo_info' => $embargo_info, + '#embargo_info' => $embargoes_info, '#cache' => [ 'tags' => $cache_tags, - ]; + ], ]; } } @@ -142,11 +142,4 @@ public function build() { return []; } - /** - * {@inheritdoc} - */ - public function getCacheMaxAge() { - return 0; - } - }