NodeAccessControlHandlerInterface.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace Drupal\node;
  3. use Drupal\Core\Session\AccountInterface;
  4. /**
  5. * Node specific entity access control methods.
  6. *
  7. * @ingroup node_access
  8. */
  9. interface NodeAccessControlHandlerInterface {
  10. /**
  11. * Gets the list of node access grants.
  12. *
  13. * This function is called to check the access grants for a node. It collects
  14. * all node access grants for the node from hook_node_access_records()
  15. * implementations, allows these grants to be altered via
  16. * hook_node_access_records_alter() implementations, and returns the grants to
  17. * the caller.
  18. *
  19. * @param \Drupal\node\NodeInterface $node
  20. * The $node to acquire grants for.
  21. *
  22. * @return array
  23. * The access rules for the node.
  24. */
  25. public function acquireGrants(NodeInterface $node);
  26. /**
  27. * Writes a list of grants to the database, deleting any previously saved ones.
  28. *
  29. * Modules that use node access can use this function when doing mass updates
  30. * due to widespread permission changes.
  31. *
  32. * Note: Don't call this function directly from a contributed module. Call
  33. * \Drupal\node\NodeAccessControlHandlerInterface::acquireGrants() instead.
  34. *
  35. * @param \Drupal\node\NodeInterface $node
  36. * The node whose grants are being written.
  37. * @param $delete
  38. * (optional) If false, does not delete records. This is only for optimization
  39. * purposes, and assumes the caller has already performed a mass delete of
  40. * some form. Defaults to TRUE.
  41. *
  42. * @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
  43. * Use \Drupal\node\NodeAccessControlHandlerInterface::acquireGrants().
  44. */
  45. public function writeGrants(NodeInterface $node, $delete = TRUE);
  46. /**
  47. * Creates the default node access grant entry on the grant storage.
  48. */
  49. public function writeDefaultGrant();
  50. /**
  51. * Deletes all node access entries.
  52. */
  53. public function deleteGrants();
  54. /**
  55. * Counts available node grants.
  56. *
  57. * @return int
  58. * Returns the amount of node grants.
  59. */
  60. public function countGrants();
  61. /**
  62. * Checks all grants for a given account.
  63. *
  64. * @param \Drupal\Core\Session\AccountInterface $account
  65. * A user object representing the user for whom the operation is to be
  66. * performed.
  67. *
  68. * @return int
  69. * Status of the access check.
  70. */
  71. public function checkAllGrants(AccountInterface $account);
  72. }