FileInterface.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. * Returns the MIME type of the file.
  47. *
  48. * @return string
  49. * The MIME type of the file, e.g. image/jpeg or text/xml.
  50. */
  51. public function getMimeType();
  52. /**
  53. * Sets the MIME type of the file.
  54. *
  55. * @param string $mime
  56. * The MIME type of the file, e.g. image/jpeg or text/xml.
  57. */
  58. public function setMimeType($mime);
  59. /**
  60. * Returns the size of the file.
  61. *
  62. * @return string
  63. * The size of the file in bytes.
  64. */
  65. public function getSize();
  66. /**
  67. * Sets the size of the file.
  68. *
  69. * @param int $size
  70. * The size of the file in bytes.
  71. */
  72. public function setSize($size);
  73. /**
  74. * Returns TRUE if the file is permanent.
  75. *
  76. * @return bool
  77. * TRUE if the file status is permanent.
  78. */
  79. public function isPermanent();
  80. /**
  81. * Returns TRUE if the file is temporary.
  82. *
  83. * @return bool
  84. * TRUE if the file status is temporary.
  85. */
  86. public function isTemporary();
  87. /**
  88. * Sets the file status to permanent.
  89. */
  90. public function setPermanent();
  91. /**
  92. * Sets the file status to temporary.
  93. */
  94. public function setTemporary();
  95. /**
  96. * Returns the file entity creation timestamp.
  97. *
  98. * @return int
  99. * Creation timestamp of the file entity.
  100. */
  101. public function getCreatedTime();
  102. }