Swift_Attachment::__construct PHP Метод

__construct() публичный Метод

Details may be optionally provided to the constructor.
public __construct ( string | Swift_OutputByteStream $data = null, string $filename = null, string $contentType = null )
$data string | Swift_OutputByteStream
$filename string
$contentType string
    public function __construct($data = null, $filename = null, $contentType = null)
    {
        call_user_func_array(array($this, 'Swift_Mime_Attachment::__construct'), Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.attachment'));
        $this->setBody($data);
        $this->setFilename($filename);
        if ($contentType) {
            $this->setContentType($contentType);
        }
    }

Usage Example

 /**
  * Calendar attachment constructor
  *
  * @param Calendar $calendar
  */
 public function __construct(Calendar $calendar)
 {
     $data = $calendar->createCalendar();
     $filename = $calendar->getConfig('filename');
     $contentType = $calendar->getContentType();
     parent::__construct($data, $filename, $contentType);
 }