1 | <?php |
||
17 | class Priloha extends FlexiBeeRW |
||
18 | { |
||
19 | /** |
||
20 | * Evidence užitá objektem. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | public $evidence = 'priloha'; |
||
25 | |||
26 | /** |
||
27 | * Evidence s přílohami |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | public static $relatedEvidence = [ |
||
32 | 'prodejka' => 'doklFak', 'pohledavka' => 'doklFak', 'zavazek' => 'doklFak', |
||
33 | 'faktura-prijata' => 'doklFak', 'faktura-vydana' => 'doklFak', |
||
34 | 'interni-doklad' => 'doklInt', 'pokladni-pohyb' => 'doklInt', 'vzajemny-zapocet' => 'doklInt', |
||
35 | 'banka' => 'doklInt', |
||
36 | 'poptavka-vydana' => 'doklObch', 'poptavka-prijata' => 'doklObch', 'objednavka-prijata' => 'doklObch', |
||
37 | 'nabidka-vydana' => 'doklObch', |
||
38 | 'objednavka-vydana' => 'doklObch', 'nabidka-prijata' => 'doklObch', |
||
39 | 'skladovy-pohyb' => 'doklSklad', |
||
40 | 'cenik' => 'cenik', |
||
41 | 'adresar' => 'adresar', 'kontakt' => 'kontakt' |
||
42 | ]; |
||
43 | |||
44 | /** |
||
45 | * Attach file |
||
46 | * Přilož Soubor |
||
47 | * |
||
48 | * @param string $filepath |
||
49 | * @param array $attachmentData |
||
50 | */ |
||
51 | public function attachFile($filepath, $attachmentData = []) |
||
52 | { |
||
53 | if (file_exists($filepath)) { |
||
54 | $attachmentData['nazSoub'] = basename($filepath); |
||
55 | $attachmentData['contentType'] = mime_content_type($filepath); |
||
56 | $attachmentData['dataSize'] = filesize($filepath); |
||
57 | $attachmentData['dataHash'] = md5_file($filepath); |
||
58 | |||
59 | switch ($attachmentData['contentType']) { |
||
60 | case 'image/png': |
||
61 | case 'image/gif': |
||
62 | case 'image/jpeg': |
||
63 | break; |
||
64 | } |
||
65 | $attachmentData['content'] = base64_encode(file_get_contents($filepath)); |
||
66 | } |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Obtain url for Attachment Download |
||
71 | * |
||
72 | * @param \FlexiBeeRO $object Source object |
||
73 | * @return string url |
||
74 | */ |
||
75 | public static function getDownloadUrl($object) |
||
76 | { |
||
77 | $urlParts = parse_url($object->apiURL); |
||
78 | $pathParts = pathinfo($urlParts['path']); |
||
79 | return $urlParts['scheme'].'://'.$urlParts['host'].$pathParts['dirname'].'/'.$pathParts['filename'].'/content'; |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Obtain first attachment for given object |
||
84 | * |
||
85 | * @param FlexiBeeRO $object |
||
86 | * @return array |
||
87 | */ |
||
88 | public static function getFirstAttachment($object) |
||
93 | |||
94 | /** |
||
95 | * Send "download" headers first and then file itself |
||
96 | * |
||
97 | * @param FlexiBeeRO $object |
||
98 | * @param int|string $attachmentID |
||
99 | */ |
||
100 | public static function download($object, $format = 'pdf', |
||
123 | |||
124 | /** |
||
125 | * Save attachment to file |
||
126 | * |
||
127 | * @param int $attachmentID |
||
128 | * @param string $destination directory or filename with path |
||
129 | * @return int |
||
130 | */ |
||
131 | public static function saveToFile($attachmentID, $destination) |
||
148 | |||
149 | /** |
||
150 | * Add Attachment from File |
||
151 | * |
||
152 | * @param FlexiBeeRW $object |
||
153 | * @param string $filename |
||
154 | * |
||
155 | * @return int HTTP response code |
||
156 | */ |
||
157 | public static function addAttachmentFromFile($object, $filename) |
||
162 | |||
163 | /** |
||
164 | * Add Attachment related to current $object content |
||
165 | * |
||
166 | * @param FlexiBeeRW $object |
||
167 | * @param string $filename |
||
168 | * @param string $attachment Body |
||
169 | * @param string $contentType Attachment Content-Type |
||
170 | * |
||
171 | * @return int HTTP Response code |
||
172 | */ |
||
173 | public static function addAttachment($object, $filename, $attachment, |
||
185 | |||
186 | /** |
||
187 | * Obtain Record related attachments list |
||
188 | * |
||
189 | * @param FlexiBeeRO $object |
||
190 | * @return array |
||
191 | */ |
||
192 | public static function getAttachmentsList($object) |
||
206 | } |
||
207 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: