File.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAVACL\FS;
  4. use Sabre\DAV\FSExt\File as BaseFile;
  5. use Sabre\DAVACL\ACLTrait;
  6. use Sabre\DAVACL\IACL;
  7. /**
  8. * This is an ACL-enabled file node.
  9. *
  10. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  11. * @author Evert Pot (http://evertpot.com/)
  12. * @license http://sabre.io/license/ Modified BSD License
  13. */
  14. class File extends BaseFile implements IACL
  15. {
  16. use ACLTrait;
  17. /**
  18. * A list of ACL rules.
  19. *
  20. * @var array
  21. */
  22. protected $acl;
  23. /**
  24. * Owner uri, or null for no owner.
  25. *
  26. * @var string|null
  27. */
  28. protected $owner;
  29. /**
  30. * Constructor.
  31. *
  32. * @param string $path on-disk path
  33. * @param array $acl ACL rules
  34. * @param string|null $owner principal owner string
  35. */
  36. public function __construct($path, array $acl, $owner = null)
  37. {
  38. parent::__construct($path);
  39. $this->acl = $acl;
  40. $this->owner = $owner;
  41. }
  42. /**
  43. * Returns the owner principal.
  44. *
  45. * This must be a url to a principal, or null if there's no owner
  46. *
  47. * @return string|null
  48. */
  49. public function getOwner()
  50. {
  51. return $this->owner;
  52. }
  53. /**
  54. * Returns a list of ACE's for this node.
  55. *
  56. * Each ACE has the following properties:
  57. * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  58. * currently the only supported privileges
  59. * * 'principal', a url to the principal who owns the node
  60. * * 'protected' (optional), indicating that this ACE is not allowed to
  61. * be updated.
  62. *
  63. * @return array
  64. */
  65. public function getACL()
  66. {
  67. return $this->acl;
  68. }
  69. }