1: <?php namespace Laravella\Cart;
2:
3: use Illuminate\Support\ServiceProvider;
4:
5: class CartServiceProvider extends ServiceProvider {
6:
7: /**
8: * Indicates if loading of the provider is deferred.
9: *
10: * @var bool
11: */
12: protected $defer = false;
13:
14: /**
15: * Bootstrap the application events.
16: *
17: * @return void
18: */
19: public function boot()
20: {
21: $this->package('laravella/cart');
22:
23: include __DIR__.'/../../routes/routes.php';
24:
25: $this->registerCommands();
26:
27: }
28:
29: /**
30: * Register the service provider.
31: *
32: * @return void
33: */
34: public function register()
35: {
36: // Register 'underlyingclass' instance container to our UnderlyingClass object
37: $this->app['dbgopher'] = $this->app->share(function($app)
38: {
39: return new DbGopher;
40: });
41:
42: $this->app['mysqlgopher'] = $this->app->share(function($app)
43: {
44: return new MysqlGopher;
45: });
46:
47: $this->app->booting(function()
48: {
49: $loader = \Illuminate\Foundation\AliasLoader::getInstance();
50: $loader->alias('DbGopher', 'Laravella\Cart\Facades\DbGopher');
51: $loader->alias('MysqlGopher', 'Laravella\Cart\MysqlGopher');
52: });
53: }
54:
55: /**
56: * Get the services provided by the provider.
57: *
58: * @return array
59: */
60: public function provides()
61: {
62: return array();
63: }
64:
65: /** register the custom commands **/
66: public function registerCommands()
67: {
68: // Artisan::add(new InstallCommand);
69: // Artisan::add(new UpdateCommand);
70:
71: $commands = array('CartInstall','CartUpdate');
72:
73: foreach ($commands as $command)
74: {
75: $this->{'register'.$command.'Command'}();
76: }
77:
78: $this->commands(
79: 'command.cart.install','command.cart.update'
80: );
81:
82: }
83:
84: public function registerCartInstallCommand()
85: {
86: $this->app['command.cart.install'] = $this->app->share(function($app)
87: {
88: return new CartInstallCommand();
89: });
90: }
91:
92: public function registerCartUpdateCommand()
93: {
94: $this->app['command.cart.update'] = $this->app->share(function($app)
95: {
96: return new CartUpdateCommand();
97: });
98: }
99:
100:
101:
102: }