Issues (145)

src/ShopServiceProvider.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015-2023
6
 */
7
8
9
namespace Aimeos\Shop;
10
11
use Illuminate\Support\ServiceProvider;
12
use Illuminate\Support\Facades\Blade;
13
use Illuminate\Support\Facades\Route;
14
15
16
/**
17
 * Aimeos shop service provider for Laravel
18
 */
19
class ShopServiceProvider extends ServiceProvider {
20
21
	/**
22
	 * Indicates if loading of the provider is deferred.
23
	 *
24
	 * @var bool
25
	 */
26
	protected $defer = false;
27
28
29
	/**
30
	 * Bootstrap the application events.
31
	 *
32
	 * @return void
33
	 */
34
	public function boot()
35
	{
36
		$this->loadViewsFrom( dirname( __DIR__ ) . '/views', 'shop' );
37
		$this->loadRoutesFrom( dirname( __DIR__ ) . '/routes/aimeos.php' );
38
39
		$this->publishes( [dirname( __DIR__ ) . '/config/shop.php' => config_path( 'shop.php' )], 'config' );
40
		$this->publishes( [dirname( __DIR__ ) . '/public' => public_path( 'vendor/shop' )], 'public' );
41
42
		$class = '\Composer\InstalledVersions';
43
44
		if( class_exists( $class ) && method_exists( $class, 'getInstalledPackagesByType' ) )
45
		{
46
			foreach( \Composer\InstalledVersions::getInstalledPackagesByType( 'aimeos-extension' ) as $package )
47
			{
48
				$path = realpath( \Composer\InstalledVersions::getInstallPath( $package ) );
0 ignored issues
show
It seems like Composer\InstalledVersio...etInstallPath($package) can also be of type null; however, parameter $path of realpath() does only seem to accept string, 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 ignore-type  annotation

48
				$path = realpath( /** @scrutinizer ignore-type */ \Composer\InstalledVersions::getInstallPath( $package ) );
Loading history...
49
50
				if( file_exists( $path . '/themes/client/html' ) ) {
51
					$this->publishes( [$path . '/themes/client/html' => public_path( 'vendor/shop/themes' )], 'public' );
52
				}
53
			}
54
		}
55
	}
56
57
58
	/**
59
	 * Register the service provider.
60
	 *
61
	 * @return void
62
	 */
63
	public function register()
64
	{
65
		$this->mergeConfigFrom( dirname( __DIR__ ) . '/config/default.php', 'shop' );
66
67
		$this->app->singleton( 'aimeos', function( $app ) {
68
			return new \Aimeos\Shop\Base\Aimeos( $app['config'] );
69
		});
70
71
		$this->app->singleton( 'aimeos.config', function( $app ) {
72
			return new \Aimeos\Shop\Base\Config( $app['config'], $app['aimeos'] );
73
		});
74
75
		$this->app->singleton( 'aimeos.i18n', function( $app ) {
76
			return new \Aimeos\Shop\Base\I18n( $this->app['config'], $app['aimeos'] );
77
		});
78
79
		$this->app->singleton( 'aimeos.locale', function( $app ) {
80
			return new \Aimeos\Shop\Base\Locale( $app['config'] );
81
		});
82
83
		$this->app->singleton( 'aimeos.context', function( $app ) {
84
			return new \Aimeos\Shop\Base\Context( $app['session.store'], $app['aimeos.config'], $app['aimeos.locale'], $app['aimeos.i18n'] );
85
		});
86
87
		$this->app->singleton( 'aimeos.support', function( $app ) {
88
			return new \Aimeos\Shop\Base\Support( $app['aimeos.context'], $app['aimeos.locale'] );
89
		});
90
91
		$this->app->singleton( 'aimeos.view', function( $app ) {
92
			return new \Aimeos\Shop\Base\View( $app['config'], $app['aimeos.i18n'], $app['aimeos.support'] );
93
		});
94
95
		$this->app->singleton( 'aimeos.shop', function( $app ) {
96
			return new \Aimeos\Shop\Base\Shop( $app['aimeos'], $app['aimeos.context'], $app['aimeos.view'] );
97
		});
98
99
100
		$this->app->bind( 'aimeos.frontend.attribute', function( $app ) {
101
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'attribute' );
102
		});
103
104
		$this->app->bind( 'aimeos.frontend.basket', function( $app ) {
105
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'basket' );
106
		});
107
108
		$this->app->bind( 'aimeos.frontend.catalog', function( $app ) {
109
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'catalog' );
110
		});
111
112
		$this->app->bind( 'aimeos.frontend.cms', function( $app ) {
113
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'cms' );
114
		});
115
116
		$this->app->bind( 'aimeos.frontend.customer', function( $app ) {
117
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'customer' );
118
		});
119
120
		$this->app->bind( 'aimeos.frontend.locale', function( $app ) {
121
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'locale' );
122
		});
123
124
		$this->app->bind( 'aimeos.frontend.order', function( $app ) {
125
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'order' );
126
		});
127
128
		$this->app->bind( 'aimeos.frontend.product', function( $app ) {
129
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'product' );
130
		});
131
132
		$this->app->bind( 'aimeos.frontend.service', function( $app ) {
133
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'service' );
134
		});
135
136
		$this->app->bind( 'aimeos.frontend.stock', function( $app ) {
137
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'stock' );
138
		});
139
140
		$this->app->bind( 'aimeos.frontend.subscription', function( $app ) {
141
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'subscription' );
142
		});
143
144
		$this->app->bind( 'aimeos.frontend.supplier', function( $app ) {
145
			return \Aimeos\Controller\Frontend::create( $app['aimeos.context'], 'supplier' );
146
		});
147
148
149
		$this->commands( array(
150
			'Aimeos\Shop\Command\AccountCommand',
151
			'Aimeos\Shop\Command\ClearCommand',
152
			'Aimeos\Shop\Command\SetupCommand',
153
			'Aimeos\Shop\Command\JobsCommand',
154
		) );
155
	}
156
157
158
	/**
159
	 * Get the services provided by the provider.
160
	 *
161
	 * @return array
162
	 */
163
	public function provides()
164
	{
165
		return array(
166
			'Aimeos\Shop\Base\Aimeos', 'Aimeos\Shop\Base\I18n', 'Aimeos\Shop\Base\Context',
167
			'Aimeos\Shop\Base\Config', 'Aimeos\Shop\Base\Locale', 'Aimeos\Shop\Base\View',
168
			'Aimeos\Shop\Base\Support', 'Aimeos\Shop\Base\Shop',
169
			'Aimeos\Shop\Command\AccountCommand', 'Aimeos\Shop\Command\ClearCommand',
170
			'Aimeos\Shop\Command\SetupCommand', 'Aimeos\Shop\Command\JobsCommand',
171
		);
172
	}
173
174
}