Check the access for the paragraph based on the lockable setting.
Only add content access controls if: Not a view operation Lockable Behavior is enabled Lockable has the locked value set as true.
\Drupal\Core\Entity\EntityInterface $entity: The paragraph entity.
string $operation: The current operation.
\Drupal\Core\Session\AccountInterface $account: The current logged in user.
\Drupal\Core\Access\AccessResult The access result, will be false if the paragraph is locked and the user does not have the appropriate permission.
public static function determineParagraphAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var ParagraphsType $paragraphs_type */
$paragraphs_type = $entity
->getParagraphType();
if ($operation !== 'view' && $entity
->getBehaviorSetting('lockable', 'locked') && $paragraphs_type
->hasEnabledBehaviorPlugin('lockable')) {
$accessResult = AccessResult::forbiddenIf(!$account
->hasPermission('administer lockable paragraph'));
}
else {
$accessResult = AccessResult::neutral();
}
$accessResult
->addCacheableDependency($entity);
$accessResult
->addCacheableDependency($paragraphs_type);
return $accessResult;
}