ShopServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 22
c 3
b 0
f 0
dl 0
loc 42
rs 9.568
cc 1
nc 1
nop 0
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\Route;
15
16
17
/**
18
 * Aimeos shop service provider for Laravel
19
 * @package laravel
20
 */
21
class ShopServiceProvider extends ServiceProvider {
22
23
	/**
24
	 * Indicates if loading of the provider is deferred.
25
	 *
26
	 * @var bool
27
	 */
28
	protected $defer = false;
29
30
31
	/**
32
	 * Bootstrap the application events.
33
	 *
34
	 * @return void
35
	 */
36
	public function boot()
37
	{
38
		$ds = DIRECTORY_SEPARATOR;
39
		$basedir = dirname( dirname( __DIR__ ) ) . $ds;
40
41
		$this->loadRoutesFrom( $basedir . 'routes.php' );
42
		$this->loadViewsFrom( $basedir . 'views', 'shop' );
43
44
		$this->publishes( [ $basedir . 'config/shop.php' => config_path( 'shop.php' ) ], 'config' );
45
		$this->publishes( [ dirname( $basedir ) . $ds . 'public' => public_path( 'packages/aimeos/shop' ) ], 'public' );
46
	}
47
48
49
	/**
50
	 * Register the service provider.
51
	 *
52
	 * @return void
53
	 */
54
	public function register()
55
	{
56
		$this->mergeConfigFrom( dirname( dirname( __DIR__ ) ) . DIRECTORY_SEPARATOR . 'default.php', 'shop');
57
58
		$this->app->singleton('aimeos', function($app) {
59
			return new \Aimeos\Shop\Base\Aimeos($app['config']);
60
		});
61
62
		$this->app->singleton('aimeos.config', function($app) {
63
			return new \Aimeos\Shop\Base\Config($app['config'], $app['aimeos']);
64
		});
65
66
		$this->app->singleton('aimeos.i18n', function($app) {
67
			return new \Aimeos\Shop\Base\I18n($this->app['config'], $app['aimeos']);
68
		});
69
70
		$this->app->singleton('aimeos.locale', function($app) {
71
			return new \Aimeos\Shop\Base\Locale($app['config']);
72
		});
73
74
		$this->app->singleton('aimeos.context', function($app) {
75
			return new \Aimeos\Shop\Base\Context($app['session.store'], $app['aimeos.config'], $app['aimeos.locale'], $app['aimeos.i18n']);
76
		});
77
78
		$this->app->singleton('aimeos.support', function($app) {
79
			return new \Aimeos\Shop\Base\Support($app['aimeos.context'], $app['aimeos.locale']);
80
		});
81
82
		$this->app->singleton('aimeos.view', function($app) {
83
			return new \Aimeos\Shop\Base\View($app['config'], $app['aimeos.i18n'], $app['aimeos.support']);
84
		});
85
86
		$this->app->singleton('aimeos.shop', function($app) {
87
			return new \Aimeos\Shop\Base\Shop($app['aimeos'], $app['aimeos.context'], $app['aimeos.view']);
88
		});
89
90
91
		$this->commands( array(
92
			'Aimeos\Shop\Command\AccountCommand',
93
			'Aimeos\Shop\Command\CacheCommand',
94
			'Aimeos\Shop\Command\SetupCommand',
95
			'Aimeos\Shop\Command\JobsCommand',
96
		) );
97
	}
98
99
100
	/**
101
	 * Get the services provided by the provider.
102
	 *
103
	 * @return array
104
	 */
105
	public function provides()
106
	{
107
		return array(
108
			'Aimeos\Shop\Base\Aimeos', 'Aimeos\Shop\Base\I18n', 'Aimeos\Shop\Base\Context',
109
			'Aimeos\Shop\Base\Config', 'Aimeos\Shop\Base\Locale', 'Aimeos\Shop\Base\View',
110
			'Aimeos\Shop\Base\Support', 'Aimeos\Shop\Base\Shop',
111
			'Aimeos\Shop\Command\AccountCommand', 'Aimeos\Shop\Command\CacheCommand',
112
			'Aimeos\Shop\Command\SetupCommand', 'Aimeos\Shop\Command\JobsCommand',
113
		);
114
	}
115
116
}