1 | <?php |
||
16 | class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * Recognized MIME types |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | private $_mimeTypes = array(); |
||
24 | |||
25 | /** |
||
26 | * Create a new Attachment with $headers, $encoder and $cache. |
||
27 | * |
||
28 | * @param Swift_Mime_HeaderSet $headers |
||
29 | * @param Swift_Mime_ContentEncoder $encoder |
||
30 | * @param Swift_KeyCache $cache |
||
31 | * @param Swift_EmailValidatorBridge $emailValidator |
||
32 | * @param array $mimeTypes optional |
||
33 | */ |
||
34 | 179 | public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_EmailValidatorBridge $emailValidator, $mimeTypes = array()) |
|
35 | { |
||
36 | 179 | parent::__construct($headers, $encoder, $cache, $emailValidator); |
|
37 | 179 | $this->setDisposition('attachment'); |
|
38 | 179 | $this->setContentType('application/octet-stream'); |
|
39 | 179 | $this->_mimeTypes = $mimeTypes; |
|
40 | 179 | } |
|
41 | |||
42 | /** |
||
43 | * Get the nesting level used for this attachment. |
||
44 | * |
||
45 | * Always returns {@link LEVEL_MIXED}. |
||
46 | * |
||
47 | * @return int |
||
48 | */ |
||
49 | 21 | public function getNestingLevel() |
|
53 | |||
54 | /** |
||
55 | * Get the Content-Disposition of this attachment. |
||
56 | * |
||
57 | * By default attachments have a disposition of "attachment". |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 2 | public function getDisposition() |
|
65 | |||
66 | /** |
||
67 | * Set the Content-Disposition of this attachment. |
||
68 | * |
||
69 | * @param string $disposition |
||
70 | * |
||
71 | * @return Swift_Mime_Attachment |
||
72 | */ |
||
73 | 179 | public function setDisposition($disposition) |
|
74 | { |
||
75 | 179 | if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) { |
|
76 | 163 | $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition); |
|
77 | } |
||
78 | |||
79 | 179 | return $this; |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * Get the filename of this attachment when downloaded. |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | 2 | public function getFilename() |
|
91 | |||
92 | /** |
||
93 | * Set the filename of this attachment. |
||
94 | * |
||
95 | * @param string $filename |
||
96 | * |
||
97 | * @return Swift_Mime_Attachment |
||
98 | */ |
||
99 | 55 | public function setFilename($filename) |
|
106 | |||
107 | /** |
||
108 | * Get the file size of this attachment. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | 2 | public function getSize() |
|
116 | |||
117 | /** |
||
118 | * Set the file size of this attachment. |
||
119 | * |
||
120 | * @param int $size |
||
121 | * |
||
122 | * @return Swift_Mime_Attachment |
||
123 | */ |
||
124 | 16 | public function setSize($size) |
|
130 | |||
131 | /** |
||
132 | * Set the file that this attachment is for. |
||
133 | * |
||
134 | * @param Swift_FileStream $file |
||
135 | * @param string $contentType optional |
||
136 | * |
||
137 | * @return Swift_Mime_Attachment |
||
138 | */ |
||
139 | 18 | public function setFile(Swift_FileStream $file, $contentType = null) |
|
154 | |||
155 | /** |
||
156 | * get the file-extension e.g. from "http://foo.bar/image.jpg?md5=123456" |
||
157 | * |
||
158 | * @param $str |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | 16 | private function getFileExtension($str) |
|
172 | } |
||
173 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.