Completed
Push — master ( 922d11...3ce384 )
by Aimeos
02:02
created
lib/custom/src/MShop/Customer/Manager/FosUser.php 1 patch
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 	 *
244 244
 	 * @param array $siteids List of IDs for sites whose entries should be deleted
245 245
 	 */
246
-	public function cleanup( array $siteids )
246
+	public function cleanup(array $siteids)
247 247
 	{
248 248
 		$path = 'mshop/customer/manager/submanagers';
249
-		foreach( $this->getContext()->getConfig()->get( $path, array( 'address', 'lists' ) ) as $domain ) {
250
-			$this->getObject()->getSubManager( $domain )->cleanup( $siteids );
249
+		foreach ($this->getContext()->getConfig()->get($path, array('address', 'lists')) as $domain) {
250
+			$this->getObject()->getSubManager($domain)->cleanup($siteids);
251 251
 		}
252 252
 	}
253 253
 
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @param array $ids List of IDs
259 259
 	 */
260
-	public function deleteItems( array $ids )
260
+	public function deleteItems(array $ids)
261 261
 	{
262 262
 		$path = 'mshop/customer/manager/fosuser/delete';
263
-		$this->deleteItemsBase( $ids, $path, false );
263
+		$this->deleteItemsBase($ids, $path, false);
264 264
 	}
265 265
 
266 266
 
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	 * @param boolean $withsub Return also attributes of sub-managers if true
271 271
 	 * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface
272 272
 	 */
273
-	public function getSearchAttributes( $withsub = true )
273
+	public function getSearchAttributes($withsub = true)
274 274
 	{
275 275
 		$path = 'mshop/customer/manager/submanagers';
276 276
 
277
-		return $this->getSearchAttributesBase( $this->searchConfig, $path, array( 'address', 'lists' ), $withsub );
277
+		return $this->getSearchAttributesBase($this->searchConfig, $path, array('address', 'lists'), $withsub);
278 278
 	}
279 279
 
280 280
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 */
286 286
 	public function createItem()
287 287
 	{
288
-		return $this->createItemBase( ['customer.siteid' => $this->getContext()->getLocale()->getSiteId()] );
288
+		return $this->createItemBase(['customer.siteid' => $this->getContext()->getLocale()->getSiteId()]);
289 289
 	}
290 290
 
291 291
 
@@ -296,29 +296,29 @@  discard block
 block discarded – undo
296 296
 	 * @param boolean $fetch True if the new ID should be returned in the item
297 297
 	 * @return \Aimeos\MShop\Common\Item\Iface $item Updated item including the generated ID
298 298
 	 */
299
-	public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
299
+	public function saveItem(\Aimeos\MShop\Common\Item\Iface $item, $fetch = true)
300 300
 	{
301 301
 		$iface = '\\Aimeos\\MShop\\Customer\\Item\\FosUser';
302
-		if( !( $item instanceof $iface ) ) {
303
-			throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
302
+		if (!($item instanceof $iface)) {
303
+			throw new \Aimeos\MShop\Customer\Exception(sprintf('Object is not of required type "%1$s"', $iface));
304 304
 		}
305 305
 
306
-		if( !$item->isModified() ) {
306
+		if (!$item->isModified()) {
307 307
 			return $item;
308 308
 		}
309 309
 
310 310
 		$context = $this->getContext();
311 311
 		$dbm = $context->getDatabaseManager();
312 312
 		$dbname = $this->getResourceName();
313
-		$conn = $dbm->acquire( $dbname );
313
+		$conn = $dbm->acquire($dbname);
314 314
 
315 315
 		try
316 316
 		{
317 317
 			$id = $item->getId();
318
-			$date = date( 'Y-m-d H:i:s' );
318
+			$date = date('Y-m-d H:i:s');
319 319
 			$billingAddress = $item->getPaymentAddress();
320 320
 
321
-			if( $id === null )
321
+			if ($id === null)
322 322
 			{
323 323
 				/** mshop/customer/manager/fosuser/insert
324 324
 				 * Inserts a new customer record into the database table
@@ -382,51 +382,51 @@  discard block
 block discarded – undo
382 382
 				$path = 'mshop/customer/manager/fosuser/update';
383 383
 			}
384 384
 
385
-			$stmt = $this->getCachedStatement( $conn, $path );
386
-
387
-			$stmt->bind( 1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
388
-			$stmt->bind( 2, $item->getCode() ); // canonical username
389
-			$stmt->bind( 3, $item->getCode() ); // username
390
-			$stmt->bind( 4, $billingAddress->getCompany() );
391
-			$stmt->bind( 5, $billingAddress->getVatID() );
392
-			$stmt->bind( 6, $billingAddress->getSalutation() );
393
-			$stmt->bind( 7, $billingAddress->getTitle() );
394
-			$stmt->bind( 8, $billingAddress->getFirstname() );
395
-			$stmt->bind( 9, $billingAddress->getLastname() );
396
-			$stmt->bind( 10, $billingAddress->getAddress1() );
397
-			$stmt->bind( 11, $billingAddress->getAddress2() );
398
-			$stmt->bind( 12, $billingAddress->getAddress3() );
399
-			$stmt->bind( 13, $billingAddress->getPostal() );
400
-			$stmt->bind( 14, $billingAddress->getCity() );
401
-			$stmt->bind( 15, $billingAddress->getState() );
402
-			$stmt->bind( 16, $billingAddress->getCountryId() );
403
-			$stmt->bind( 17, $billingAddress->getLanguageId() );
404
-			$stmt->bind( 18, $billingAddress->getTelephone() );
405
-			$stmt->bind( 19, $billingAddress->getEmail() );
406
-			$stmt->bind( 20, $billingAddress->getEmail() );
407
-			$stmt->bind( 21, $billingAddress->getTelefax() );
408
-			$stmt->bind( 22, $billingAddress->getWebsite() );
409
-			$stmt->bind( 23, $billingAddress->getLongitude() );
410
-			$stmt->bind( 24, $billingAddress->getLatitude() );
411
-			$stmt->bind( 25, $item->getBirthday() );
412
-			$stmt->bind( 26, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
413
-			$stmt->bind( 27, $item->getDateVerified() );
414
-			$stmt->bind( 28, $item->getPassword() );
415
-			$stmt->bind( 29, $date ); // Modification time
416
-			$stmt->bind( 30, $context->getEditor() );
417
-			$stmt->bind( 31, serialize( $item->getRoles() ) );
418
-			$stmt->bind( 32, $item->getSalt() );
419
-
420
-			if( $id !== null ) {
421
-				$stmt->bind( 33, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );
422
-				$item->setId( $id );
385
+			$stmt = $this->getCachedStatement($conn, $path);
386
+
387
+			$stmt->bind(1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
388
+			$stmt->bind(2, $item->getCode()); // canonical username
389
+			$stmt->bind(3, $item->getCode()); // username
390
+			$stmt->bind(4, $billingAddress->getCompany());
391
+			$stmt->bind(5, $billingAddress->getVatID());
392
+			$stmt->bind(6, $billingAddress->getSalutation());
393
+			$stmt->bind(7, $billingAddress->getTitle());
394
+			$stmt->bind(8, $billingAddress->getFirstname());
395
+			$stmt->bind(9, $billingAddress->getLastname());
396
+			$stmt->bind(10, $billingAddress->getAddress1());
397
+			$stmt->bind(11, $billingAddress->getAddress2());
398
+			$stmt->bind(12, $billingAddress->getAddress3());
399
+			$stmt->bind(13, $billingAddress->getPostal());
400
+			$stmt->bind(14, $billingAddress->getCity());
401
+			$stmt->bind(15, $billingAddress->getState());
402
+			$stmt->bind(16, $billingAddress->getCountryId());
403
+			$stmt->bind(17, $billingAddress->getLanguageId());
404
+			$stmt->bind(18, $billingAddress->getTelephone());
405
+			$stmt->bind(19, $billingAddress->getEmail());
406
+			$stmt->bind(20, $billingAddress->getEmail());
407
+			$stmt->bind(21, $billingAddress->getTelefax());
408
+			$stmt->bind(22, $billingAddress->getWebsite());
409
+			$stmt->bind(23, $billingAddress->getLongitude());
410
+			$stmt->bind(24, $billingAddress->getLatitude());
411
+			$stmt->bind(25, $item->getBirthday());
412
+			$stmt->bind(26, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
413
+			$stmt->bind(27, $item->getDateVerified());
414
+			$stmt->bind(28, $item->getPassword());
415
+			$stmt->bind(29, $date); // Modification time
416
+			$stmt->bind(30, $context->getEditor());
417
+			$stmt->bind(31, serialize($item->getRoles()));
418
+			$stmt->bind(32, $item->getSalt());
419
+
420
+			if ($id !== null) {
421
+				$stmt->bind(33, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
422
+				$item->setId($id);
423 423
 			} else {
424
-				$stmt->bind( 33, $date ); // Creation time
424
+				$stmt->bind(33, $date); // Creation time
425 425
 			}
426 426
 
427 427
 			$stmt->execute()->finish();
428 428
 
429
-			if( $id === null && $fetch === true )
429
+			if ($id === null && $fetch === true)
430 430
 			{
431 431
 				/** mshop/customer/manager/fosuser/newid
432 432
 				 * Retrieves the ID generated by the database when inserting a new record
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 				 * @see mshop/customer/manager/fosuser/count
460 460
 				 */
461 461
 				$path = 'mshop/customer/manager/fosuser/newid';
462
-				$item->setId( $this->newId( $conn, $path ) );
462
+				$item->setId($this->newId($conn, $path));
463 463
 			}
464 464
 
465
-			$this->addGroups( $item );
465
+			$this->addGroups($item);
466 466
 
467
-			$dbm->release( $conn, $dbname );
467
+			$dbm->release($conn, $dbname);
468 468
 		}
469
-		catch( \Exception $e )
469
+		catch (\Exception $e)
470 470
 		{
471
-			$dbm->release( $conn, $dbname );
471
+			$dbm->release($conn, $dbname);
472 472
 			throw $e;
473 473
 		}
474 474
 
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
 	 * @return array List of items implementing \Aimeos\MShop\Customer\Item\Iface
485 485
 	 * @throws \Aimeos\MShop\Customer\Exception If creating items failed
486 486
 	 */
487
-	public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null )
487
+	public function searchItems(\Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null)
488 488
 	{
489 489
 		$dbm = $this->getContext()->getDatabaseManager();
490 490
 		$dbname = $this->getResourceName();
491
-		$conn = $dbm->acquire( $dbname );
491
+		$conn = $dbm->acquire($dbname);
492 492
 		$map = [];
493 493
 
494 494
 		try
@@ -496,27 +496,27 @@  discard block
 block discarded – undo
496 496
 			$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
497 497
 			$cfgPathSearch = 'mshop/customer/manager/fosuser/search';
498 498
 			$cfgPathCount = 'mshop/customer/manager/fosuser/count';
499
-			$required = array( 'customer' );
499
+			$required = array('customer');
500 500
 
501
-			$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level );
502
-			while( ( $row = $results->fetch() ) !== false ) {
503
-				$map[ $row['customer.id'] ] = $row;
501
+			$results = $this->searchItemsBase($conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level);
502
+			while (($row = $results->fetch()) !== false) {
503
+				$map[$row['customer.id']] = $row;
504 504
 			}
505 505
 
506
-			$dbm->release( $conn, $dbname );
506
+			$dbm->release($conn, $dbname);
507 507
 		}
508
-		catch( \Exception $e )
508
+		catch (\Exception $e)
509 509
 		{
510
-			$dbm->release( $conn, $dbname  );
510
+			$dbm->release($conn, $dbname);
511 511
 			throw $e;
512 512
 		}
513 513
 
514 514
 		$addrItems = [];
515
-		if( in_array( 'address', $ref, true ) ) {
516
-			$addrItems = $this->getAddressItems( array_keys( $map ) );
515
+		if (in_array('address', $ref, true)) {
516
+			$addrItems = $this->getAddressItems(array_keys($map));
517 517
 		}
518 518
 
519
-		return $this->buildItems( $map, $ref, 'customer', $addrItems );
519
+		return $this->buildItems($map, $ref, 'customer', $addrItems);
520 520
 	}
521 521
 
522 522
 
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
528 528
 	 * @return mixed Manager for different extensions, e.g stock, tags, locations, etc.
529 529
 	 */
530
-	public function getSubManager( $manager, $name = null )
530
+	public function getSubManager($manager, $name = null)
531 531
 	{
532
-		return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'FosUser' : $name ) );
532
+		return $this->getSubManagerBase('customer', $manager, ($name === null ? 'FosUser' : $name));
533 533
 	}
534 534
 
535 535
 
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
 	 * @param array $refItems Items referenced by the customer item via the list items
542 542
 	 * @return \Aimeos\MShop\Customer\Item\Iface New customer item
543 543
 	 */
544
-	protected function createItemBase( array $values = [], array $listItems = [], array $refItems = [], array $addresses = [] )
544
+	protected function createItemBase(array $values = [], array $listItems = [], array $refItems = [], array $addresses = [])
545 545
 	{
546
-		if( !isset( $this->addressManager ) ) {
547
-			$this->addressManager = $this->getObject()->getSubManager( 'address' );
546
+		if (!isset($this->addressManager)) {
547
+			$this->addressManager = $this->getObject()->getSubManager('address');
548 548
 		}
549 549
 
550
-		if( isset( $values['roles'] ) ) {
551
-			$values['roles'] = unserialize( $values['roles'] );
550
+		if (isset($values['roles'])) {
551
+			$values['roles'] = unserialize($values['roles']);
552 552
 		}
553 553
 
554 554
 		$helper = $this->getPasswordHelper();
555 555
 		$address = $this->addressManager->createItem();
556 556
 
557
-		return new \Aimeos\MShop\Customer\Item\FosUser( $address, $values, $listItems, $refItems, null, $helper, $addresses );
557
+		return new \Aimeos\MShop\Customer\Item\FosUser($address, $values, $listItems, $refItems, null, $helper, $addresses);
558 558
 	}
559 559
 }
Please login to merge, or discard this patch.