Completed
Push — master ( 291525...463da6 )
by Aimeos
02:39
created
Service/Context.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param Container $container Container object to access parameters
33 33
 	 */
34
-	public function __construct( Container $container )
34
+	public function __construct(Container $container)
35 35
 	{
36 36
 		$this->container = $container;
37 37
 	}
@@ -44,37 +44,37 @@  discard block
 block discarded – undo
44 44
 	 * @param string $type Configuration type ("frontend" or "backend")
45 45
 	 * @return \Aimeos\MShop\Context\Item\Iface Context object
46 46
 	 */
47
-	public function get( $locale = true, $type = 'frontend' )
47
+	public function get($locale = true, $type = 'frontend')
48 48
 	{
49
-		$config = $this->container->get( 'aimeos_config' )->get( $type );
49
+		$config = $this->container->get('aimeos_config')->get($type);
50 50
 
51
-		if( self::$context === null )
51
+		if (self::$context === null)
52 52
 		{
53 53
 			$context = new \Aimeos\MShop\Context\Item\Standard();
54
-			$context->setConfig( $config );
54
+			$context->setConfig($config);
55 55
 
56
-			$this->addDataBaseManager( $context );
57
-			$this->addFilesystemManager( $context );
58
-			$this->addMessageQueueManager( $context );
59
-			$this->addLogger( $context );
60
-			$this->addCache( $context );
61
-			$this->addMailer( $context);
56
+			$this->addDataBaseManager($context);
57
+			$this->addFilesystemManager($context);
58
+			$this->addMessageQueueManager($context);
59
+			$this->addLogger($context);
60
+			$this->addCache($context);
61
+			$this->addMailer($context);
62 62
 
63 63
 			self::$context = $context;
64 64
 		}
65 65
 
66 66
 		$context = self::$context;
67
-		$context->setConfig( $config );
67
+		$context->setConfig($config);
68 68
 
69
-		if( $locale === true )
69
+		if ($locale === true)
70 70
 		{
71
-			$localeItem = $this->container->get('aimeos_locale')->get( $context );
72
-			$context->setI18n( $this->container->get('aimeos_i18n')->get( array( $localeItem->getLanguageId() ) ) );
73
-			$context->setLocale( $localeItem );
71
+			$localeItem = $this->container->get('aimeos_locale')->get($context);
72
+			$context->setI18n($this->container->get('aimeos_i18n')->get(array($localeItem->getLanguageId())));
73
+			$context->setLocale($localeItem);
74 74
 		}
75 75
 
76
-		$this->addSession( $context );
77
-		$this->addUserGroups( $context);
76
+		$this->addSession($context);
77
+		$this->addUserGroups($context);
78 78
 
79 79
 		return $context;
80 80
 	}
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object including config
87 87
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
88 88
 	 */
89
-	protected function addCache( \Aimeos\MShop\Context\Item\Iface $context )
89
+	protected function addCache(\Aimeos\MShop\Context\Item\Iface $context)
90 90
 	{
91
-		$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context );
92
-		$context->setCache( $cache );
91
+		$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context);
92
+		$context->setCache($cache);
93 93
 
94 94
 		return $context;
95 95
 	}
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
102 102
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
103 103
 	 */
104
-	protected function addDatabaseManager( \Aimeos\MShop\Context\Item\Iface $context )
104
+	protected function addDatabaseManager(\Aimeos\MShop\Context\Item\Iface $context)
105 105
 	{
106
-		$dbm = new \Aimeos\MW\DB\Manager\DBAL( $context->getConfig() );
107
-		$context->setDatabaseManager( $dbm );
106
+		$dbm = new \Aimeos\MW\DB\Manager\DBAL($context->getConfig());
107
+		$context->setDatabaseManager($dbm);
108 108
 
109 109
 		return $context;
110 110
 	}
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
117 117
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
118 118
 	 */
119
-	protected function addFilesystemManager( \Aimeos\MShop\Context\Item\Iface $context )
119
+	protected function addFilesystemManager(\Aimeos\MShop\Context\Item\Iface $context)
120 120
 	{
121
-		$fs = new \Aimeos\MW\Filesystem\Manager\Standard( $context->getConfig() );
122
-		$context->setFilesystemManager( $fs );
121
+		$fs = new \Aimeos\MW\Filesystem\Manager\Standard($context->getConfig());
122
+		$context->setFilesystemManager($fs);
123 123
 
124 124
 		return $context;
125 125
 	}
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
132 132
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
133 133
 	 */
