MimeEntity.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * A MIME entity, such as an attachment.
  11. *
  12. * @package Swift
  13. * @subpackage Mime
  14. * @author Chris Corbyn
  15. */
  16. interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver
  17. {
  18. /** Main message document; there can only be one of these */
  19. const LEVEL_TOP = 16;
  20. /** An entity which nests with the same precedence as an attachment */
  21. const LEVEL_MIXED = 256;
  22. /** An entity which nests with the same precedence as a mime part */
  23. const LEVEL_ALTERNATIVE = 4096;
  24. /** An entity which nests with the same precedence as embedded content */
  25. const LEVEL_RELATED = 65536;
  26. /**
  27. * Get the level at which this entity shall be nested in final document.
  28. *
  29. * The lower the value, the more outermost the entity will be nested.
  30. * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE
  31. *
  32. * @return int
  33. */
  34. public function getNestingLevel();
  35. /**
  36. * Get the qualified content-type of this mime entity.
  37. * @return string
  38. */
  39. public function getContentType();
  40. /**
  41. * Returns a unique ID for this entity.
  42. *
  43. * For most entities this will likely be the Content-ID, though it has
  44. * no explicit semantic meaning and can be considered an identifier for
  45. * programming logic purposes.
  46. *
  47. * If a Content-ID header is present, this value SHOULD match the value of
  48. * the header.
  49. *
  50. * @return string
  51. */
  52. public function getId();
  53. /**
  54. * Get all children nested inside this entity.
  55. *
  56. * These are not just the immediate children, but all children.
  57. *
  58. * @return Swift_Mime_MimeEntity[]
  59. */
  60. public function getChildren();
  61. /**
  62. * Set all children nested inside this entity.
  63. *
  64. * This includes grandchildren.
  65. *
  66. * @param Swift_Mime_MimeEntity[] $children
  67. */
  68. public function setChildren(array $children);
  69. /**
  70. * Get the collection of Headers in this Mime entity.
  71. *
  72. * @return Swift_Mime_Header[]
  73. */
  74. public function getHeaders();
  75. /**
  76. * Get the body content of this entity as a string.
  77. *
  78. * Returns NULL if no body has been set.
  79. *
  80. * @return string|null
  81. */
  82. public function getBody();
  83. /**
  84. * Set the body content of this entity as a string.
  85. *
  86. * @param string $body
  87. * @param string $contentType optional
  88. */
  89. public function setBody($body, $contentType = null);
  90. /**
  91. * Get this entire entity in its string form.
  92. *
  93. * @return string
  94. */
  95. public function toString();
  96. /**
  97. * Get this entire entity as a ByteStream.
  98. *
  99. * @param Swift_InputByteStream $is to write to
  100. */
  101. public function toByteStream(Swift_InputByteStream $is);
  102. }