Completed
Push — master ( 78d407...3b8285 )
by Aimeos
01:52
created
lib/custom/src/MShop/Customer/Manager/Ezpublish.php 1 patch
Spacing   +78 added lines, -78 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, array( 'address', 'lists' ) ) as $domain ) {
235
-			$this->getObject()->getSubManager( $domain )->cleanup( $siteids );
234
+		foreach ($this->getContext()->getConfig()->get($path, array('address', 'lists')) 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, array( 'address', 'lists' ), $withsub );
276
+		return $this->getSearchAttributesBase($this->searchConfig, $path, array('address', 'lists'), $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,90 +297,90 @@  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
 			return $item;
309 309
 		}
310 310
 
311 311
 		$context = $this->getContext();
312 312
 
313 313
 		$class = '\Aimeos\MShop\Context\Item\Ezpublish';
314
-		if( !is_a( $context, $class ) ) {
315
-			throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Object is not of required type "%1$s"', $class ) );
314
+		if (!is_a($context, $class)) {
315
+			throw new \Aimeos\MShop\Customer\Exception(sprintf('Object is not of required type "%1$s"', $class));
316 316
 		}
317 317
 
318 318
 		$service = $context->getEzUserService();
319 319
 		$email = $item->getPaymentAddress()->getEmail();
320 320
 
321
-		if( $item->getId() !== null )
321
+		if ($item->getId() !== null)
322 322
 		{
323 323
 			$struct = $service->newUserUpdateStruct();
324 324
 			$struct->password = $item->getPassword();
325 325
 			$struct->enabled = $item->getStatus();
326 326
 			$struct->email = $email;
327 327
 
328
-			$user = $service->loadUser( $item->getId() );
329
-			$service->updateUser( $user, $struct );
328
+			$user = $service->loadUser($item->getId());
329
+			$service->updateUser($user, $struct);
330 330
 		}
331 331
 		else
332 332
 		{
333
-			$struct = $service->newUserCreateStruct( $item->getCode(), $email, $item->getPassword(), 'eng-GB' );
333
+			$struct = $service->newUserCreateStruct($item->getCode(), $email, $item->getPassword(), 'eng-GB');
334 334
 			$struct->enabled = $item->getStatus();
335 335
 
336
-			$user = $service->createUser( $struct, [] );
337
-			$item->setId( $user->getUserId() );
336
+			$user = $service->createUser($struct, []);
337
+			$item->setId($user->getUserId());
338 338
 		}
339 339
 
340 340
 		$dbm = $context->getDatabaseManager();
341 341
 		$dbname = $this->getResourceName();
342
-		$conn = $dbm->acquire( $dbname );
342
+		$conn = $dbm->acquire($dbname);
343 343
 
344 344
 		try
345 345
 		{
346
-			$date = date( 'Y-m-d H:i:s' );
347
-			$ctime = ( $item->getTimeCreated() ? $item->getTimeCreated() : $date );
346
+			$date = date('Y-m-d H:i:s');
347
+			$ctime = ($item->getTimeCreated() ? $item->getTimeCreated() : $date);
348 348
 			$billingAddress = $item->getPaymentAddress();
349 349
 
350 350
 			$path = 'mshop/customer/manager/ezpublish/update';
351
-			$stmt = $this->getCachedStatement( $conn, $path );
352
-
353
-			$stmt->bind( 1, $billingAddress->getCompany() );
354
-			$stmt->bind( 2, $billingAddress->getVatID() );
355
-			$stmt->bind( 3, $billingAddress->getSalutation() );
356
-			$stmt->bind( 4, $billingAddress->getTitle() );
357
-			$stmt->bind( 5, $billingAddress->getFirstname() );
358
-			$stmt->bind( 6, $billingAddress->getLastname() );
359
-			$stmt->bind( 7, $billingAddress->getAddress1() );
360
-			$stmt->bind( 8, $billingAddress->getAddress2() );
361
-			$stmt->bind( 9, $billingAddress->getAddress3() );
362
-			$stmt->bind( 10, $billingAddress->getPostal() );
363
-			$stmt->bind( 11, $billingAddress->getCity() );
364
-			$stmt->bind( 12, $billingAddress->getState() );
365
-			$stmt->bind( 13, $billingAddress->getCountryId() );
366
-			$stmt->bind( 14, $billingAddress->getLanguageId() );
367
-			$stmt->bind( 15, $billingAddress->getTelephone() );
368
-			$stmt->bind( 16, $billingAddress->getTelefax() );
369
-			$stmt->bind( 17, $billingAddress->getWebsite() );
370
-			$stmt->bind( 18, $item->getBirthday() );
371
-			$stmt->bind( 19, $item->getDateVerified() );
372
-			$stmt->bind( 20, $date ); // Modification time
373
-			$stmt->bind( 21, $context->getEditor() );
374
-			$stmt->bind( 22, $ctime ); // Creation time
375
-			$stmt->bind( 23, $item->getId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );
351
+			$stmt = $this->getCachedStatement($conn, $path);
352
+
353
+			$stmt->bind(1, $billingAddress->getCompany());
354
+			$stmt->bind(2, $billingAddress->getVatID());
355
+			$stmt->bind(3, $billingAddress->getSalutation());
356
+			$stmt->bind(4, $billingAddress->getTitle());
357
+			$stmt->bind(5, $billingAddress->getFirstname());
358
+			$stmt->bind(6, $billingAddress->getLastname());
359
+			$stmt->bind(7, $billingAddress->getAddress1());
360
+			$stmt->bind(8, $billingAddress->getAddress2());
361
+			$stmt->bind(9, $billingAddress->getAddress3());
362
+			$stmt->bind(10, $billingAddress->getPostal());
363
+			$stmt->bind(11, $billingAddress->getCity());
364
+			$stmt->bind(12, $billingAddress->getState());
365
+			$stmt->bind(13, $billingAddress->getCountryId());
366
+			$stmt->bind(14, $billingAddress->getLanguageId());
367
+			$stmt->bind(15, $billingAddress->getTelephone());
368
+			$stmt->bind(16, $billingAddress->getTelefax());
369
+			$stmt->bind(17, $billingAddress->getWebsite());
370
+			$stmt->bind(18, $item->getBirthday());
371
+			$stmt->bind(19, $item->getDateVerified());
372
+			$stmt->bind(20, $date); // Modification time
373
+			$stmt->bind(21, $context->getEditor());
374
+			$stmt->bind(22, $ctime); // Creation time
375
+			$stmt->bind(23, $item->getId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
376 376
 
377 377
 			$stmt->execute()->finish();
378 378
 
379
-			$dbm->release( $conn, $dbname );
379
+			$dbm->release($conn, $dbname);
380 380
 		}
381
-		catch( \Exception $e )
381
+		catch (\Exception $e)
382 382
 		{
383
-			$dbm->release( $conn, $dbname );
383
+			$dbm->release($conn, $dbname);
384 384
 			throw $e;
385 385
 		}
386 386
 
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
 	 * @return array List of items implementing \Aimeos\MShop\Customer\Item\Iface
397 397
 	 * @throws \Aimeos\MShop\Customer\Exception If creating items failed
398 398
 	 */
399
-	public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null )
399
+	public function searchItems(\Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null)
400 400
 	{
401 401
 		$dbm = $this->getContext()->getDatabaseManager();
402 402
 		$dbname = $this->getResourceName();
403
-		$conn = $dbm->acquire( $dbname );
403
+		$conn = $dbm->acquire($dbname);
404 404
 		$map = [];
405 405
 
406 406
 		try
@@ -408,34 +408,34 @@  discard block
 block discarded – undo
408 408
 			$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
409 409
 			$cfgPathSearch = 'mshop/customer/manager/ezpublish/search';
410 410
 			$cfgPathCount = 'mshop/customer/manager/ezpublish/count';
411
-			$required = array( 'customer' );
411
+			$required = array('customer');
412 412
 
413
-			$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level );
413
+			$results = $this->searchItemsBase($conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level);
414 414
 
415
-			while( ( $row = $results->fetch() ) !== false )
415
+			while (($row = $results->fetch()) !== false)
416 416
 			{
417
-				$map[ $row['customer.id'] ] = $row;
418
-				$map[ $row['customer.id'] ]['groups'] = [];
417
+				$map[$row['customer.id']] = $row;
418
+				$map[$row['customer.id']]['groups'] = [];
419 419
 			}
420 420
 
421 421
 
422 422
 			$path = 'mshop/customer/manager/ezpublish/groups';
423
-			$stmt = $conn->create( $this->getGroupSql( array_keys( $map ), $path ) );
423
+			$stmt = $conn->create($this->getGroupSql(array_keys($map), $path));
424 424
 			$results = $stmt->execute();
425 425
 
426
-			while( ( $row = $results->fetch() ) !== false ) {
427
-				$map[ $row['contentobject_id'] ]['groups'][] = $row['role_id'];
426
+			while (($row = $results->fetch()) !== false) {
427
+				$map[$row['contentobject_id']]['groups'][] = $row['role_id'];
428 428
 			}
429 429
 
430
-			$dbm->release( $conn, $dbname );
430
+			$dbm->release($conn, $dbname);
431 431
 		}
432
-		catch( \Exception $e )
432
+		catch (\Exception $e)
433 433
 		{
434
-			$dbm->release( $conn, $dbname  );
434
+			$dbm->release($conn, $dbname);
435 435
 			throw $e;
436 436
 		}
437 437
 
438
-		return $this->buildItems( $map, $ref, 'customer' );
438
+		return $this->buildItems($map, $ref, 'customer');
439 439
 	}
440 440
 
441 441
 
@@ -448,15 +448,15 @@  discard block
 block discarded – undo
448 448
 	 * @param array $addresses List of address items of the customer item
449 449
 	 * @return \Aimeos\MShop\Customer\Item\Iface New customer item
450 450
 	 */
451
-	protected function createItemBase( array $values = [], array $listItems = [], array $refItems = [], array $addresses = [] )
451
+	protected function createItemBase(array $values = [], array $listItems = [], array $refItems = [], array $addresses = [])
452 452
 	{
453
-		if( !isset( $this->addressManager ) ) {
454
-			$this->addressManager = $this->getObject()->getSubManager( 'address' );
453
+		if (!isset($this->addressManager)) {
454
+			$this->addressManager = $this->getObject()->getSubManager('address');
455 455
 		}
456 456
 
457 457
 		$address = $this->addressManager->createItem();
458 458
 
459
-		return new \Aimeos\MShop\Customer\Item\Ezpublish( $address, $values, $listItems, $refItems, $addresses );
459
+		return new \Aimeos\MShop\Customer\Item\Ezpublish($address, $values, $listItems, $refItems, $addresses);
460 460
 	}
461 461
 
462 462
 
@@ -467,18 +467,18 @@  discard block
 block discarded – undo
467 467
 	 * @param string $cfgpath Configuration path to the SQL statement
468 468
 	 * @return string SQL statement ready for execution
469 469
 	 */
470
-	protected function getGroupSql( array $ids, $cfgpath )
470
+	protected function getGroupSql(array $ids, $cfgpath)
471 471
 	{
472
-		if( empty( $ids ) ) { return '1=1'; }
472
+		if (empty($ids)) { return '1=1'; }
473 473
 
474 474
 		$search = $this->getObject()->createSearch();
475
-		$search->setConditions( $search->compare( '==', 'id', $ids ) );
475
+		$search->setConditions($search->compare('==', 'id', $ids));
476 476
 
477
-		$types = array( 'id' => \Aimeos\MW\DB\Statement\Base::PARAM_INT );
478
-		$translations = array( 'id' => '"contentobject_id"' );
477
+		$types = array('id' => \Aimeos\MW\DB\Statement\Base::PARAM_INT);
478
+		$translations = array('id' => '"contentobject_id"');
479 479
 
480
-		$cond = $search->getConditionString( $types, $translations );
480
+		$cond = $search->getConditionString($types, $translations);
481 481
 
482
-		return str_replace( ':cond', $cond, $this->getSqlConfig( $cfgpath ) );
482
+		return str_replace(':cond', $cond, $this->getSqlConfig($cfgpath));
483 483
 	}
484 484
 }
Please login to merge, or discard this patch.