|
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * This file is part of FacturaScripts |
4 | | - * Copyright (C) 2018-2024 Carlos Garcia Gomez <carlos@facturascripts.com> |
| 4 | + * Copyright (C) 2018-2025 Carlos Garcia Gomez <carlos@facturascripts.com> |
5 | 5 | * |
6 | 6 | * This program is free software: you can redistribute it and/or modify |
7 | 7 | * it under the terms of the GNU Lesser General Public License as |
|
22 | 22 | use FacturaScripts\Core\Base\DataBase\DataBaseWhere; |
23 | 23 | use FacturaScripts\Core\Cache; |
24 | 24 | use FacturaScripts\Core\Lib\MyFilesToken; |
25 | | -use FacturaScripts\Core\Model\Base\ModelOnChangeClass; |
26 | | -use FacturaScripts\Core\Model\Base\ModelTrait; |
| 25 | +use FacturaScripts\Core\Template\ModelClass; |
| 26 | +use FacturaScripts\Core\Template\ModelTrait; |
27 | 27 | use FacturaScripts\Core\Tools; |
28 | 28 | use finfo; |
29 | 29 |
|
|
33 | 33 | * @author Carlos García Gómez <carlos@facturascripts.com> |
34 | 34 | * @author Francesc Pineda Segarra <francesc.pineda.segarra@gmail.com> |
35 | 35 | */ |
36 | | -class AttachedFile extends ModelOnChangeClass |
| 36 | +class AttachedFile extends ModelClass |
37 | 37 | { |
38 | 38 | use ModelTrait; |
39 | 39 |
|
@@ -252,16 +252,11 @@ protected function getNextCode(): int |
252 | 252 | return $this->newCode(); |
253 | 253 | } |
254 | 254 |
|
255 | | - /** |
256 | | - * @param string $field |
257 | | - * |
258 | | - * @return bool |
259 | | - */ |
260 | | - protected function onChange($field) |
| 255 | + protected function onChange(string $field): bool |
261 | 256 | { |
262 | 257 | switch ($field) { |
263 | 258 | case 'path': |
264 | | - if ($this->previousData['path']) { |
| 259 | + if ($this->getOriginal('path')) { |
265 | 260 | // remove old file |
266 | 261 | unlink(FS_FOLDER . '/' . $this->previousData['path']); |
267 | 262 | } |
@@ -310,10 +305,4 @@ protected function setFile(): bool |
310 | 305 |
|
311 | 306 | return true; |
312 | 307 | } |
313 | | - |
314 | | - protected function setPreviousData(array $fields = []) |
315 | | - { |
316 | | - $more = ['path']; |
317 | | - parent::setPreviousData(array_merge($more, $fields)); |
318 | | - } |
319 | 308 | } |
0 commit comments