/framework/vendor/swift/lib/classes/Swift/EmbeddedFile.php

http://zoop.googlecode.com/ · PHP · 73 lines · 30 code · 8 blank · 35 comment · 1 complexity · ed8050e9c1aa5fd3b494682de2f93393 MD5 · raw file

  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. //@require 'Swift/Mime/Attachment.php';
  10. //@require 'Swift/DependencyContainer.php';
  11. //@require 'Swift/ByteStream/FileByteStream.php';
  12. /**
  13. * An embedded file, in a multipart message.
  14. * @package Swift
  15. * @subpackage Mime
  16. * @author Chris Corbyn
  17. */
  18. class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile
  19. {
  20. /**
  21. * Create a new EmbeddedFile.
  22. * Details may be optionally provided to the constructor.
  23. * @param string|Swift_OutputByteStream $data
  24. * @param string $filename
  25. * @param string $contentType
  26. */
  27. public function __construct($data = null, $filename = null,
  28. $contentType = null)
  29. {
  30. call_user_func_array(
  31. array($this, 'Swift_Mime_EmbeddedFile::__construct'),
  32. Swift_DependencyContainer::getInstance()
  33. ->createDependenciesFor('mime.embeddedfile')
  34. );
  35. $this->setBody($data);
  36. $this->setFilename($filename);
  37. if ($contentType)
  38. {
  39. $this->setContentType($contentType);
  40. }
  41. }
  42. /**
  43. * Create a new EmbeddedFile.
  44. * @param string|Swift_OutputByteStream $data
  45. * @param string $filename
  46. * @param string $contentType
  47. * @return Swift_Mime_EmbeddedFile
  48. */
  49. public static function newInstance($data = null, $filename = null,
  50. $contentType = null)
  51. {
  52. return new self($data, $filename, $contentType);
  53. }
  54. /**
  55. * Create a new EmbeddedFile from a filesystem path.
  56. * @param string $path
  57. * @return Swift_Mime_EmbeddedFile
  58. */
  59. public static function fromPath($path)
  60. {
  61. return self::newInstance()->setFile(
  62. new Swift_ByteStream_FileByteStream($path)
  63. );
  64. }
  65. }