PageRenderTime 13ms CodeModel.GetById 3ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/framework/vendor/swift/lib/classes/Swift/EmbeddedFile.php

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