itstructure /
laravel-media-file-uploader
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Itstructure\MFU; |
||||||
| 4 | |||||||
| 5 | use Illuminate\Foundation\AliasLoader; |
||||||
| 6 | use Illuminate\Support\Facades\View; |
||||||
| 7 | use Illuminate\Support\Facades\Blade; |
||||||
| 8 | use Illuminate\Support\ServiceProvider; |
||||||
| 9 | use Itstructure\MFU\Facades\Uploader as UploaderFacade; |
||||||
| 10 | use Itstructure\MFU\Services\Uploader as UploaderService; |
||||||
| 11 | use Itstructure\MFU\Facades\Previewer as PreviewerFacade; |
||||||
| 12 | use Itstructure\MFU\Services\Previewer as PreviewerService; |
||||||
| 13 | |||||||
| 14 | /** |
||||||
| 15 | * Class UploadServiceProvider |
||||||
| 16 | * @package Itstructure\MFU |
||||||
| 17 | * @author Andrey Girnik <[email protected]> |
||||||
| 18 | */ |
||||||
| 19 | class UploadServiceProvider extends ServiceProvider |
||||||
| 20 | { |
||||||
| 21 | /** |
||||||
| 22 | * Register any application services. |
||||||
| 23 | * @return void |
||||||
| 24 | */ |
||||||
| 25 | public function register() |
||||||
| 26 | { |
||||||
| 27 | $this->app->bind('uploader', function ($app) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 28 | return UploaderService::getInstance($app['config']['uploader']['processor']); |
||||||
| 29 | }); |
||||||
| 30 | AliasLoader::getInstance()->alias('Uploader', UploaderFacade::class); |
||||||
| 31 | |||||||
| 32 | $this->app->bind('previewer', function ($app) { |
||||||
| 33 | return PreviewerService::getInstance($app['config']['uploader']['preview']); |
||||||
| 34 | }); |
||||||
| 35 | AliasLoader::getInstance()->alias('Previewer', PreviewerFacade::class); |
||||||
| 36 | |||||||
| 37 | // Directives |
||||||
| 38 | require_once __DIR__ . '/functions.php'; |
||||||
| 39 | |||||||
| 40 | Blade::directive('fileSetter', function ($config) { |
||||||
| 41 | return "<?php echo file_setter($config); ?>"; |
||||||
| 42 | }); |
||||||
| 43 | |||||||
| 44 | $this->app->register(UploadRouteServiceProvider::class); |
||||||
|
0 ignored issues
–
show
The call to
Tests\Laravel\App::register() has too many arguments starting with Itstructure\MFU\UploadRouteServiceProvider::class.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||||
| 45 | |||||||
| 46 | $this->registerCommands(); |
||||||
| 47 | } |
||||||
| 48 | |||||||
| 49 | /** |
||||||
| 50 | * Bootstrap any application services. |
||||||
| 51 | * @return void |
||||||
| 52 | */ |
||||||
| 53 | public function boot() |
||||||
| 54 | { |
||||||
| 55 | // Loading settings |
||||||
| 56 | $this->loadViews(); |
||||||
| 57 | $this->loadTranslations(); |
||||||
| 58 | $this->loadMigrations(); |
||||||
| 59 | |||||||
| 60 | |||||||
| 61 | // Publish settings |
||||||
| 62 | $this->publishAssets(); |
||||||
| 63 | $this->publishConfig(); |
||||||
| 64 | $this->publishViews(); |
||||||
| 65 | $this->publishTranslations(); |
||||||
| 66 | $this->publishMigrations(); |
||||||
| 67 | |||||||
| 68 | // Global view's params |
||||||
| 69 | View::share('albumsLayout', config('uploader.albums.layout')); |
||||||
| 70 | } |
||||||
| 71 | |||||||
| 72 | |||||||
| 73 | /* |
||||||
| 74 | |-------------------------------------------------------------------------- |
||||||
| 75 | | COMMAND SETTINGS |
||||||
| 76 | |-------------------------------------------------------------------------- |
||||||
| 77 | */ |
||||||
| 78 | |||||||
| 79 | /** |
||||||
| 80 | * Register commands. |
||||||
| 81 | * @return void |
||||||
| 82 | */ |
||||||
| 83 | private function registerCommands(): void |
||||||
| 84 | { |
||||||
| 85 | $this->commands(Commands\PublishCommand::class); |
||||||
|
0 ignored issues
–
show
The method
commands() does not exist on Itstructure\MFU\UploadServiceProvider.
(
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...
|
|||||||
| 86 | } |
||||||
| 87 | |||||||
| 88 | |||||||
| 89 | /* |
||||||
| 90 | |-------------------------------------------------------------------------- |
||||||
| 91 | | LOADING SETTINGS |
||||||
| 92 | |-------------------------------------------------------------------------- |
||||||
| 93 | */ |
||||||
| 94 | |||||||
| 95 | /** |
||||||
| 96 | * Set directory to load views. |
||||||
| 97 | * @return void |
||||||
| 98 | */ |
||||||
| 99 | private function loadViews(): void |
||||||
| 100 | { |
||||||
| 101 | $this->loadViewsFrom($this->packagePath('resources/views'), 'uploader'); |
||||||
|
0 ignored issues
–
show
The method
loadViewsFrom() does not exist on Itstructure\MFU\UploadServiceProvider. Did you maybe mean loadViews()?
(
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...
|
|||||||
| 102 | } |
||||||
| 103 | |||||||
| 104 | /** |
||||||
| 105 | * Set directory to load translations. |
||||||
| 106 | * @return void |
||||||
| 107 | */ |
||||||
| 108 | private function loadTranslations(): void |
||||||
| 109 | { |
||||||
| 110 | $this->loadTranslationsFrom($this->packagePath('resources/lang'), 'uploader'); |
||||||
|
0 ignored issues
–
show
The method
loadTranslationsFrom() does not exist on Itstructure\MFU\UploadServiceProvider. Did you maybe mean loadTranslations()?
(
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...
|
|||||||
| 111 | } |
||||||
| 112 | |||||||
| 113 | /** |
||||||
| 114 | * Set directory to load migrations. |
||||||
| 115 | * @return void |
||||||
| 116 | */ |
||||||
| 117 | private function loadMigrations(): void |
||||||
| 118 | { |
||||||
| 119 | $this->loadMigrationsFrom($this->packagePath('database/migrations')); |
||||||
|
0 ignored issues
–
show
The method
loadMigrationsFrom() does not exist on Itstructure\MFU\UploadServiceProvider. Did you maybe mean loadMigrations()?
(
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...
|
|||||||
| 120 | } |
||||||
| 121 | |||||||
| 122 | |||||||
| 123 | /* |
||||||
| 124 | |-------------------------------------------------------------------------- |
||||||
| 125 | | PUBLISH SETTINGS |
||||||
| 126 | |-------------------------------------------------------------------------- |
||||||
| 127 | */ |
||||||
| 128 | |||||||
| 129 | private function publishAssets(): void |
||||||
| 130 | { |
||||||
| 131 | $this->publishes([ |
||||||
|
0 ignored issues
–
show
The method
publishes() does not exist on Itstructure\MFU\UploadServiceProvider. Did you maybe mean publishViews()?
(
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...
|
|||||||
| 132 | $this->packagePath('resources/assets') => public_path('vendor/uploader'), |
||||||
| 133 | ], 'assets'); |
||||||
| 134 | } |
||||||
| 135 | |||||||
| 136 | /** |
||||||
| 137 | * Publish config. |
||||||
| 138 | * @return void |
||||||
| 139 | */ |
||||||
| 140 | private function publishConfig(): void |
||||||
| 141 | { |
||||||
| 142 | $configPath = $this->packagePath('config/uploader.php'); |
||||||
| 143 | |||||||
| 144 | $this->publishes([ |
||||||
| 145 | $configPath => config_path('uploader.php'), |
||||||
| 146 | ], 'config'); |
||||||
| 147 | |||||||
| 148 | $this->mergeConfigFrom($configPath, 'uploader'); |
||||||
|
0 ignored issues
–
show
The method
mergeConfigFrom() does not exist on Itstructure\MFU\UploadServiceProvider.
(
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...
|
|||||||
| 149 | } |
||||||
| 150 | |||||||
| 151 | /** |
||||||
| 152 | * Publish views. |
||||||
| 153 | * @return void |
||||||
| 154 | */ |
||||||
| 155 | private function publishViews(): void |
||||||
| 156 | { |
||||||
| 157 | $this->publishes([ |
||||||
| 158 | $this->packagePath('resources/views') => resource_path('views/vendor/uploader'), |
||||||
| 159 | ], 'views'); |
||||||
| 160 | } |
||||||
| 161 | |||||||
| 162 | /** |
||||||
| 163 | * Publish translations. |
||||||
| 164 | * @return void |
||||||
| 165 | */ |
||||||
| 166 | private function publishTranslations(): void |
||||||
| 167 | { |
||||||
| 168 | $this->publishes([ |
||||||
| 169 | $this->packagePath('resources/lang') => resource_path('lang/vendor/uploader'), |
||||||
| 170 | ], 'lang'); |
||||||
| 171 | } |
||||||
| 172 | |||||||
| 173 | /** |
||||||
| 174 | * Publish migrations. |
||||||
| 175 | * @return void |
||||||
| 176 | */ |
||||||
| 177 | private function publishMigrations(): void |
||||||
| 178 | { |
||||||
| 179 | $this->publishes([ |
||||||
| 180 | $this->packagePath('database/migrations') => database_path('migrations'), |
||||||
| 181 | ], 'migrations'); |
||||||
| 182 | } |
||||||
| 183 | |||||||
| 184 | |||||||
| 185 | /* |
||||||
| 186 | |-------------------------------------------------------------------------- |
||||||
| 187 | | OTHER SETTINGS |
||||||
| 188 | |-------------------------------------------------------------------------- |
||||||
| 189 | */ |
||||||
| 190 | |||||||
| 191 | /** |
||||||
| 192 | * Get package path. |
||||||
| 193 | * @param $path |
||||||
| 194 | * @return string |
||||||
| 195 | */ |
||||||
| 196 | private function packagePath($path): string |
||||||
| 197 | { |
||||||
| 198 | return __DIR__ . '/../' . $path; |
||||||
| 199 | } |
||||||
| 200 | } |
||||||
| 201 |
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.