Completed
Push — master ( cf4a01...1eeaa3 )
by Aimeos
02:29
created
src/Aimeos/Shop/Base/Context.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param \Illuminate\Contracts\Config\Repository $config Configuration object
46 46
 	 * @param \Illuminate\Session\Store $session Laravel session object
47 47
 	 */
48
-	public function __construct( \Illuminate\Contracts\Config\Repository $config, \Illuminate\Session\Store $session )
48
+	public function __construct(\Illuminate\Contracts\Config\Repository $config, \Illuminate\Session\Store $session)
49 49
 	{
50 50
 		$this->config = $config;
51 51
 		$this->session = $session;
@@ -58,48 +58,48 @@  discard block
 block discarded – undo
58 58
 	 * @param boolean $locale True to add locale object to context, false if not
59 59
 	 * @return \Aimeos\MShop\Context\Item\Iface Context object
60 60
 	 */
61
-	public function get( $locale = true )
61
+	public function get($locale = true)
62 62
 	{
63
-		if( self::$context === null )
63
+		if (self::$context === null)
64 64
 		{
65 65
 			$context = new \Aimeos\MShop\Context\Item\Standard();
66 66
 
67 67
 			$config = $this->getConfig();
68
-			$context->setConfig( $config );
68
+			$context->setConfig($config);
69 69
 
70
-			$dbm = new \Aimeos\MW\DB\Manager\PDO( $config );
71
-			$context->setDatabaseManager( $dbm );
70
+			$dbm = new \Aimeos\MW\DB\Manager\PDO($config);
71
+			$context->setDatabaseManager($dbm);
72 72
 
73
-			$fs = new \Aimeos\MW\Filesystem\Laravel( app( 'filesystem.disk' ) );
74
-			$context->setFilesystem( $fs );
73
+			$fs = new \Aimeos\MW\Filesystem\Laravel(app('filesystem.disk'));
74
+			$context->setFilesystem($fs);
75 75
 
76
-			$mail = new \Aimeos\MW\Mail\Swift( function() { return app( 'mailer' )->getSwiftMailer(); } );
77
-			$context->setMail( $mail );
76
+			$mail = new \Aimeos\MW\Mail\Swift(function() { return app('mailer')->getSwiftMailer(); } );
77
+			$context->setMail($mail);
78 78
 
79
-			$logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager( $context );
80
-			$context->setLogger( $logger );
79
+			$logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context);
80
+			$context->setLogger($logger);
81 81
 
82
-			$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context );
83
-			$context->setCache( $cache );
82
+			$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context);
83
+			$context->setCache($cache);
84 84
 
85 85
 			self::$context = $context;
86 86
 		}
87 87
 
88 88
 		$context = self::$context;
89 89
 
90
-		if( $locale === true )
90
+		if ($locale === true)
91 91
 		{
92
-			$localeItem = $this->getLocale( $context );
92
+			$localeItem = $this->getLocale($context);
93 93
 			$langid = $localeItem->getLanguageId();
94 94
 
95
-			$context->setLocale( $localeItem );
96
-			$context->setI18n( app('\Aimeos\Shop\Base\I18n')->get( array( $langid ) ) );
95
+			$context->setLocale($localeItem);
96
+			$context->setI18n(app('\Aimeos\Shop\Base\I18n')->get(array($langid)));
97 97
 		}
98 98
 
99
-		$session = new \Aimeos\MW\Session\Laravel4( $this->session );
100
-		$context->setSession( $session );
99
+		$session = new \Aimeos\MW\Session\Laravel4($this->session);
100
+		$context->setSession($session);
101 101
 
102
-		$this->addUser( $context );
102
+		$this->addUser($context);
103 103
 
104 104
 		return $context;
105 105
 	}
@@ -110,20 +110,20 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
112 112
 	 */
