Completed
Push — master ( c4e330...553822 )
by Aimeos
13:47
created

ShopServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 126
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 14

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 0
loc 126
rs 10
c 3
b 0
f 0
wmc 4
lcom 1
cbo 14

3 Methods

Rating   Name   Duplication   Size   Complexity  
B boot() 0 30 2
A register() 0 56 1
A provides() 0 9 1
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015-2016
6
 * @package laravel
7
 */
8
9
10
namespace Aimeos\Shop;
11
12
use Illuminate\Support\ServiceProvider;
13
use Illuminate\Support\Facades\Blade;
14
use Illuminate\Support\Facades\Input;
15
use Illuminate\Support\Facades\Route;
16
17
18
/**
19
 * Aimeos shop service provider for Laravel
20
 * @package laravel
21
 */
22
class ShopServiceProvider extends ServiceProvider {
23
24
	/**
25
	 * Indicates if loading of the provider is deferred.
26
	 *
27
	 * @var bool
28
	 */
29
	protected $defer = false;
30
31
32
	/**
33
	 * Bootstrap the application events.
34
	 *
35
	 * @return void
36
	 */
37
	public function boot()
38
	{
39
		$basedir = dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR;
40
		$confpath = config_path('shop.php');
41
42
		$config = array_replace_recursive(
43
			$this->app['config']->get('shop', []),
44
			require $basedir.'default.php',
45
			(file_exists($confpath) ? require $confpath : array())
46
		);
47
		$this->app['config']->set('shop', $config);
48
49
		$this->loadViewsFrom($basedir.'views', 'shop');
50
51
52
		$this->publishes(array(
53
			$basedir.'config/shop.php' => config_path('shop.php'),
54
		), 'config');
55
56
		$this->publishes(array(
57
			$basedir.'views' => base_path('resources/views/vendor/shop'),
58
		), 'views');
59
60
		$this->publishes(array(
61
			dirname($basedir).DIRECTORY_SEPARATOR.'public' => public_path('packages/aimeos/shop'),
62
		), 'public');
63
64
65
		require $basedir.'routes.php';
66
	}
67
68
69
	/**
70
	 * Register the service provider.
71
	 *
72
	 * @return void
73
	 */
74
	public function register()
75
	{
76
		$this->app->singleton('\Aimeos\Shop\Base\Aimeos', function($app) {
77
			return new \Aimeos\Shop\Base\Aimeos($app['config']);
78
		});
79
80
		$this->app->singleton('\Aimeos\Shop\Base\Config', function($app) {
81
			return new \Aimeos\Shop\Base\Config($app['config'], $app['\Aimeos\Shop\Base\Aimeos']);
82
		});
83
84
		$this->app->singleton('\Aimeos\Shop\Base\I18n', function($app) {
85
			return new \Aimeos\Shop\Base\I18n($this->app['config'], $app['\Aimeos\Shop\Base\Aimeos']);
86
		});
87
88
		$this->app->singleton('\Aimeos\Shop\Base\Locale', function($app) {
89
			return new \Aimeos\Shop\Base\Locale($app['config']);
90
		});
91
92
		$this->app->singleton('\Aimeos\Shop\Base\Context', function($app) {
93
			return new \Aimeos\Shop\Base\Context($app['session.store'], $app['\Aimeos\Shop\Base\Config'], $app['\Aimeos\Shop\Base\Locale'], $app['\Aimeos\Shop\Base\I18n']);
94
		});
95
96
		$this->app->singleton('\Aimeos\Shop\Base\Page', function($app) {
97
			return new \Aimeos\Shop\Base\Page($app['config'], $app['\Aimeos\Shop\Base\Aimeos'], $app['\Aimeos\Shop\Base\Context'], $app['\Aimeos\Shop\Base\Locale'], $app['\Aimeos\Shop\Base\View']);
98
		});
99
100
		$this->app->singleton('\Aimeos\Shop\Base\Support', function($app) {
101
			return new \Aimeos\Shop\Base\Support($app['\Aimeos\Shop\Base\Context'], $app['\Aimeos\Shop\Base\Locale']);
102
		});
103
104
		$this->app->singleton('\Aimeos\Shop\Base\View', function($app) {
105
			return new \Aimeos\Shop\Base\View($app['\Aimeos\Shop\Base\I18n'], $app['\Aimeos\Shop\Base\Support']);
106
		});
107
108
109
		$this->app['command.aimeos.account'] = $this->app->share(function() {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

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...
110
			return new Command\AccountCommand();
111
		});
112
113
		$this->app['command.aimeos.cache'] = $this->app->share(function() {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

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...
114
			return new Command\CacheCommand();
115
		});
116
117
		$this->app['command.aimeos.jobs'] = $this->app->share(function() {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

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...
118
			return new Command\JobsCommand();
119
		});
120
121
		$this->app['command.aimeos.setup'] = $this->app->share(function() {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

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...
122
			return new Command\SetupCommand();
123
		});
124
125
		$this->commands('command.aimeos.account');
126
		$this->commands('command.aimeos.cache');
127
		$this->commands('command.aimeos.setup');
128
		$this->commands('command.aimeos.jobs');
129
	}
130
131
132
	/**
133
	 * Get the services provided by the provider.
134
	 *
135
	 * @return array
136
	 */
137
	public function provides()
138
	{
139
		return array(
140
			'command.aimeos.account', 'command.aimeos.cache', 'command.aimeos.jobs', 'command.aimeos.setup',
141
			'\Aimeos\Shop\Base\Aimeos', '\Aimeos\Shop\Base\I18n', '\Aimeos\Shop\Base\Context',
142
			'\Aimeos\Shop\Base\Config', '\Aimeos\Shop\Base\Locale', '\Aimeos\Shop\Base\View',
143
			'\Aimeos\Shop\Base\Page', '\Aimeos\Shop\Base\Support'
144
		);
145
	}
146
147
}