|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of SwiftMailer. |
|
|
5 |
* (c) 2004-2009 Chris Corbyn |
|
|
6 |
* |
|
|
7 |
* For the full copyright and license information, please view the LICENSE |
|
|
8 |
* file that was distributed with this source code. |
|
|
9 |
*/ |
|
|
10 |
|
|
|
11 |
|
|
|
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 |
/** |
|
|
22 |
* Create a new EmbeddedFile. |
|
|
23 |
* Details may be optionally provided to the constructor. |
|
|
24 |
* @param string|Swift_OutputByteStream $data |
|
|
25 |
* @param string $filename |
|
|
26 |
* @param string $contentType |
|
|
27 |
*/ |
|
|
28 |
public function __construct($data = null, $filename = null, |
|
|
29 |
$contentType = null) |
|
|
30 |
{ |
|
|
31 |
call_user_func_array( |
|
|
32 |
array($this, 'Swift_Mime_EmbeddedFile::__construct'), |
|
|
33 |
Swift_DependencyContainer::getInstance() |
|
|
34 |
->createDependenciesFor('mime.embeddedfile') |
|
|
35 |
); |
|
|
36 |
|
|
|
37 |
$this->setBody($data); |
|
|
38 |
$this->setFilename($filename); |
|
|
39 |
if ($contentType) |
|
|
40 |
{ |
|
|
41 |
$this->setContentType($contentType); |
|
|
42 |
} |
|
|
43 |
} |
|
|
44 |
|
|
|
45 |
/** |
|
|
46 |
* Create a new EmbeddedFile. |
|
|
47 |
* @param string|Swift_OutputByteStream $data |
|
|
48 |
* @param string $filename |
|
|
49 |
* @param string $contentType |
|
|
50 |
* @return Swift_Mime_EmbeddedFile |
|
|
51 |
*/ |
|
|
52 |
public static function newInstance($data = null, $filename = null, |
|
|
53 |
$contentType = null) |
|
|
54 |
{ |
|
|
55 |
return new self($data, $filename, $contentType); |
|
|
56 |
} |
|
|
57 |
|
|
|
58 |
/** |
|
|
59 |
* Create a new EmbeddedFile from a filesystem path. |
|
|
60 |
* @param string $path |
|
|
61 |
* @return Swift_Mime_EmbeddedFile |
|
|
62 |
*/ |
|
|
63 |
public static function fromPath($path) |
|
|
64 |
{ |
|
|
65 |
return self::newInstance()->setFile( |
|
|
66 |
new Swift_ByteStream_FileByteStream($path) |
|
|
67 |
); |
|
|
68 |
} |
|
|
69 |
|
|
|
70 |
} |