Completed
Push — master ( 71e644...fa8547 )
by Aimeos
03:10
created
src/Aimeos/Shop/Base/Context.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param \Illuminate\Contracts\Config\Repository $config Configuration object
50 50
 	 * @param \Illuminate\Session\Store $session Laravel session object
51 51
 	 */
52
-	public function __construct( \Illuminate\Contracts\Config\Repository $config, \Illuminate\Session\Store $session )
52
+	public function __construct(\Illuminate\Contracts\Config\Repository $config, \Illuminate\Session\Store $session)
53 53
 	{
54 54
 		$this->config = $config;
55 55
 		$this->session = $session;
@@ -62,48 +62,48 @@  discard block
 block discarded – undo
62 62
 	 * @param boolean $locale True to add locale object to context, false if not
63 63
 	 * @return \Aimeos\MShop\Context\Item\Iface Context object
64 64
 	 */
65
-	public function get( $locale = true )
65
+	public function get($locale = true)
66 66
 	{
67
-		if( self::$context === null )
67
+		if (self::$context === null)
68 68
 		{
69 69
 			$context = new \Aimeos\MShop\Context\Item\Standard();
70 70
 
71 71
 			$config = $this->getConfig();
72
-			$context->setConfig( $config );
72
+			$context->setConfig($config);
73 73
 
74
-			$dbm = new \Aimeos\MW\DB\Manager\PDO( $config );
75
-			$context->setDatabaseManager( $dbm );
74
+			$dbm = new \Aimeos\MW\DB\Manager\PDO($config);
75
+			$context->setDatabaseManager($dbm);
76 76
 
77
-			$fs = new \Aimeos\MW\Filesystem\Manager\Laravel( app( 'filesystem' ), $config, storage_path( 'aimeos' ) );
78
-			$context->setFilesystemManager( $fs );
77
+			$fs = new \Aimeos\MW\Filesystem\Manager\Laravel(app('filesystem'), $config, storage_path('aimeos'));
78
+			$context->setFilesystemManager($fs);
79 79
 
80
-			$mail = new \Aimeos\MW\Mail\Swift( function() { return app( 'mailer' )->getSwiftMailer(); } );
81
-			$context->setMail( $mail );
80
+			$mail = new \Aimeos\MW\Mail\Swift(function() { return app('mailer')->getSwiftMailer(); } );
81
+			$context->setMail($mail);
82 82
 
83
-			$logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager( $context );
84
-			$context->setLogger( $logger );
83
+			$logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context);
84
+			$context->setLogger($logger);
85 85
 
86
-			$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context );
87
-			$context->setCache( $cache );
86
+			$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context);
87
+			$context->setCache($cache);
88 88
 
89 89
 			self::$context = $context;
90 90
 		}
91 91
 
92 92
 		$context = self::$context;
93 93
 
94
-		if( $locale === true )
94
+		if ($locale === true)
95 95
 		{
96
-			$localeItem = $this->getLocale( $context );
96
+			$localeItem = $this->getLocale($context);
97 97
 			$langid = $localeItem->getLanguageId();
98 98
 
99
-			$context->setLocale( $localeItem );
100
-			$context->setI18n( app('\Aimeos\Shop\Base\I18n')->get( array( $langid ) ) );
99
+			$context->setLocale($localeItem);
100
+			$context->setI18n(app('\Aimeos\Shop\Base\I18n')->get(array($langid)));
101 101
 		}
102 102
 
103
-		$session = new \Aimeos\MW\Session\Laravel5( $this->session );
104
-		$context->setSession( $session );
103
+		$session = new \Aimeos\MW\Session\Laravel5($this->session);
104
+		$context->setSession($session);
105 105
 
106
-		$this->addUser( $context );
106
+		$this->addUser($context);
107 107
 
108 108
 		return $context;
109 109
 	}
@@ -114,20 +114,20 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
116 116
 	 */
