1 | <?php |
||
12 | * |
||
13 | * @package Scool\Inventory\Providers |
||
14 | */ |
||
15 | class InventoryServiceProvider extends ServiceProvider |
||
16 | { |
||
17 | /** |
||
18 | * Register package services. |
||
19 | */ |
||
20 | public function register() |
||
21 | { |
||
22 | if (!defined('SCOOL_INVENTORY_PATH')) { |
||
23 | define('SCOOL_INVENTORY_PATH', realpath(__DIR__.'/../../')); |
||
24 | } |
||
25 | <<<<<<< HEAD |
||
26 | $this->registerNamesServiceProvider(); |
||
27 | $this->registerStatefulEloquentServiceProvider(); |
||
28 | $this->bindRepositories(); |
||
29 | $this->app->bind(StatsRepositoryInterface::class,function() { |
||
30 | ======= |
||
31 | $this->app->register(NamesServiceProvider::class); |
||
32 | $this->app->bind(\Scool\Inventory\Repositories\StudyRepository::class, \Scool\Inventory\Repositories\StudyRepositoryEloquent::class); |
||
33 | $this->app->bind(StatsRepositoryInterface::class, function () { |
||
34 | >>>>>>> af3b7660d20378ee776d8126fd76cd529a6c647e |
||
35 | return new CacheableStatsRepository(new StatsRepository()); |
||
36 | }); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Bind repositories |
||
41 | */ |
||
42 | protected function bindRepositories() |
||
43 | { |
||
44 | $this->app->bind( |
||
45 | \Scool\Inventory\Repositories\StudyRepository::class, |
||
46 | \Scool\Inventory\Repositories\StudyRepositoryEloquent::class); |
||
47 | $this->app->bind(\Scool\Inventory\Repositories\TodoRepository::class, \Scool\Inventory\Repositories\TodoRepositoryEloquent::class); |
||
48 | $this->app->bind(\Scool\Inventory\Repositories\ShitRepository::class, \Scool\Inventory\Repositories\ShitRepositoryEloquent::class); |
||
49 | //:end-bindings: |
||
50 | } |
||
51 | /** |
||
52 | * Register acacha/stateful-eloquent Service Provider. |
||
53 | * |
||
54 | */ |
||
55 | protected function registerStatefulEloquentServiceProvider() |
||
56 | { |
||
57 | $this->app->register(StatefulServiceProvider::class); |
||
58 | } |
||
59 | /** |
||
60 | * Register acacha/names Service Provider. |
||
61 | * |
||
62 | */ |
||
63 | protected function registerNamesServiceProvider() |
||
64 | { |
||
65 | $this->app->register(NamesServiceProvider::class); |
||
66 | } |
||
67 | /** |
||
68 | * Bootstrap package services. |
||
69 | * |
||
70 | * @return void |
||
71 | */ |
||
72 | public function boot() |
||
73 | { |
||
74 | $this->defineRoutes(); |
||
75 | $this->loadMigrations(); |
||
76 | $this->loadViews(); |
||
77 | $this->publishFactories(); |
||
78 | $this->publishConfig(); |
||
79 | $this->publishTests(); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Define the inventory routes. |
||
84 | */ |
||
85 | protected function defineRoutes() |
||
86 | { |
||
87 | if (!$this->app->routesAreCached()) { |
||
88 | $router = app('router'); |
||
89 | $router->group(['namespace' => 'Scool\Inventory\Http\Controllers'], function () { |
||
90 | require __DIR__.'/../Http/routes.php'; |
||
91 | }); |
||
92 | } |
||
93 | } |
||
94 | /** |
||
95 | * Load package views. |
||
96 | */ |
||
97 | private function loadViews() |
||
98 | { |
||
99 | $this->loadViewsFrom(SCOOL_INVENTORY_PATH . '/resources/views', 'inventory'); |
||
163 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.