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