@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | $includepaths = $aimeos->getIncludePaths(); |
20 | 20 | $includepaths[] = get_include_path(); |
21 | - set_include_path( implode( PATH_SEPARATOR, $includepaths ) ); |
|
21 | + set_include_path(implode(PATH_SEPARATOR, $includepaths)); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | - public static function getContext( $site = 'unittest' ) |
|
25 | + public static function getContext($site = 'unittest') |
|
26 | 26 | { |
27 | - if( !isset( self::$context[$site] ) ) { |
|
28 | - self::$context[$site] = self::createContext( $site ); |
|
27 | + if (!isset(self::$context[$site])) { |
|
28 | + self::$context[$site] = self::createContext($site); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | return clone self::$context[$site]; |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | |
35 | 35 | private static function getAimeos() |
36 | 36 | { |
37 | - if( !isset( self::$aimeos ) ) |
|
37 | + if (!isset(self::$aimeos)) |
|
38 | 38 | { |
39 | 39 | require_once 'Bootstrap.php'; |
40 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
40 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
41 | 41 | |
42 | - $extdir = dirname( dirname( dirname( __DIR__ ) ) ); |
|
43 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
42 | + $extdir = dirname(dirname(dirname(__DIR__))); |
|
43 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return self::$aimeos; |
@@ -50,45 +50,45 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @param string $site |
52 | 52 | */ |
53 | - private static function createContext( $site ) |
|
53 | + private static function createContext($site) |
|
54 | 54 | { |
55 | 55 | $ctx = new \Aimeos\MShop\Context\Item\Ezpublish(); |
56 | 56 | $aimeos = self::getAimeos(); |
57 | 57 | |
58 | 58 | |
59 | 59 | $paths = $aimeos->getConfigPaths(); |
60 | - $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
|
60 | + $paths[] = __DIR__.DIRECTORY_SEPARATOR.'config'; |
|
61 | 61 | |
62 | - $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
|
63 | - $ctx->setConfig( $conf ); |
|
62 | + $conf = new \Aimeos\MW\Config\PHPArray([], $paths); |
|
63 | + $ctx->setConfig($conf); |
|
64 | 64 | |
65 | 65 | |
66 | - $dbm = new \Aimeos\MW\DB\Manager\DBAL( $conf ); |
|
67 | - $ctx->setDatabaseManager( $dbm ); |
|
66 | + $dbm = new \Aimeos\MW\DB\Manager\DBAL($conf); |
|
67 | + $ctx->setDatabaseManager($dbm); |
|
68 | 68 | |
69 | 69 | |
70 | - $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
71 | - $ctx->setLogger( $logger ); |
|
70 | + $logger = new \Aimeos\MW\Logger\File($site.'.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
71 | + $ctx->setLogger($logger); |
|
72 | 72 | |
73 | 73 | |
74 | 74 | $cache = new \Aimeos\MW\Cache\None(); |
75 | - $ctx->setCache( $cache ); |
|
75 | + $ctx->setCache($cache); |
|
76 | 76 | |
77 | 77 | |
78 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
79 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
78 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
79 | + $ctx->setI18n(array('de' => $i18n)); |
|
80 | 80 | |
81 | 81 | |
82 | 82 | $session = new \Aimeos\MW\Session\None(); |
83 | - $ctx->setSession( $session ); |
|
83 | + $ctx->setSession($session); |
|
84 | 84 | |
85 | 85 | |
86 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
|
87 | - $localeItem = $localeManager->bootstrap( $site, '', '', false ); |
|
86 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create($ctx); |
|
87 | + $localeItem = $localeManager->bootstrap($site, '', '', false); |
|
88 | 88 | |
89 | - $ctx->setLocale( $localeItem ); |
|
89 | + $ctx->setLocale($localeItem); |
|
90 | 90 | |
91 | - $ctx->setEditor( 'ai-ezpublish:unittest' ); |
|
91 | + $ctx->setEditor('ai-ezpublish:unittest'); |
|
92 | 92 | |
93 | 93 | return $ctx; |
94 | 94 | } |
@@ -226,11 +226,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | |
@@ -438,10 +438,10 @@ discard block |
||
438 | 438 | * @param \Aimeos\MShop\Common\Item\Property\Iface[] $propItems List of property items |
439 | 439 | * @return \Aimeos\MShop\Customer\Item\Iface New customer item |
440 | 440 | */ |
441 | - protected function createItemBase( array $values = [], array $listItems = [], array $refItems = [], |
|
442 | - array $addrItems = [], array $propItems = [] ) |
|
441 | + protected function createItemBase(array $values = [], array $listItems = [], array $refItems = [], |
|
442 | + array $addrItems = [], array $propItems = []) |
|
443 | 443 | { |
444 | - $address = new \Aimeos\MShop\Common\Item\Address\Simple( 'customer.', $values ); |
|
444 | + $address = new \Aimeos\MShop\Common\Item\Address\Simple('customer.', $values); |
|
445 | 445 | |
446 | 446 | return new \Aimeos\MShop\Customer\Item\Ezpublish( |
447 | 447 | $address, $values, $listItems, $refItems, $addrItems, $propItems |
@@ -456,18 +456,18 @@ discard block |
||
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 | } |