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