Completed
Push — master ( 89095d...9bae21 )
by Aimeos
01:33
created
lib/custom/src/MShop/Customer/Manager/Ezpublish.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @param array $siteids List of IDs for sites whose entries should be deleted
228 228
 	 */
229
-	public function cleanup( array $siteids )
229
+	public function cleanup(array $siteids)
230 230
 	{
231 231
 		$path = 'mshop/customer/manager/submanagers';
232
-		foreach( $this->getContext()->getConfig()->get( $path, ['address', 'group', 'lists', 'property'] ) as $domain ) {
233
-			$this->getObject()->getSubManager( $domain )->cleanup( $siteids );
232
+		foreach ($this->getContext()->getConfig()->get($path, ['address', 'group', 'lists', 'property']) as $domain) {
233
+			$this->getObject()->getSubManager($domain)->cleanup($siteids);
234 234
 		}
235 235
 	}
236 236
 
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @param array $ids List of IDs
242 242
 	 */
243
-	public function deleteItems( array $ids )
243
+	public function deleteItems(array $ids)
244 244
 	{
245 245
 		$service = $this->getContext()->getEzUserService();
246 246
 
247
-		foreach( $ids as $id ) {
248
-			$service->deleteUser( $service->loadUser( $id ) );
247
+		foreach ($ids as $id) {
248
+			$service->deleteUser($service->loadUser($id));
249 249
 		}
250 250
 	}
251 251
 
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 	 * @param boolean $withsub Return also attributes of sub-managers if true
257 257
 	 * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface
258 258
 	 */
259
-	public function getSearchAttributes( $withsub = true )
259
+	public function getSearchAttributes($withsub = true)
260 260
 	{
261 261
 		$path = 'mshop/customer/manager/submanagers';
262 262
 
263
-		return $this->getSearchAttributesBase( $this->searchConfig, $path, ['address', 'group', 'lists', 'property'], $withsub );
263
+		return $this->getSearchAttributesBase($this->searchConfig, $path, ['address', 'group', 'lists', 'property'], $withsub);
264 264
 	}
265 265
 
266 266
 
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
272 272
 	 * @return mixed Manager for different extensions, e.g stock, tags, locations, etc.
273 273
 	 */
274
-	public function getSubManager( $manager, $name = null )
274
+	public function getSubManager($manager, $name = null)
275 275
 	{
276
-		return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'Ezpublish' : $name ) );
276
+		return $this->getSubManagerBase('customer', $manager, ($name === null ? 'Ezpublish' : $name));
277 277
 	}
278 278
 
279 279
 
@@ -284,96 +284,96 @@  discard block
 block discarded – undo
284 284
 	 * @param boolean $fetch True if the new ID should be returned in the item
285 285
 	 * @return \Aimeos\MShop\Common\Item\Iface $item Updated item including the generated ID
286 286
 	 */
