TYPO3 API  SVNRelease
EmbeddedFile.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of SwiftMailer.
00005  * (c) 2004-2009 Chris Corbyn
00006  *
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
00009  */
00010 
00011 //@require 'Swift/Mime/Attachment.php';
00012 //@require 'Swift/DependencyContainer.php';
00013 //@require 'Swift/ByteStream/FileByteStream.php';
00014 
00015 /**
00016  * An embedded file, in a multipart message.
00017  * @package Swift
00018  * @subpackage Mime
00019  * @author Chris Corbyn
00020  */
00021 class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile
00022 {
00023 
00024   /**
00025    * Create a new EmbeddedFile.
00026    * Details may be optionally provided to the constructor.
00027    * @param string|Swift_OutputByteStream $data
00028    * @param string $filename
00029    * @param string $contentType
00030    */
00031   public function __construct($data = null, $filename = null,
00032     $contentType = null)
00033   {
00034     call_user_func_array(
00035       array($this, 'Swift_Mime_EmbeddedFile::__construct'),
00036       Swift_DependencyContainer::getInstance()
00037         ->createDependenciesFor('mime.embeddedfile')
00038       );
00039 
00040     $this->setBody($data);
00041     $this->setFilename($filename);
00042     if ($contentType)
00043     {
00044       $this->setContentType($contentType);
00045     }
00046   }
00047 
00048   /**
00049    * Create a new EmbeddedFile.
00050    * @param string|Swift_OutputByteStream $data
00051    * @param string $filename
00052    * @param string $contentType
00053    * @return Swift_Mime_EmbeddedFile
00054    */
00055   public static function newInstance($data = null, $filename = null,
00056     $contentType = null)
00057   {
00058     return new self($data, $filename, $contentType);
00059   }
00060 
00061   /**
00062    * Create a new EmbeddedFile from a filesystem path.
00063    * @param string $path
00064    * @return Swift_Mime_EmbeddedFile
00065    */
00066   public static function fromPath($path)
00067   {
00068     return self::newInstance()->setFile(
00069       new Swift_ByteStream_FileByteStream($path)
00070       );
00071   }
00072 
00073 }