DomainAccessManagerInterface.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace Drupal\domain_access;
  3. use Drupal\Core\Entity\FieldableEntityInterface;
  4. use Drupal\Core\Field\FieldDefinitionInterface;
  5. use Drupal\Core\Session\AccountInterface;
  6. use Drupal\domain\DomainInterface;
  7. /**
  8. * Checks the access status of entities based on domain settings.
  9. */
  10. interface DomainAccessManagerInterface {
  11. /**
  12. * Get the domain access field values from an entity.
  13. *
  14. * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
  15. * The entity to retrieve field data from.
  16. * @param string $field_name
  17. * The name of the field that holds our data.
  18. *
  19. * @return array
  20. * The domain access field values.
  21. */
  22. public static function getAccessValues(FieldableEntityInterface $entity, $field_name = DOMAIN_ACCESS_FIELD);
  23. /**
  24. * Get the all affiliates field values from an entity.
  25. *
  26. * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
  27. * The entity to retrieve field data from.
  28. *
  29. * @return bool
  30. * Returns TRUE if the entity is sent to all affiliates.
  31. */
  32. public static function getAllValue(FieldableEntityInterface $entity);
  33. /**
  34. * Compare the entity values against a user's account assignments.
  35. *
  36. * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
  37. * The entity being checked for access.
  38. * @param \Drupal\Core\Session\AccountInterface $account
  39. * The account of the user performing the action.
  40. *
  41. * @return bool
  42. * Returns TRUE if the user has access to the domain.
  43. */
  44. public function checkEntityAccess(FieldableEntityInterface $entity, AccountInterface $account);
  45. /**
  46. * Get the default field value for an entity.
  47. *
  48. * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
  49. * The entity being created.
  50. * @param \Drupal\Core\Field\FieldDefinitionInterface $definition
  51. * The field being created.
  52. *
  53. * @return array
  54. * The default field value(s).
  55. */
  56. public static function getDefaultValue(FieldableEntityInterface $entity, FieldDefinitionInterface $definition);
  57. /**
  58. * Checks that a user belongs to the domain and has a set of permissions.
  59. *
  60. * @param \Drupal\Core\Session\AccountInterface $account
  61. * The user account.
  62. * @param \Drupal\domain\DomainInterface $domain
  63. * The domain being checked.
  64. * @param array $permissions
  65. * The relevant permissions to check.
  66. * @param string $conjunction
  67. * The conjunction AND|OR to use when checking permissions.
  68. *
  69. * @return bool
  70. * Returns TRUE if the user is assigned to the domain and has the necessary
  71. * permissions.
  72. */
  73. public function hasDomainPermissions(AccountInterface $account, DomainInterface $domain, array $permissions, $conjunction = 'AND');
  74. /**
  75. * Get all possible URLs pointing to an entity.
  76. *
  77. * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
  78. * The entity to retrieve field data from.
  79. *
  80. * @return array
  81. * An array of absolute URLs keyed by domain_id, with an known canonical id
  82. * as the first element of the array.
  83. */
  84. public function getContentUrls(FieldableEntityInterface $entity);
  85. }