287
-	public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
287
+	public function saveItem(\Aimeos\MShop\Common\Item\Iface $item, $fetch = true)
288 288
 	{
289
-		self::checkClass( '\\Aimeos\\MShop\\Customer\\Item\\Iface', $item );
289
+		self::checkClass('\\Aimeos\\MShop\\Customer\\Item\\Iface', $item);
290 290
 
291
-		if( !$item->isModified() )
291
+		if (!$item->isModified())
292 292
 		{
293
-			$item = $this->savePropertyItems( $item, 'customer' );
294
-			$item = $this->saveAddressItems( $item, 'customer' );
295
-			return $this->saveListItems( $item, 'customer' );
293
+			$item = $this->savePropertyItems($item, 'customer');
294
+			$item = $this->saveAddressItems($item, 'customer');
295
+			return $this->saveListItems($item, 'customer');
296 296
 		}
297 297
 
298 298
 		$context = $this->getContext();
299 299
 
300 300
 		$class = '\Aimeos\MShop\Context\Item\Ezpublish';
301
-		if( !is_a( $context, $class ) ) {
302
-			throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Object is not of required type "%1$s"', $class ) );
301
+		if (!is_a($context, $class)) {
302
+			throw new \Aimeos\MShop\Customer\Exception(sprintf('Object is not of required type "%1$s"', $class));
303 303
 		}
304 304
 
305 305
 		$service = $context->getEzUserService();
306 306
 		$email = $item->getPaymentAddress()->getEmail();
307 307
 
308
-		if( $item->getId() !== null )
308
+		if ($item->getId() !== null)
309 309
 		{
310 310
 			$struct = $service->newUserUpdateStruct();
311 311
 			$struct->password = $item->getPassword();
312 312
 			$struct->enabled = $item->getStatus();
313 313
 			$struct->email = $email;
314 314
 
315
-			$user = $service->loadUser( $item->getId() );
316
-			$service->updateUser( $user, $struct );
315
+			$user = $service->loadUser($item->getId());
316
+			$service->updateUser($user, $struct);
317 317
 		}
318 318
 		else
319 319
 		{
320
-			$struct = $service->newUserCreateStruct( $item->getCode(), $email, $item->getPassword(), 'eng-GB' );
320
+			$struct = $service->newUserCreateStruct($item->getCode(), $email, $item->getPassword(), 'eng-GB');
321 321
 			$struct->enabled = $item->getStatus();
322 322
 
323
-			$user = $service->createUser( $struct, [] );
324
-			$item->setId( $user->getUserId() );
323
+			$user = $service->createUser($struct, []);
324
+			$item->setId($user->getUserId());
325 325
 		}
326 326
 
327 327
 		$dbm = $context->getDatabaseManager();
328 328
 		$dbname = $this->getResourceName();
329
-		$conn = $dbm->acquire( $dbname );
329
+		$conn = $dbm->acquire($dbname);
330 330
 
331 331
 		try
332 332
 		{
333
-			$date = date( 'Y-m-d H:i:s' );
334
-			$ctime = ( $item->getTimeCreated() ? $item->getTimeCreated() : $date );
333
+			$date = date('Y-m-d H:i:s');
334
+			$ctime = ($item->getTimeCreated() ? $item->getTimeCreated() : $date);
335 335
 			$billingAddress = $item->getPaymentAddress();
336 336
 
337 337
 			$path = 'mshop/customer/manager/ezpublish/update';
338
-			$stmt = $this->getCachedStatement( $conn, $path );
339
-
340
-			$stmt->bind( 1, $billingAddress->getCompany() );
341
-			$stmt->bind( 2, $billingAddress->getVatID() );
342
-			$stmt->bind( 3, $billingAddress->getSalutation() );
343
-			$stmt->bind( 4, $billingAddress->getTitle() );
344
-			$stmt->bind( 5, $billingAddress->getFirstname() );
345
-			$stmt->bind( 6, $billingAddress->getLastname() );
346
-			$stmt->bind( 7, $billingAddress->getAddress1() );
347
-			$stmt->bind( 8, $billingAddress->getAddress2() );
348
-			$stmt->bind( 9, $billingAddress->getAddress3() );
349
-			$stmt->bind( 10, $billingAddress->getPostal() );
350
-			$stmt->bind( 11, $billingAddress->getCity() );
351
-			$stmt->bind( 12, $billingAddress->getState() );
352
-			$stmt->bind( 13, $billingAddress->getCountryId() );
353
-			$stmt->bind( 14, $billingAddress->getLanguageId() );
354
-			$stmt->bind( 15, $billingAddress->getTelephone() );
355
-			$stmt->bind( 16, $billingAddress->getTelefax() );
356
-			$stmt->bind( 17, $billingAddress->getWebsite() );
357
-			$stmt->bind( 18, $item->getBirthday() );
358
-			$stmt->bind( 19, $item->getDateVerified() );
359
-			$stmt->bind( 20, $date ); // Modification time
360
-			$stmt->bind( 21, $context->getEditor() );
361
-			$stmt->bind( 22, $ctime ); // Creation time
362
-			$stmt->bind( 23, $item->getId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
338
+			$stmt = $this->getCachedStatement($conn, $path);
339
+
340
+			$stmt->bind(1, $billingAddress->getCompany());
341
+			$stmt->bind(2, $billingAddress->getVatID());
342
+			$stmt->bind(3, $billingAddress->getSalutation());
343
+			$stmt->bind(4, $billingAddress->getTitle());
344
+			$stmt->bind(5, $billingAddress->getFirstname());
345
+			$stmt->bind(6, $billingAddress->getLastname());
346
+			$stmt->bind(7, $billingAddress->getAddress1());
347
+			$stmt->bind(8, $billingAddress->getAddress2());
348
+			$stmt->bind(9, $billingAddress->getAddress3());
349
+			$stmt->bind(10, $billingAddress->getPostal());
350
+			$stmt->bind(11, $billingAddress->getCity());
351
+			$stmt->bind(12, $billingAddress->getState());
352
+			$stmt->bind(13, $billingAddress->getCountryId());
353
+			$stmt->bind(14, $billingAddress->getLanguageId());
354
+			$stmt->bind(15, $billingAddress->getTelephone());
355
+			$stmt->bind(16, $billingAddress->getTelefax());
356
+			$stmt->bind(17, $billingAddress->getWebsite());
357
+			$stmt->bind(18, $item->getBirthday());
358
+			$stmt->bind(19, $item->getDateVerified());
359
+			$stmt->bind(20, $date); // Modification time
360
+			$stmt->bind(21, $context->getEditor());
361
+			$stmt->bind(22, $ctime); // Creation time
362
+			$stmt->bind(23, $item->getId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
363 363
 
364 364
 			$stmt->execute()->finish();
365 365
 
366
-			$dbm->release( $conn, $dbname );
366
+			$dbm->release($conn, $dbname);
367 367
 		}
368
-		catch( \Exception $e )
368
+		catch (\Exception $e)
369 369
 		{
370
-			$dbm->release( $conn, $dbname );
370
+			$dbm->release($conn, $dbname);
371 371
 			throw $e;
372 372
 		}
373 373
 
374
-		$item = $this->savePropertyItems( $item, 'customer' );
375
-		$item = $this->saveAddressItems( $item, 'customer' );
376
-		return $this->saveListItems( $item, 'customer' );
374
+		$item = $this->savePropertyItems($item, 'customer');
375
+		$item = $this->saveAddressItems($item, 'customer');
376
+		return $this->saveListItems($item, 'customer');
377 377
 	}
378 378
 
379 379
 
@@ -385,11 +385,11 @@  discard block
 block discarded – undo
385 385
 	 * @return array List of items implementing \Aimeos\MShop\Customer\Item\Iface
386 386
 	 * @throws \Aimeos\MShop\Customer\Exception If creating items failed
387 387
 	 */
388
-	public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null )
388
+	public function searchItems(\Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null)
389 389
 	{
390 390
 		$dbm = $this->getContext()->getDatabaseManager();
391 391
 		$dbname = $this->getResourceName();
392
-		$conn = $dbm->acquire( $dbname );
392
+		$conn = $dbm->acquire($dbname);
393 393
 		$map = [];
394 394
 
395 395
 		try
@@ -397,34 +397,34 @@  discard block
 block discarded – undo
397 397
 			$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
398 398
 			$cfgPathSearch = 'mshop/customer/manager/ezpublish/search';
399 399
 			$cfgPathCount = 'mshop/customer/manager/ezpublish/count';
400
-			$required = array( 'customer' );
400
+			$required = array('customer');
401 401
 
402
-			$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level );
402
+			$results = $this->searchItemsBase($conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level);
403 403
 
404
-			while( ( $row = $results->fetch() ) !== false )
404
+			while (($row = $results->fetch()) !== false)
405 405
 			{
406
-				$map[ $row['customer.id'] ] = $row;
407
-				$map[ $row['customer.id'] ]['groups'] = [];
406
+				$map[$row['customer.id']] = $row;
407
+				$map[$row['customer.id']]['groups'] = [];
408 408
 			}
409 409
 
410 410
 
411 411
 			$path = 'mshop/customer/manager/ezpublish/groups';
412
-			$stmt = $conn->create( $this->getGroupSql( array_keys( $map ), $path ) );
412
+			$stmt = $conn->create($this->getGroupSql(array_keys($map), $path));
413 413
 			$results = $stmt->execute();
414 414
 
415
-			while( ( $row = $results->fetch() ) !== false ) {
416
-				$map[ $row['contentobject_id'] ]['groups'][] = $row['role_id'];
415
+			while (($row = $results->fetch()) !== false) {
416
+				$map[$row['contentobject_id']]['groups'][] = $row['role_id'];
417 417
 			}
418 418
 
419
-			$dbm->release( $conn, $dbname );
419
+			$dbm->release($conn, $dbname);
420 420
 		}
421
-		catch( \Exception $e )
421
+		catch (\Exception $e)
422 422
 		{
423
-			$dbm->release( $conn, $dbname  );
423
+			$dbm->release($conn, $dbname);
424 424
 			throw $e;
425 425
 		}
426 426
 
427
-		return $this->buildItems( $map, $ref, 'customer' );
427
+		return $this->buildItems($map, $ref, 'customer');
428 428
 	}
429 429
 
430 430
 
@@ -437,10 +437,10 @@  discard block
 block discarded – undo
437 437
 	 * @param array $addresses List of address items of the customer item
438 438
 	 * @return \Aimeos\MShop\Customer\Item\Iface New customer item
439 439
 	 */
440
-	protected function createItemBase( array $values = [], array $listItems = [], array $refItems = [],
441
-		array $addresses = [], array $propItems = [] )
440
+	protected function createItemBase(array $values = [], array $listItems = [], array $refItems = [],
441
+		array $addresses = [], array $propItems = [])
442 442
 	{
443
-		$address = new \Aimeos\MShop\Common\Item\Address\Simple( 'customer.', $values );
443
+		$address = new \Aimeos\MShop\Common\Item\Address\Simple('customer.', $values);
444 444
 
445 445
 		return new \Aimeos\MShop\Customer\Item\Ezpublish(
446 446
 			$address, $values, $listItems, $refItems,
@@ -456,18 +456,18 @@  discard block
 block discarded – undo
456 456
 	 * @param string $cfgpath Configuration path to the SQL statement
457 457
 	 * @return string SQL statement ready for execution
458 458
 	 */
459
-	protected function getGroupSql( array $ids, $cfgpath )
459
+	protected function getGroupSql(array $ids, $cfgpath)
460 460
 	{
461
-		if( empty( $ids ) ) { return '1=1'; }
461
+		if (empty($ids)) { return '1=1'; }
462 462
 
463 463
 		$search = $this->getObject()->createSearch();
464
-		$search->setConditions( $search->compare( '==', 'id', $ids ) );
464
+		$search->setConditions($search->compare('==', 'id', $ids));
465 465
 
466
-		$types = array( 'id' => \Aimeos\MW\DB\Statement\Base::PARAM_INT );
467
-		$translations = array( 'id' => '"contentobject_id"' );
466
+		$types = array('id' => \Aimeos\MW\DB\Statement\Base::PARAM_INT);
467
+		$translations = array('id' => '"contentobject_id"');
468 468
 
469
-		$cond = $search->getConditionSource( $types, $translations );
469
+		$cond = $search->getConditionSource($types, $translations);
470 470
 
471
-		return str_replace( ':cond', $cond, $this->getSqlConfig( $cfgpath ) );
471
+		return str_replace(':cond', $cond, $this->getSqlConfig($cfgpath));
472 472
 	}
473 473
 }
Please login to merge, or discard this patch.