MimeEntity.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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
  16. 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. * The lower the value, the more outermost the entity will be nested.
  29. * @return int
  30. * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE
  31. */
  32. public function getNestingLevel();
  33. /**
  34. * Get the qualified content-type of this mime entity.
  35. * @return string
  36. */
  37. public function getContentType();
  38. /**
  39. * Returns a unique ID for this entity.
  40. * For most entities this will likely be the Content-ID, though it has
  41. * no explicit semantic meaning and can be considered an identifier for
  42. * programming logic purposes.
  43. * If a Content-ID header is present, this value SHOULD match the value of
  44. * the header.
  45. * @return string
  46. */
  47. public function getId();
  48. /**
  49. * Get all children nested inside this entity.
  50. * These are not just the immediate children, but all children.
  51. * @return Swift_Mime_MimeEntity[]
  52. */
  53. public function getChildren();
  54. /**
  55. * Set all children nested inside this entity.
  56. * This includes grandchildren.
  57. * @param Swift_Mime_MimeEntity[] $children
  58. */
  59. public function setChildren(array $children);
  60. /**
  61. * Get the collection of Headers in this Mime entity.
  62. * @return Swift_Mime_Header[]
  63. */
  64. public function getHeaders();
  65. /**
  66. * Get the body content of this entity as a string.
  67. * Returns NULL if no body has been set.
  68. * @return string
  69. */
  70. public function getBody();
  71. /**
  72. * Set the body content of this entity as a string.
  73. * @param string $body
  74. * @param string $contentType optional
  75. */
  76. public function setBody($body, $contentType = null);
  77. /**
  78. * Get this entire entity in its string form.
  79. * @return string
  80. */
  81. public function toString();
  82. /**
  83. * Get this entire entity as a ByteStream.
  84. * @param Swift_InputByteStream $is to write to
  85. */
  86. public function toByteStream(Swift_InputByteStream $is);
  87. }