134
-	protected function addLogger( \Aimeos\MShop\Context\Item\Iface $context )
134
+	protected function addLogger(\Aimeos\MShop\Context\Item\Iface $context)
135 135
 	{
136
-		$logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager( $context );
137
-		$context->setLogger( $logger );
136
+		$logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context);
137
+		$context->setLogger($logger);
138 138
 
139 139
 		return $context;
140 140
 	}
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
148 148
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
149 149
 	 */
150
-	protected function addMailer( \Aimeos\MShop\Context\Item\Iface $context )
150
+	protected function addMailer(\Aimeos\MShop\Context\Item\Iface $context)
151 151
 	{
152 152
 		$container = $this->container;
153
-		$mail = new \Aimeos\MW\Mail\Swift( function() use ( $container) { return $container->get( 'mailer' ); } );
154
-		$context->setMail( $mail );
153
+		$mail = new \Aimeos\MW\Mail\Swift(function() use ($container) { return $container->get('mailer'); } );
154
+		$context->setMail($mail);
155 155
 
156 156
 		return $context;
157 157
 	}
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
164 164
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
165 165
 	 */
166
-	protected function addMessageQueueManager( \Aimeos\MShop\Context\Item\Iface $context )
166
+	protected function addMessageQueueManager(\Aimeos\MShop\Context\Item\Iface $context)
167 167
 	{
168
-		$mq = new \Aimeos\MW\MQueue\Manager\Standard( $context->getConfig() );
169
-		$context->setMessageQueueManager( $mq );
168
+		$mq = new \Aimeos\MW\MQueue\Manager\Standard($context->getConfig());
169
+		$context->setMessageQueueManager($mq);
170 170
 
171 171
 		return $context;
172 172
 	}
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
179 179
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
180 180
 	 */
181
-	protected function addSession( \Aimeos\MShop\Context\Item\Iface $context )
181
+	protected function addSession(\Aimeos\MShop\Context\Item\Iface $context)
182 182
 	{
183
-		$session = new \Aimeos\MW\Session\Symfony2( $this->container->get( 'session' ) );
184
-		$context->setSession( $session );
183
+		$session = new \Aimeos\MW\Session\Symfony2($this->container->get('session'));
184
+		$context->setSession($session);
185 185
 
186 186
 		return $context;
187 187
 	}
@@ -192,35 +192,35 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
194 194
 	 */
195
-	protected function addUserGroups( \Aimeos\MShop\Context\Item\Iface $context )
195
+	protected function addUserGroups(\Aimeos\MShop\Context\Item\Iface $context)
196 196
 	{
197 197
 		$username = '';
198
-		$token = $this->container->get( 'security.token_storage' )->getToken();
198
+		$token = $this->container->get('security.token_storage')->getToken();
199 199
 
200
-		if( is_object( $token ) )
200
+		if (is_object($token))
201 201
 		{
202
-			if( method_exists( $token->getUser(), 'getId' ) )
202
+			if (method_exists($token->getUser(), 'getId'))
203 203
 			{
204 204
 				$userid = $token->getUser()->getId();
205
-				$context->setUserId( $userid );
206
-				$context->setGroupIds( function() use ( $context, $userid )
205
+				$context->setUserId($userid);
206
+				$context->setGroupIds(function() use ($context, $userid)
207 207
 				{
208
-					$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
209
-					return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups();
208
+					$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
209
+					return $manager->getItem($userid, array('customer/group'))->getGroups();
210 210
 				} );
211 211
 			}
212 212
 
213
-			if( is_object( $token->getUser() ) ) {
214
-				$username =  $token->getUser()->getUsername();
213
+			if (is_object($token->getUser())) {
214
+				$username = $token->getUser()->getUsername();
215 215
 			} else {
216 216
 				$username = $token->getUser();
217 217
 			}
218 218
 		}
219
-		elseif( $this->container->has( 'request' ) )
219
+		elseif ($this->container->has('request'))
220 220
 		{
221
-			$username = $this->container->get( 'request' )->getClientIp();
221
+			$username = $this->container->get('request')->getClientIp();
222 222
 		}
223 223
 
224
-		$context->setEditor( $username );
224
+		$context->setEditor($username);
225 225
 	}
226 226
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -215,8 +215,7 @@
 block discarded – undo
215 215
 			} else {
216 216
 				$username = $token->getUser();
217 217
 			}
218
-		}
219
-		elseif( $this->container->has( 'request' ) )
218
+		} elseif( $this->container->has( 'request' ) )
220 219
 		{
221 220
 			$username = $this->container->get( 'request' )->getClientIp();
222 221
 		}
Please login to merge, or discard this patch.