@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @param \Aimeos\Shop\Base\Context $context Context object |
| 31 | 31 | */ |
| 32 | - public function __construct( \Aimeos\Shop\Base\Context $context ) |
|
| 32 | + public function __construct(\Aimeos\Shop\Base\Context $context) |
|
| 33 | 33 | { |
| 34 | 34 | $this->context = $context; |
| 35 | 35 | } |
@@ -42,21 +42,21 @@ discard block |
||
| 42 | 42 | * @param string $groupcode Unique user/customer group code |
| 43 | 43 | * @return boolean True if user is part of the group, false if not |
| 44 | 44 | */ |
| 45 | - public function checkGroup( $userid, $groupcode ) |
|
| 45 | + public function checkGroup($userid, $groupcode) |
|
| 46 | 46 | { |
| 47 | 47 | $context = $this->context->get(); |
| 48 | - $group = \Aimeos\MShop\Factory::createManager( $context, 'customer/group' )->findItem( $groupcode ); |
|
| 49 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 48 | + $group = \Aimeos\MShop\Factory::createManager($context, 'customer/group')->findItem($groupcode); |
|
| 49 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
| 50 | 50 | |
| 51 | 51 | $search = $manager->createSearch(); |
| 52 | 52 | $expr = array( |
| 53 | - $search->compare( '==', 'customer.lists.parentid', $userid ), |
|
| 54 | - $search->compare( '==', 'customer.lists.refid', $group->getId() ), |
|
| 55 | - $search->compare( '==', 'customer.lists.domain', 'customer/group' ), |
|
| 53 | + $search->compare('==', 'customer.lists.parentid', $userid), |
|
| 54 | + $search->compare('==', 'customer.lists.refid', $group->getId()), |
|
| 55 | + $search->compare('==', 'customer.lists.domain', 'customer/group'), |
|
| 56 | 56 | ); |
| 57 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 58 | - $search->setSlice( 0, 1 ); |
|
| 57 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 58 | + $search->setSlice(0, 1); |
|
| 59 | 59 | |
| 60 | - return (bool) count( $manager->searchItems( $search ) ); |
|
| 60 | + return (bool) count($manager->searchItems($search)); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | \ No newline at end of file |
@@ -39,21 +39,21 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function fire() |
| 41 | 41 | { |
| 42 | - $code = $this->argument( 'email' ); |
|
| 43 | - if( ( $password = $this->option( 'password' ) ) === null ) { |
|
| 44 | - $password = $this->secret( 'Password' ); |
|
| 42 | + $code = $this->argument('email'); |
|
| 43 | + if (($password = $this->option('password')) === null) { |
|
| 44 | + $password = $this->secret('Password'); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $context = $this->getLaravel()->make( 'Aimeos\Shop\Base\Context' )->get( false ); |
|
| 48 | - $context->setEditor( 'aimeos:account' ); |
|
| 47 | + $context = $this->getLaravel()->make('Aimeos\Shop\Base\Context')->get(false); |
|
| 48 | + $context->setEditor('aimeos:account'); |
|
| 49 | 49 | |
| 50 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
| 51 | - $context->setLocale( $localeManager->createItem() ); |
|
| 50 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
| 51 | + $context->setLocale($localeManager->createItem()); |
|
| 52 | 52 | |
| 53 | - $user = $this->createCustomerItem( $context, $code, $password ); |
|
| 53 | + $user = $this->createCustomerItem($context, $code, $password); |
|
| 54 | 54 | |
| 55 | - if( $this->option( 'admin' ) ) { |
|
| 56 | - $this->addPrivilege( $context, $user, 'admin' ); |
|
| 55 | + if ($this->option('admin')) { |
|
| 56 | + $this->addPrivilege($context, $user, 'admin'); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -65,31 +65,31 @@ discard block |
||
| 65 | 65 | * @param string $userid Unique user ID |
| 66 | 66 | * @param string $groupid Unique group ID |
| 67 | 67 | */ |
| 68 | - protected function addListItem( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid ) |
|
| 68 | + protected function addListItem(\Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid) |
|
| 69 | 69 | { |
| 70 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'lists' ); |
|
| 71 | - $typeid = $manager->getSubmanager( 'type' )->findItem( 'default', array(), 'customer/group' )->getId(); |
|
| 70 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('lists'); |
|
| 71 | + $typeid = $manager->getSubmanager('type')->findItem('default', array(), 'customer/group')->getId(); |
|
| 72 | 72 | |
| 73 | 73 | $search = $manager->createSearch(); |
| 74 | 74 | $expr = array( |
| 75 | - $search->compare( '==', 'customer.lists.parentid', $userid ), |
|
| 76 | - $search->compare( '==', 'customer.lists.refid', $groupid ), |
|
| 77 | - $search->compare( '==', 'customer.lists.domain', 'customer/group' ), |
|
| 78 | - $search->compare( '==', 'customer.lists.typeid', $typeid ), |
|
| 75 | + $search->compare('==', 'customer.lists.parentid', $userid), |
|
| 76 | + $search->compare('==', 'customer.lists.refid', $groupid), |
|
| 77 | + $search->compare('==', 'customer.lists.domain', 'customer/group'), |
|
| 78 | + $search->compare('==', 'customer.lists.typeid', $typeid), |
|
| 79 | 79 | ); |
| 80 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 81 | - $search->setSlice( 0, 1 ); |
|
| 80 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 81 | + $search->setSlice(0, 1); |
|
| 82 | 82 | |
| 83 | - if( count( $manager->searchItems( $search ) ) === 0 ) |
|
| 83 | + if (count($manager->searchItems($search)) === 0) |
|
| 84 | 84 | { |
| 85 | 85 | $item = $manager->createItem(); |
| 86 | - $item->setDomain( 'customer/group' ); |
|
| 87 | - $item->setParentId( $userid ); |
|
| 88 | - $item->setTypeId( $typeid ); |
|
| 89 | - $item->setRefId( $groupid ); |
|
| 90 | - $item->setStatus( 1 ); |
|
| 86 | + $item->setDomain('customer/group'); |
|
| 87 | + $item->setParentId($userid); |
|
| 88 | + $item->setTypeId($typeid); |
|
| 89 | + $item->setRefId($groupid); |
|
| 90 | + $item->setStatus(1); |
|
| 91 | 91 | |
| 92 | - $manager->saveItem( $item, false ); |
|
| 92 | + $manager->saveItem($item, false); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -101,23 +101,23 @@ discard block |
||
| 101 | 101 | * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object |
| 102 | 102 | * @param string $privilege Unique customer group code |
| 103 | 103 | */ |
| 104 | - protected function addPrivilege( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $privilege ) |
|
| 104 | + protected function addPrivilege(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $privilege) |
|
| 105 | 105 | { |
| 106 | - $this->info( sprintf( 'Add "%1$s" privilege to user "%2$s" for sites', $privilege, $user->getCode() ) ); |
|
| 106 | + $this->info(sprintf('Add "%1$s" privilege to user "%2$s" for sites', $privilege, $user->getCode())); |
|
| 107 | 107 | |
| 108 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
| 108 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
| 109 | 109 | |
| 110 | - foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem ) |
|
| 110 | + foreach ($this->getSiteItems($context, $this->argument('site')) as $siteItem) |
|
| 111 | 111 | { |
| 112 | - $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
| 112 | + $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); |
|
| 113 | 113 | |
| 114 | 114 | $lcontext = clone $context; |
| 115 | - $lcontext->setLocale( $localeItem ); |
|
| 115 | + $lcontext->setLocale($localeItem); |
|
| 116 | 116 | |
| 117 | - $this->info( '- ' . $siteItem->getCode() ); |
|
| 117 | + $this->info('- ' . $siteItem->getCode()); |
|
| 118 | 118 | |
| 119 | - $groupItem = $this->getGroupItem( $lcontext, $privilege ); |
|
| 120 | - $this->addListItem( $lcontext, $user->getId(), $groupItem->getId() ); |
|
| 119 | + $groupItem = $this->getGroupItem($lcontext, $privilege); |
|
| 120 | + $this->addListItem($lcontext, $user->getId(), $groupItem->getId()); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
@@ -132,21 +132,21 @@ discard block |
||
| 132 | 132 | * @param string $password New user password |
| 133 | 133 | * @return \Aimeos\MShop\Customer\Item\Iface Aimeos customer item object |
| 134 | 134 | */ |
| 135 | - protected function createCustomerItem( \Aimeos\MShop\Context\Item\Iface $context, $email, $password ) |
|
| 135 | + protected function createCustomerItem(\Aimeos\MShop\Context\Item\Iface $context, $email, $password) |
|
| 136 | 136 | { |
| 137 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 137 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 138 | 138 | |
| 139 | 139 | try { |
| 140 | - $item = $manager->findItem( $email ); |
|
| 141 | - } catch( \Aimeos\MShop\Exception $e ) { |
|
| 140 | + $item = $manager->findItem($email); |
|
| 141 | + } catch (\Aimeos\MShop\Exception $e) { |
|
| 142 | 142 | $item = $manager->createItem(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $item->setCode( $email ); |
|
| 146 | - $item->getPaymentAddress()->setEmail( $email ); |
|
| 147 | - $item->setPassword( $password ); |
|
| 145 | + $item->setCode($email); |
|
| 146 | + $item->getPaymentAddress()->setEmail($email); |
|
| 147 | + $item->setPassword($password); |
|
| 148 | 148 | |
| 149 | - $manager->saveItem( $item ); |
|
| 149 | + $manager->saveItem($item); |
|
| 150 | 150 | |
| 151 | 151 | return $item; |
| 152 | 152 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | protected function getArguments() |
| 161 | 161 | { |
| 162 | 162 | return array( |
| 163 | - array( 'email', InputArgument::REQUIRED, 'E-mail address of the account that should be created' ), |
|
| 164 | - array( 'site', InputArgument::OPTIONAL, 'Site codes to create accounts for like "default unittest" (none for all)' ), |
|
| 163 | + array('email', InputArgument::REQUIRED, 'E-mail address of the account that should be created'), |
|
| 164 | + array('site', InputArgument::OPTIONAL, 'Site codes to create accounts for like "default unittest" (none for all)'), |
|
| 165 | 165 | ); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -173,21 +173,21 @@ discard block |
||
| 173 | 173 | * @param string $code Unique customer group code |
| 174 | 174 | * @return \Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object |
| 175 | 175 | */ |
| 176 | - protected function getGroupItem( \Aimeos\MShop\Context\Item\Iface $context, $code ) |
|
| 176 | + protected function getGroupItem(\Aimeos\MShop\Context\Item\Iface $context, $code) |
|
| 177 | 177 | { |
| 178 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'group' ); |
|
| 178 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('group'); |
|
| 179 | 179 | |
| 180 | 180 | try |
| 181 | 181 | { |
| 182 | - $item = $manager->findItem( $code ); |
|
| 182 | + $item = $manager->findItem($code); |
|
| 183 | 183 | } |
| 184 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 184 | + catch (\Aimeos\MShop\Exception $e) |
|
| 185 | 185 | { |
| 186 | 186 | $item = $manager->createItem(); |
| 187 | - $item->setLabel( $code ); |
|
| 188 | - $item->setCode( $code ); |
|
| 187 | + $item->setLabel($code); |
|
| 188 | + $item->setCode($code); |
|
| 189 | 189 | |
| 190 | - $manager->saveItem( $item ); |
|
| 190 | + $manager->saveItem($item); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | return $item; |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | protected function getOptions() |
| 203 | 203 | { |
| 204 | 204 | return array( |
| 205 | - array( 'password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)' ), |
|
| 206 | - array( 'admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges' ), |
|
| 205 | + array('password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)'), |
|
| 206 | + array('admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges'), |
|
| 207 | 207 | ); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -216,23 +216,23 @@ discard block |
||
| 216 | 216 | * @return \Aimeos\MShop\Common\Item\Type\Iface Aimeos customer list type item object |
| 217 | 217 | * @throws \Exception If no customer list type item for the given code is found |
| 218 | 218 | */ |
| 219 | - protected function getTypeItem( \Aimeos\MShop\Common\Manager\Iface $listManager, $code ) |
|
| 219 | + protected function getTypeItem(\Aimeos\MShop\Common\Manager\Iface $listManager, $code) |
|
| 220 | 220 | { |
| 221 | - $manager = $listManager->getSubmanager( 'type' ); |
|
| 221 | + $manager = $listManager->getSubmanager('type'); |
|
| 222 | 222 | |
| 223 | 223 | $search = $manager->createSearch(); |
| 224 | 224 | $expr = array( |
| 225 | - $search->compare( '==', 'customer.lists.type.domain', 'customer/group' ), |
|
| 226 | - $search->compare( '==', 'customer.lists.type.code', $code ), |
|
| 225 | + $search->compare('==', 'customer.lists.type.domain', 'customer/group'), |
|
| 226 | + $search->compare('==', 'customer.lists.type.code', $code), |
|
| 227 | 227 | ); |
| 228 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 228 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 229 | 229 | |
| 230 | - $result = $manager->searchItems( $search ); |
|
| 230 | + $result = $manager->searchItems($search); |
|
| 231 | 231 | |
| 232 | - if( ( $item = reset( $result ) ) === false ) |
|
| 232 | + if (($item = reset($result)) === false) |
|
| 233 | 233 | { |
| 234 | - $msg = sprintf( 'No user list type item for domain "%1$s" and code "%2$s" found', 'customer/group', $code ); |
|
| 235 | - throw new \Exception( $msg ); |
|
| 234 | + $msg = sprintf('No user list type item for domain "%1$s" and code "%2$s" found', 'customer/group', $code); |
|
| 235 | + throw new \Exception($msg); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | return $item; |