FileInterface.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. namespace Drupal\file;
  3. use Drupal\Core\Entity\ContentEntityInterface;
  4. use Drupal\user\EntityOwnerInterface;
  5. use Drupal\Core\Entity\EntityChangedInterface;
  6. /**
  7. * Defines getter and setter methods for file entity base fields.
  8. *
  9. * @ingroup file
  10. */
  11. interface FileInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
  12. /**
  13. * Returns the name of the file.
  14. *
  15. * This may differ from the basename of the URI if the file is renamed to
  16. * avoid overwriting an existing file.
  17. *
  18. * @return string
  19. * Name of the file.
  20. */
  21. public function getFilename();
  22. /**
  23. * Sets the name of the file.
  24. *
  25. * @param string $filename
  26. * The file name that corresponds to this file. May differ from the basename
  27. * of the URI and changing the filename does not change the URI.
  28. */
  29. public function setFilename($filename);
  30. /**
  31. * Returns the URI of the file.
  32. *
  33. * @return string
  34. * The URI of the file, e.g. public://directory/file.jpg.
  35. */
  36. public function getFileUri();
  37. /**
  38. * Sets the URI of the file.
  39. *
  40. * @param string $uri
  41. * The URI of the file, e.g. public://directory/file.jpg. Does not change
  42. * the location of the file.
  43. */
  44. public function setFileUri($uri);
  45. /**
  46. * Creates a file URL for the URI of this file.
  47. *
  48. * @param bool $relative
  49. * (optional) Whether the URL should be root-relative, defaults to TRUE.
  50. *
  51. * @return string
  52. * A string containing a URL that may be used to access the file.
  53. *
  54. * @see file_create_url()
  55. * @see file_url_transform_relative()
  56. */
  57. public function createFileUrl($relative = TRUE);
  58. /**
  59. * Returns the MIME type of the file.
  60. *
  61. * @return string
  62. * The MIME type of the file, e.g. image/jpeg or text/xml.
  63. */
  64. public function getMimeType();
  65. /**
  66. * Sets the MIME type of the file.
  67. *
  68. * @param string $mime
  69. * The MIME type of the file, e.g. image/jpeg or text/xml.
  70. */
  71. public function setMimeType($mime);
  72. /**
  73. * Returns the size of the file.
  74. *
  75. * @return string
  76. * The size of the file in bytes.
  77. */
  78. public function getSize();
  79. /**
  80. * Sets the size of the file.
  81. *
  82. * @param int $size
  83. * The size of the file in bytes.
  84. */
  85. public function setSize($size);
  86. /**
  87. * Returns TRUE if the file is permanent.
  88. *
  89. * @return bool
  90. * TRUE if the file status is permanent.
  91. */
  92. public function isPermanent();
  93. /**
  94. * Returns TRUE if the file is temporary.
  95. *
  96. * @return bool
  97. * TRUE if the file status is temporary.
  98. */
  99. public function isTemporary();
  100. /**
  101. * Sets the file status to permanent.
  102. */
  103. public function setPermanent();
  104. /**
  105. * Sets the file status to temporary.
  106. */
  107. public function setTemporary();
  108. /**
  109. * Returns the file entity creation timestamp.
  110. *
  111. * @return int
  112. * Creation timestamp of the file entity.
  113. */
  114. public function getCreatedTime();
  115. }