Skip to content

Commit

Permalink
feat(YSP-672): bulk operation depends on ai_engine permission level
Browse files Browse the repository at this point in the history
  • Loading branch information
dblanken-yale committed Oct 8, 2024
1 parent df00a1f commit 2791996
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions modules/ai_engine_metadata/src/Plugin/Action/DisableAi.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ final class DisableAi extends ActionBase {

const METATAG_FIELD_NAME = 'ai_disable_indexing';
const ACTION_VALUE = 'disabled';
const MANAGE_AI_PERMISSION = 'manage ai engine settings';

/**
* {@inheritdoc}
*/
public function access($entity, ?AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$access = $entity->access('update', $account, TRUE);
/*->andIf($entity->metatag->ai_disable_indexing->access('edit', $account, TRUE));*/
$access = $entity->access('update', $account, TRUE)
->andIf($account->hasPermission(self::MANAGE_AI_PERMISSION));
return $return_as_object ? $access : $access->isAllowed();
}

Expand Down
5 changes: 3 additions & 2 deletions modules/ai_engine_metadata/src/Plugin/Action/EnableAi.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
final class EnableAi extends ActionBase {
const METATAG_FIELD_NAME = 'ai_disable_indexing';
const ACTION_VALUE = '';
const MANAGE_AI_PERMISSION = 'manage ai engine settings';

/**
* {@inheritdoc}
*/
public function access($entity, ?AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$access = $entity->access('update', $account, TRUE);
/*->andIf($entity->metatag->ai_disable_indexing->access('edit', $account, TRUE));*/
$access = $entity->access('update', $account, TRUE)
->andIf($account->hasPermission(self::MANAGE_AI_PERMISSION));
return $return_as_object ? $access : $access->isAllowed();
}

Expand Down

0 comments on commit 2791996

Please sign in to comment.