[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/Swiftmailer/classes/Swift/ -> Attachment.php (source)

   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   * Attachment class for attaching files to a {@link Swift_Mime_Message}.
  13   *
  14   * @author Chris Corbyn
  15   */
  16  class Swift_Attachment extends Swift_Mime_Attachment
  17  {
  18      /**
  19       * Create a new Attachment.
  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              array($this, 'Swift_Mime_Attachment::__construct'),
  31              Swift_DependencyContainer::getInstance()
  32                  ->createDependenciesFor('mime.attachment')
  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 Attachment.
  44       *
  45       * @param string|Swift_OutputByteStream $data
  46       * @param string                        $filename
  47       * @param string                        $contentType
  48       *
  49       * @return Swift_Mime_Attachment
  50       */
  51      public static function newInstance($data = null, $filename = null, $contentType = null)
  52      {
  53          return new self($data, $filename, $contentType);
  54      }
  55  
  56      /**
  57       * Create a new Attachment from a filesystem path.
  58       *
  59       * @param string $path
  60       * @param string $contentType optional
  61       *
  62       * @return Swift_Mime_Attachment
  63       */
  64      public static function fromPath($path, $contentType = null)
  65      {
  66          return self::newInstance()->setFile(
  67              new Swift_ByteStream_FileByteStream($path),
  68              $contentType
  69              );
  70      }
  71  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1