webshelf /
framework
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Providers; |
||||
| 4 | |||||
| 5 | use Exception; |
||||
| 6 | use App\Classes\PluginManager; |
||||
| 7 | use App\Classes\SettingsManager; |
||||
| 8 | use Illuminate\Foundation\Application; |
||||
| 9 | use App\Exceptions\EngineBootException; |
||||
| 10 | use Illuminate\Support\ServiceProvider; |
||||
| 11 | use App\Classes\Repositories\PluginRepository; |
||||
| 12 | use App\Classes\Repositories\SettingsRepository; |
||||
| 13 | |||||
| 14 | /** |
||||
| 15 | * Created by PhpStorm. |
||||
| 16 | * User: Mark |
||||
| 17 | * Date: 01/02/2017 |
||||
| 18 | * Time: 10:05. |
||||
| 19 | */ |
||||
| 20 | class InstanceServiceProvider extends ServiceProvider |
||||
| 21 | { |
||||
| 22 | /** |
||||
| 23 | * The application instance. |
||||
| 24 | * |
||||
| 25 | * @var Application |
||||
| 26 | */ |
||||
| 27 | protected $app; |
||||
| 28 | |||||
| 29 | /** |
||||
| 30 | * Bootstrap application. |
||||
| 31 | * @return void |
||||
| 32 | */ |
||||
| 33 | public function boot() |
||||
| 34 | { |
||||
| 35 | $this->makeSettingsInstance(); |
||||
| 36 | |||||
| 37 | $this->makePluginInstance(); |
||||
| 38 | } |
||||
| 39 | |||||
| 40 | private function makeSettingsInstance() |
||||
| 41 | { |
||||
| 42 | $this->app->singleton(SettingsManager::class, function () { |
||||
| 43 | try { |
||||
| 44 | return (new SettingsManager)->collect(app(SettingsRepository::class)->all()); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 45 | } catch (Exception $e) { |
||||
| 46 | if ($this->app->runningInConsole()) { |
||||
| 47 | return new SettingsManager; |
||||
| 48 | } |
||||
| 49 | |||||
| 50 | throw new EngineBootException('Could not perform query on the `settings database`, do we have proper connection settings?'); |
||||
| 51 | } |
||||
| 52 | }); |
||||
| 53 | } |
||||
| 54 | |||||
| 55 | private function makePluginInstance() |
||||
| 56 | { |
||||
| 57 | $this->app->singleton(PluginManager::class, function () { |
||||
| 58 | try { |
||||
| 59 | return (new PluginManager)->collect(app(PluginRepository::class)->all()); |
||||
|
0 ignored issues
–
show
It seems like
app(App\Classes\Reposito...pository::class)->all() can also be of type App\Model\Plugin and Illuminate\Database\Eloquent\Builder; however, parameter $collection of App\Classes\PluginManager::collect() does only seem to accept Illuminate\Support\Collection, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 60 | } catch (Exception $e) { |
||||
| 61 | if ($this->app->runningInConsole()) { |
||||
| 62 | return new PluginManager; |
||||
| 63 | } |
||||
| 64 | |||||
| 65 | throw new EngineBootException('Could not perform query on the `plugins database`, do we have proper connection settings?'); |
||||
| 66 | } |
||||
| 67 | }); |
||||
| 68 | } |
||||
| 69 | } |
||||
| 70 |