Completed
Push — master ( 73a491...629308 )
by Aimeos
11:13
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,51 +62,51 @@  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
-			$mq = new \Aimeos\MW\MQueue\Manager\Standard( $config );
81
-			$context->setMessageQueueManager( $mq );
80
+			$mq = new \Aimeos\MW\MQueue\Manager\Standard($config);
81
+			$context->setMessageQueueManager($mq);
82 82
 
83
-			$mail = new \Aimeos\MW\Mail\Swift( function() { return app( 'mailer' )->getSwiftMailer(); } );
84
-			$context->setMail( $mail );
83
+			$mail = new \Aimeos\MW\Mail\Swift(function() { return app('mailer')->getSwiftMailer(); } );
84
+			$context->setMail($mail);
85 85
 
86
-			$logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager( $context );
87
-			$context->setLogger( $logger );
86
+			$logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context);
87
+			$context->setLogger($logger);
88 88
 
89
-			$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context );
90
-			$context->setCache( $cache );
89
+			$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context);
90
+			$context->setCache($cache);
91 91
 
92 92
 			self::$context = $context;
93 93
 		}
94 94
 
95 95
 		$context = self::$context;
96 96
 
97
-		if( $locale === true )
97
+		if ($locale === true)
98 98
 		{
99
-			$localeItem = $this->getLocale( $context );
99
+			$localeItem = $this->getLocale($context);
100 100
 			$langid = $localeItem->getLanguageId();
101 101
 
102
-			$context->setLocale( $localeItem );
103
-			$context->setI18n( app('\Aimeos\Shop\Base\I18n')->get( array( $langid ) ) );
102
+			$context->setLocale($localeItem);
103
+			$context->setI18n(app('\Aimeos\Shop\Base\I18n')->get(array($langid)));
104 104
 		}
105 105
 
106
-		$session = new \Aimeos\MW\Session\Laravel5( $this->session );
107
-		$context->setSession( $session );
106
+		$session = new \Aimeos\MW\Session\Laravel5($this->session);
107
+		$context->setSession($session);
108 108
 
109
-		$this->addUser( $context );
109
+		$this->addUser($context);
110 110
 
111 111
 		return $context;
112 112
 	}
@@ -117,20 +117,20 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
119 119
 	 */
120
-	protected function addUser( \Aimeos\MShop\Context\Item\Iface $context )
120
+	protected function addUser(\Aimeos\MShop\Context\Item\Iface $context)
121 121
 	{
122
-		if( ( $userid = Auth::id() ) !== null )
122
+		if (($userid = Auth::id()) !== null)
123 123
 		{
124
-			$context->setUserId( $userid );
125
-			$context->setGroupIds( function() use ( $context, $userid )
124
+			$context->setUserId($userid);
125
+			$context->setGroupIds(function() use ($context, $userid)
126 126
 			{
127
-				$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
128
-				return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups();
127
+				$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
128
+				return $manager->getItem($userid, array('customer/group'))->getGroups();
129 129
 			} );
130 130
 		}
131 131
 
132
-		if( ( $user = Auth::user() ) !== null ) {
133
-			$context->setEditor( $user->name );
132
+		if (($user = Auth::user()) !== null) {
133
+			$context->setEditor($user->name);
134 134
 		}
135 135
 	}
136 136
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	protected function getConfig()
144 144
 	{
145
-		$configPaths = app( '\Aimeos\Shop\Base\Aimeos' )->get()->getConfigPaths();
146
-		$config = new \Aimeos\MW\Config\PHPArray( $this->config->get( 'shop' ), $configPaths );
145
+		$configPaths = app('\Aimeos\Shop\Base\Aimeos')->get()->getConfigPaths();
146
+		$config = new \Aimeos\MW\Config\PHPArray($this->config->get('shop'), $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->get( 'shop.disableSites', true );
178
+			$disableSites = $this->config->get('shop.disableSites', true);
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.