UniSharp /
laravel-filemanager
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace UniSharp\LaravelFilemanager\Controllers; |
||||
| 4 | |||||
| 5 | use UniSharp\LaravelFilemanager\Lfm; |
||||
| 6 | use UniSharp\LaravelFilemanager\LfmPath; |
||||
| 7 | |||||
| 8 | class LfmController extends Controller |
||||
| 9 | { |
||||
| 10 | protected static $success_response = 'OK'; |
||||
| 11 | |||||
| 12 | public function __construct() |
||||
| 13 | { |
||||
| 14 | $this->applyIniOverrides(); |
||||
| 15 | } |
||||
| 16 | |||||
| 17 | /** |
||||
| 18 | * Set up needed functions. |
||||
| 19 | * |
||||
| 20 | * @return object|null |
||||
| 21 | */ |
||||
| 22 | public function __get($var_name) |
||||
| 23 | { |
||||
| 24 | if ($var_name === 'lfm') { |
||||
| 25 | return app(LfmPath::class); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 26 | } elseif ($var_name === 'helper') { |
||||
| 27 | return app(Lfm::class); |
||||
| 28 | } |
||||
| 29 | } |
||||
| 30 | |||||
| 31 | /** |
||||
| 32 | * Show the filemanager. |
||||
| 33 | * |
||||
| 34 | * @return mixed |
||||
| 35 | */ |
||||
| 36 | public function show() |
||||
| 37 | { |
||||
| 38 | return view('laravel-filemanager::index') |
||||
|
0 ignored issues
–
show
The function
view was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 39 | ->withHelper($this->helper); |
||||
|
0 ignored issues
–
show
The property
helper does not exist on UniSharp\LaravelFilemana...ntrollers\LfmController. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||
| 40 | } |
||||
| 41 | |||||
| 42 | /** |
||||
| 43 | * Check if any extension or config is missing. |
||||
| 44 | * |
||||
| 45 | * @return array |
||||
| 46 | */ |
||||
| 47 | public function getErrors() |
||||
| 48 | { |
||||
| 49 | $arr_errors = []; |
||||
| 50 | |||||
| 51 | if (! extension_loaded('gd') && ! extension_loaded('imagick')) { |
||||
| 52 | array_push($arr_errors, trans('laravel-filemanager::lfm.message-extension_not_found')); |
||||
|
0 ignored issues
–
show
The function
trans was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 53 | } |
||||
| 54 | |||||
| 55 | if (! extension_loaded('exif')) { |
||||
| 56 | array_push($arr_errors, 'EXIF extension not found.'); |
||||
| 57 | } |
||||
| 58 | |||||
| 59 | if (! extension_loaded('fileinfo')) { |
||||
| 60 | array_push($arr_errors, 'Fileinfo extension not found.'); |
||||
| 61 | } |
||||
| 62 | |||||
| 63 | $mine_config_key = 'lfm.folder_categories.' |
||||
| 64 | . $this->helper->currentLfmType() |
||||
|
0 ignored issues
–
show
The property
helper does not exist on UniSharp\LaravelFilemana...ntrollers\LfmController. Since you implemented __get, consider adding a @property annotation.
Loading history...
The method
currentLfmType() does not exist on null.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 65 | . '.valid_mime'; |
||||
| 66 | |||||
| 67 | if (! is_array(config($mine_config_key))) { |
||||
|
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 68 | array_push($arr_errors, 'Config : ' . $mine_config_key . ' is not a valid array.'); |
||||
| 69 | } |
||||
| 70 | |||||
| 71 | return $arr_errors; |
||||
| 72 | } |
||||
| 73 | |||||
| 74 | /** |
||||
| 75 | * Overrides settings in php.ini. |
||||
| 76 | * |
||||
| 77 | * @return null |
||||
| 78 | */ |
||||
| 79 | private function applyIniOverrides() |
||||
| 80 | { |
||||
| 81 | $overrides = config('lfm.php_ini_overrides', []); |
||||
|
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 82 | |||||
| 83 | if ($overrides && is_array($overrides) && count($overrides) === 0) { |
||||
| 84 | return; |
||||
| 85 | } |
||||
| 86 | |||||
| 87 | foreach ($overrides as $key => $value) { |
||||
| 88 | if ($value && $value != 'false') { |
||||
| 89 | ini_set($key, $value); |
||||
| 90 | } |
||||
| 91 | } |
||||
| 92 | } |
||||
| 93 | |||||
| 94 | // TODO: remove this after refactoring RenameController and DeleteController |
||||
| 95 | protected function error($error_type, $variables = []) |
||||
| 96 | { |
||||
| 97 | return trans(Lfm::PACKAGE_NAME . '::lfm.error-' . $error_type, $variables); |
||||
|
0 ignored issues
–
show
The function
trans was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 98 | } |
||||
| 99 | } |
||||
| 100 |