Avail feature updated
[ninja.git] / application / vendor / swiftmailer / classes / Swift / Attachment.php
blobd3779bfe92fe0cecfa29bedda50499e1b87ba269
1 <?php
3 /*
4 * This file is part of SwiftMailer.
5 * (c) 2004-2009 Chris Corbyn
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
11 //@require 'Swift/Mime/Attachment.php';
12 //@require 'Swift/ByteStream/FileByteStream.php';
13 //@require 'Swift/DependencyContainer.php';
15 /**
16 * Attachment class for attaching files to a {@link Swift_Mime_Message}.
17 * @package Swift
18 * @subpackage Mime
19 * @author Chris Corbyn
21 class Swift_Attachment extends Swift_Mime_Attachment
24 /**
25 * Create a new Attachment.
26 * Details may be optionally provided to the constructor.
27 * @param string|Swift_OutputByteStream $data
28 * @param string $filename
29 * @param string $contentType
31 public function __construct($data = null, $filename = null,
32 $contentType = null)
34 call_user_func_array(
35 array($this, 'Swift_Mime_Attachment::__construct'),
36 Swift_DependencyContainer::getInstance()
37 ->createDependenciesFor('mime.attachment')
40 $this->setBody($data);
41 $this->setFilename($filename);
42 if ($contentType)
44 $this->setContentType($contentType);
48 /**
49 * Create a new Attachment.
50 * @param string|Swift_OutputByteStream $data
51 * @param string $filename
52 * @param string $contentType
53 * @return Swift_Mime_Attachment
55 public static function newInstance($data = null, $filename = null,
56 $contentType = null)
58 return new self($data, $filename, $contentType);
61 /**
62 * Create a new Attachment from a filesystem path.
63 * @param string $path
64 * @param string $contentType optional
65 * @return Swift_Mime_Attachment
67 public static function fromPath($path, $contentType = null)
69 return self::newInstance()->setFile(
70 new Swift_ByteStream_FileByteStream($path),
71 $contentType