113
-	protected function addUser( \Aimeos\MShop\Context\Item\Iface $context )
113
+	protected function addUser(\Aimeos\MShop\Context\Item\Iface $context)
114 114
 	{
115
-		if( ( $userid = \Auth::id() ) !== null )
115
+		if (($userid = \Auth::id()) !== null)
116 116
 		{
117
-			$context->setUserId( $userid );
118
-			$context->setGroupIds( function() use ( $context, $userid )
117
+			$context->setUserId($userid);
118
+			$context->setGroupIds(function() use ($context, $userid)
119 119
 			{
120
-				$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
121
-				return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups();
120
+				$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
121
+				return $manager->getItem($userid, array('customer/group'))->getGroups();
122 122
 			} );
123 123
 		}
124 124
 
125
-		if( ( $user = \Auth::user() ) !== null ) {
126
-			$context->setEditor( $user->name );
125
+		if (($user = \Auth::user()) !== null) {
126
+			$context->setEditor($user->name);
127 127
 		}
128 128
 	}
129 129
 
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	protected function getConfig()
137 137
 	{
138
-		$conf = $this->config->get( 'shop' );
138
+		$conf = $this->config->get('shop');
139 139
 
140
-		$configPaths = app( '\Aimeos\Shop\Base\Aimeos' )->get()->getConfigPaths( 'mysql' );
141
-		$config = new \Aimeos\MW\Config\PHPArray( $conf, $configPaths );
140
+		$configPaths = app('\Aimeos\Shop\Base\Aimeos')->get()->getConfigPaths('mysql');
141
+		$config = new \Aimeos\MW\Config\PHPArray($conf, $configPaths);
142 142
 
143
-		if( function_exists( 'apc_store' ) === true && $this->config->get( 'shop.apc_enabled', false ) == true ) {
144
-			$config = new \Aimeos\MW\Config\Decorator\APC( $config, $this->config->get( 'shop.apc_prefix', 'laravel:' ) );
143
+		if (function_exists('apc_store') === true && $this->config->get('shop.apc_enabled', false) == true) {
144
+			$config = new \Aimeos\MW\Config\Decorator\APC($config, $this->config->get('shop.apc_prefix', 'laravel:'));
145 145
 		}
146 146
 
147 147
 		return $config;
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
155 155
 	 * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
156 156
 	 */
157
-	protected function getLocale( \Aimeos\MShop\Context\Item\Iface $context )
157
+	protected function getLocale(\Aimeos\MShop\Context\Item\Iface $context)
158 158
 	{
159
-		if( $this->locale === null )
159
+		if ($this->locale === null)
160 160
 		{
161
-			if( \Route::current() !== null )
161
+			if (\Route::current() !== null)
162 162
 			{
163
-				$site = \Route::input( 'site', 'default' );
164
-				$lang = \Route::input( 'locale', '' );
165
-				$currency = \Route::input( 'currency', '' );
163
+				$site = \Route::input('site', 'default');
164
+				$lang = \Route::input('locale', '');
165
+				$currency = \Route::input('currency', '');
166 166
 			}
167 167
 			else
168 168
 			{
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 				$lang = $currency = '';
171 171
 			}
172 172
 
173
-			$disableSites = $this->config->has( 'shop.disableSites' );
173
+			$disableSites = $this->config->has('shop.disableSites');
174 174
 
175
-			$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context );
176
-			$this->locale = $localeManager->bootstrap( $site, $lang, $currency, $disableSites );
175
+			$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
176
+			$this->locale = $localeManager->bootstrap($site, $lang, $currency, $disableSites);
177 177
 		}
178 178
 
179 179
 		return $this->locale;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -163,8 +163,7 @@
 block discarded – undo
163 163
 				$site = \Route::input( 'site', 'default' );
164 164
 				$lang = \Route::input( 'locale', '' );
165 165
 				$currency = \Route::input( 'currency', '' );
166
-			}
167
-			else
166
+			} else
168 167
 			{
169 168
 				$site = 'default';
170 169
 				$lang = $currency = '';
Please login to merge, or discard this patch.
src/Aimeos/Shop/Command/AccountCommand.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function fire()
41 41
 	{
42
-		$context = $this->getLaravel()->make( 'Aimeos\Shop\Base\Context' )->get();
43
-		$context->setEditor( 'aimeos:account' );
42
+		$context = $this->getLaravel()->make('Aimeos\Shop\Base\Context')->get();
43
+		$context->setEditor('aimeos:account');
44 44
 
45
-		$code = $this->argument( 'email' );
46
-		if( ( $password = $this->option( 'password' ) ) === null ) {
47
-			$password = $this->secret( 'Password' );
45
+		$code = $this->argument('email');
46
+		if (($password = $this->option('password')) === null) {
47
+			$password = $this->secret('Password');
48 48
 		}
49 49
 
50
-		$user = $this->getCustomerItem( $context, $code, $password );
50
+		$user = $this->getCustomerItem($context, $code, $password);
51 51
 
52
-		if( $this->option( 'admin' ) ) {
53
-			$this->addPrivilege( $context, $user, 'admin' );
52
+		if ($this->option('admin')) {
53
+			$this->addPrivilege($context, $user, 'admin');
54 54
 		}
55 55
 	}
56 56
 
@@ -62,31 +62,31 @@  discard block
 block discarded – undo
62 62
 	 * @param string $userid Unique user ID
63 63
 	 * @param string $groupid Unique group ID
64 64
 	 */
65
-	protected function addListItem( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid )
65
+	protected function addListItem(\Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid)
66 66
 	{
67
-		$manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'lists' );
68
-		$typeid = $this->getTypeItem( $manager, 'default' )->getId();
67
+		$manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('lists');
68
+		$typeid = $this->getTypeItem($manager, 'default')->getId();
69 69
 
70 70
 		$search = $manager->createSearch();
71 71
 		$expr = array(
72
-			$search->compare( '==', 'customer.lists.parentid', $userid ),
73
-			$search->compare( '==', 'customer.lists.refid', $groupid ),
74
-			$search->compare( '==', 'customer.lists.domain', 'customer/group' ),
75
-			$search->compare( '==', 'customer.lists.typeid', $typeid ),
72
+			$search->compare('==', 'customer.lists.parentid', $userid),
73
+			$search->compare('==', 'customer.lists.refid', $groupid),
74
+			$search->compare('==', 'customer.lists.domain', 'customer/group'),
75
+			$search->compare('==', 'customer.lists.typeid', $typeid),
76 76
 		);
77
-		$search->setConditions( $search->combine( '&&', $expr ) );
78
-		$search->setSlice( 0, 1 );
77
+		$search->setConditions($search->combine('&&', $expr));
78
+		$search->setSlice(0, 1);
79 79
 
80
-		if( count( $manager->searchItems( $search ) ) === 0 )
80
+		if (count($manager->searchItems($search)) === 0)
81 81
 		{
82 82
 			$item = $manager->createItem();
83
-			$item->setDomain( 'customer/group' );
84
-			$item->setParentId( $userid );
85
-			$item->setTypeId( $typeid );
86
-			$item->setRefId( $groupid );
87
-			$item->setStatus( 1 );
83
+			$item->setDomain('customer/group');
84
+			$item->setParentId($userid);
85
+			$item->setTypeId($typeid);
86
+			$item->setRefId($groupid);
87
+			$item->setStatus(1);
88 88
 
89
-			$manager->saveItem( $item, false );
89
+			$manager->saveItem($item, false);
90 90
 		}
91 91
 	}
92 92
 
@@ -98,23 +98,23 @@  discard block
 block discarded – undo
98 98
 	 * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object
99 99
 	 * @param string $privilege Unique customer group code
100 100
 	 */
101
-	protected function addPrivilege( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $privilege )
101
+	protected function addPrivilege(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $privilege)
102 102
 	{
103
-		$this->info( sprintf( 'Add "%1$s" privilege to user "%2$s" for sites', $privilege, $user->getCode() ) );
103
+		$this->info(sprintf('Add "%1$s" privilege to user "%2$s" for sites', $privilege, $user->getCode()));
104 104
 
105
-		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context );
105
+		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
106 106
 
107
-		foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem )
107
+		foreach ($this->getSiteItems($context, $this->argument('site')) as $siteItem)
108 108
 		{
109
-			$localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false );
109
+			$localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
110 110
 
111 111
 			$lcontext = clone $context;
112
-			$lcontext->setLocale( $localeItem );
112
+			$lcontext->setLocale($localeItem);
113 113
 
114
-			$this->info( '- ' . $siteItem->getCode() );
114
+			$this->info('- ' . $siteItem->getCode());
115 115
 
116
-			$groupItem = $this->getGroupItem( $lcontext, $privilege );
117
-			$this->addListItem( $lcontext, $user->getId(), $groupItem->getId() );
116
+			$groupItem = $this->getGroupItem($lcontext, $privilege);
117
+			$this->addListItem($lcontext, $user->getId(), $groupItem->getId());
118 118
 		}
119 119
 	}
120 120
 
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 	protected function getArguments()
128 128
 	{
129 129
 		return array(
130
-			array( 'email', InputArgument::REQUIRED, 'E-mail address of the account that should be created' ),
131
-			array( 'site', InputArgument::OPTIONAL, 'Site codes to create accounts for like "default unittest" (none for all)' ),
130
+			array('email', InputArgument::REQUIRED, 'E-mail address of the account that should be created'),
131
+			array('site', InputArgument::OPTIONAL, 'Site codes to create accounts for like "default unittest" (none for all)'),
132 132
 		);
133 133
 	}
134 134
 
@@ -143,21 +143,21 @@  discard block
 block discarded – undo
143 143
 	 * @param string $password New user password
144 144
 	 * @return \Aimeos\MShop\Customer\Item\Iface Aimeos customer item object
145 145
 	 */
146
-	protected function getCustomerItem( \Aimeos\MShop\Context\Item\Iface $context, $email, $password )
146
+	protected function getCustomerItem(\Aimeos\MShop\Context\Item\Iface $context, $email, $password)
147 147
 	{
148
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
148
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
149 149
 
150 150
 		try {
151
-			$item = $manager->getItem( $email );
152
-		} catch( \Aimeos\MShop\Exception $e ) {
151
+			$item = $manager->getItem($email);
152
+		} catch (\Aimeos\MShop\Exception $e) {
153 153
 			$item = $manager->createItem();
154 154
 		}
155 155
 
156
-		$item->setCode( $email );
157
-		$item->getPaymentAddress()->setEmail( $email );
158
-		$item->setPassword( $password );
156
+		$item->setCode($email);
157
+		$item->getPaymentAddress()->setEmail($email);
158
+		$item->setPassword($password);
159 159
 
160
-		$manager->saveItem( $item );
160
+		$manager->saveItem($item);
161 161
 
162 162
 		return $item;
163 163
 	}
@@ -170,21 +170,21 @@  discard block
 block discarded – undo
170 170
 	 * @param string $code Unique customer group code
171 171
 	 * @return \Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object
172 172
 	 */
173
-	protected function getGroupItem( \Aimeos\MShop\Context\Item\Iface $context, $code )
173
+	protected function getGroupItem(\Aimeos\MShop\Context\Item\Iface $context, $code)
174 174
 	{
175
-		$manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'group' );
175
+		$manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('group');
176 176
 
177 177
 		try
178 178
 		{
179
-			$item = $manager->getItem( $code );
179
+			$item = $manager->getItem($code);
180 180
 		}
181
-		catch( \Aimeos\MShop\Exception $e )
181
+		catch (\Aimeos\MShop\Exception $e)
182 182
 		{
183 183
 			$item = $manager->createItem();
184
-			$item->setLabel( $code );
185
-			$item->setCode( $code );
184
+			$item->setLabel($code);
185
+			$item->setCode($code);
186 186
 
187
-			$manager->saveItem( $item );
187
+			$manager->saveItem($item);
188 188
 		}
189 189
 
190 190
 		return $item;
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	protected function getOptions()
200 200
 	{
201 201
 		return array(
202
-				array( 'password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)' ),
203
-				array( 'admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges' ),
202
+				array('password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)'),
203
+				array('admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges'),
204 204
 		);
205 205
 	}
206 206
 
@@ -213,23 +213,23 @@  discard block
 block discarded – undo
213 213
 	 * @return \Aimeos\MShop\Common\Item\Type\Iface Aimeos customer list type item object
214 214
 	 * @throws \Exception If no customer list type item for the given code is found
215 215
 	 */
216
-	protected function getTypeItem( \Aimeos\MShop\Common\Manager\Iface $listManager, $code )
216
+	protected function getTypeItem(\Aimeos\MShop\Common\Manager\Iface $listManager, $code)
217 217
 	{
218
-		$manager = $listManager->getSubmanager( 'type' );
218
+		$manager = $listManager->getSubmanager('type');
219 219
 
220 220
 		$search = $manager->createSearch();
221 221
 		$expr = array(
222
-			$search->compare( '==', 'customer.lists.type.domain', 'customer/group' ),
223
-			$search->compare( '==', 'customer.lists.type.code', $code ),
222
+			$search->compare('==', 'customer.lists.type.domain', 'customer/group'),
223
+			$search->compare('==', 'customer.lists.type.code', $code),
224 224
 		);
225
-		$search->setConditions( $search->combine( '&&', $expr ) );
225
+		$search->setConditions($search->combine('&&', $expr));
226 226
 
227
-		$result = $manager->searchItems( $search );
227
+		$result = $manager->searchItems($search);
228 228
 
229
-		if( ( $item = reset( $result ) ) === false )
229
+		if (($item = reset($result)) === false)
230 230
 		{
231
-			$msg = sprintf( 'No user list type item for domain "%1$s" and code "%2$s" found', 'customer/group', $code );
232
-			throw new \Exception( $msg );
231
+			$msg = sprintf('No user list type item for domain "%1$s" and code "%2$s" found', 'customer/group', $code);
232
+			throw new \Exception($msg);
233 233
 		}
234 234
 
235 235
 		return $item;
Please login to merge, or discard this patch.