117
-	protected function addUser( \Aimeos\MShop\Context\Item\Iface $context )
117
+	protected function addUser(\Aimeos\MShop\Context\Item\Iface $context)
118 118
 	{
119
-		if( ( $userid = Auth::id() ) !== null )
119
+		if (($userid = Auth::id()) !== null)
120 120
 		{
121
-			$context->setUserId( $userid );
122
-			$context->setGroupIds( function() use ( $context, $userid )
121
+			$context->setUserId($userid);
122
+			$context->setGroupIds(function() use ($context, $userid)
123 123
 			{
124
-				$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
125
-				return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups();
124
+				$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
125
+				return $manager->getItem($userid, array('customer/group'))->getGroups();
126 126
 			} );
127 127
 		}
128 128
 
129
-		if( ( $user = Auth::user() ) !== null ) {
130
-			$context->setEditor( $user->name );
129
+		if (($user = Auth::user()) !== null) {
130
+			$context->setEditor($user->name);
131 131
 		}
132 132
 	}
133 133
 
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function getConfig()
141 141
 	{
142
-		$default = include dirname( dirname( dirname( __DIR__ ) ) ) . DIRECTORY_SEPARATOR . 'default.php';
143
-		$conf = array_replace_recursive( $default, $this->config->get( 'shop' ) );
142
+		$default = include dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'default.php';
143
+		$conf = array_replace_recursive($default, $this->config->get('shop'));
144 144
 
145
-		$configPaths = app( '\Aimeos\Shop\Base\Aimeos' )->get()->getConfigPaths();
146
-		$config = new \Aimeos\MW\Config\PHPArray( $conf, $configPaths );
145
+		$configPaths = app('\Aimeos\Shop\Base\Aimeos')->get()->getConfigPaths();
146
+		$config = new \Aimeos\MW\Config\PHPArray($conf, $configPaths);
147 147
 
148
-		if( function_exists( 'apc_store' ) === true && $this->config->get( 'shop.apc_enabled', false ) == true ) {
149
-			$config = new \Aimeos\MW\Config\Decorator\APC( $config, $this->config->get( 'shop.apc_prefix', 'laravel:' ) );
148
+		if (function_exists('apc_store') === true && $this->config->get('shop.apc_enabled', false) == true) {
149
+			$config = new \Aimeos\MW\Config\Decorator\APC($config, $this->config->get('shop.apc_prefix', 'laravel:'));
150 150
 		}
151 151
 
152 152
 		return $config;
@@ -159,15 +159,15 @@  discard block
 block discarded – undo
159 159
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
160 160
 	 * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
161 161
 	 */
162
-	protected function getLocale( \Aimeos\MShop\Context\Item\Iface $context )
162
+	protected function getLocale(\Aimeos\MShop\Context\Item\Iface $context)
163 163
 	{
164
-		if( $this->locale === null )
164
+		if ($this->locale === null)
165 165
 		{
166
-			if( Route::current() !== null )
166
+			if (Route::current() !== null)
167 167
 			{
168
-				$site = Route::input( 'site', 'default' );
169
-				$lang = Route::input( 'locale', '' );
170
-				$currency = Route::input( 'currency', '' );
168
+				$site = Route::input('site', 'default');
169
+				$lang = Route::input('locale', '');
170
+				$currency = Route::input('currency', '');
171 171
 			}
172 172
 			else
173 173
 			{
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 				$lang = $currency = '';
176 176
 			}
177 177
 
178
-			$disableSites = $this->config->has( 'shop.disableSites' );
178
+			$disableSites = $this->config->has('shop.disableSites');
179 179
 
180
-			$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context );
181
-			$this->locale = $localeManager->bootstrap( $site, $lang, $currency, $disableSites );
180
+			$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
181
+			$this->locale = $localeManager->bootstrap($site, $lang, $currency, $disableSites);
182 182
 		}
183 183
 
184 184
 		return $this->locale;
Please login to merge, or discard this patch.