MimeEntity.php 2.8KB

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