Skip to content

Commit

Permalink
DDST-382: Code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant-bd committed Jul 29, 2024
1 parent 14fb7a2 commit 272a831
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/Entity/Embargo.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,33 +397,34 @@ public function getCacheMaxAge() {
* {@inheritdoc}
*/
public function getCacheTags() {
if ($this->getEmbargoedNode() !== NULL) {
$tags = Cache::mergeTags(parent::getCacheTags(), $this->getEmbargoedNode()->getCacheTags());
$tags = parent::getCacheTags();
if ($node = $this->getEmbargoedNode()) {
$tags = Cache::mergeTags($tags, $node->getCacheTags());
}

if ($this->getExemptIps()) {
$tags = Cache::mergeTags($tags, $this->getExemptIps()->getCacheTags());
}
return $tags;
if ($this->getExemptIps()) {
$tags = Cache::mergeTags($tags, $this->getExemptIps()->getCacheTags());
}
return $tags;
}

/**
* {@inheritDoc}
*/
public function getCacheContexts() {
if ($this->getEmbargoedNode() !== NULL) {
$contexts = Cache::mergeContexts(
parent::getCacheContexts(),
$this->getEmbargoedNode()->getCacheContexts(),
['user.embargo__has_exemption'],
);

if ($this->getExemptIps()) {
$contexts = Cache::mergeContexts($contexts, $this->getExemptIps()->getCacheContexts());
}

return $contexts;
$contexts = Cache::mergeContexts(
parent::getCacheContexts(),
['user.embargo__has_exemption'],
);
if ($node = $this->getEmbargoedNode()) {
$context = Cache::mergeContexts($contexts, $node->getCacheContexts());
}

if ($this->getExemptIps()) {
$contexts = Cache::mergeContexts($contexts, $this->getExemptIps()->getCacheContexts());
}

return $contexts;
}

/**
Expand All @@ -443,8 +444,8 @@ public function isUserExempt(AccountInterface $user): bool {
$exempt_users = $this->getExemptUsers();
$has_permission = $user->hasPermission('bypass embargo access');
return $has_permission || in_array($user->id(), array_map(function (UserInterface $user) {
return $user->id();
}, $exempt_users));
return $user->id();
}, $exempt_users));
}

/**
Expand Down

0 comments on commit 272a831

Please sign in to comment.