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