@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | protected function configure() |
| 31 | 31 | { |
| 32 | - $this->setName( 'aimeos:account'); |
|
| 33 | - $this->setDescription( 'Creates new (admin) accounts' ); |
|
| 34 | - $this->addArgument( 'email', InputArgument::REQUIRED, 'E-mail address of the account that should be created' ); |
|
| 35 | - $this->addArgument( 'site', InputArgument::OPTIONAL, 'Site codes to create accounts for like "default unittest" (none for all)' ); |
|
| 36 | - $this->addOption( 'password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)' ); |
|
| 37 | - $this->addOption( 'admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges' ); |
|
| 38 | - $this->addOption( 'editor', null, InputOption::VALUE_NONE, 'If account should have limited editor privileges' ); |
|
| 32 | + $this->setName('aimeos:account'); |
|
| 33 | + $this->setDescription('Creates new (admin) accounts'); |
|
| 34 | + $this->addArgument('email', InputArgument::REQUIRED, 'E-mail address of the account that should be created'); |
|
| 35 | + $this->addArgument('site', InputArgument::OPTIONAL, 'Site codes to create accounts for like "default unittest" (none for all)'); |
|
| 36 | + $this->addOption('password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)'); |
|
| 37 | + $this->addOption('admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges'); |
|
| 38 | + $this->addOption('editor', null, InputOption::VALUE_NONE, 'If account should have limited editor privileges'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -45,32 +45,32 @@ discard block |
||
| 45 | 45 | * @param InputInterface $input Input object |
| 46 | 46 | * @param OutputInterface $output Output object |
| 47 | 47 | */ |
| 48 | - protected function execute( InputInterface $input, OutputInterface $output ) |
|
| 48 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 49 | 49 | { |
| 50 | - $code = $input->getArgument( 'email' ); |
|
| 51 | - if( ( $password = $input->getOption( 'password' ) ) === null ) |
|
| 50 | + $code = $input->getArgument('email'); |
|
| 51 | + if (($password = $input->getOption('password')) === null) |
|
| 52 | 52 | { |
| 53 | - $helper = $this->getHelper( 'question' ); |
|
| 54 | - $question = new Question( 'Password' ); |
|
| 55 | - $question->setHidden( true ); |
|
| 53 | + $helper = $this->getHelper('question'); |
|
| 54 | + $question = new Question('Password'); |
|
| 55 | + $question->setHidden(true); |
|
| 56 | 56 | |
| 57 | - $password = $helper->ask( $input, $output, $question ); |
|
| 57 | + $password = $helper->ask($input, $output, $question); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $context = $this->getContainer()->get( 'aimeos_context' )->get( false ); |
|
| 61 | - $context->setEditor( 'aimeos:account' ); |
|
| 60 | + $context = $this->getContainer()->get('aimeos_context')->get(false); |
|
| 61 | + $context->setEditor('aimeos:account'); |
|
| 62 | 62 | |
| 63 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
| 64 | - $context->setLocale( $localeManager->createItem() ); |
|
| 63 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
| 64 | + $context->setLocale($localeManager->createItem()); |
|
| 65 | 65 | |
| 66 | - $user = $this->createCustomerItem( $context, $code, $password ); |
|
| 66 | + $user = $this->createCustomerItem($context, $code, $password); |
|
| 67 | 67 | |
| 68 | - if( $input->getOption( 'admin' ) ) { |
|
| 69 | - $this->addGroup( $input, $context, $user, 'admin' ); |
|
| 68 | + if ($input->getOption('admin')) { |
|
| 69 | + $this->addGroup($input, $context, $user, 'admin'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if( $input->getOption( 'editor' ) ) { |
|
| 73 | - $this->addGroup( $input, $context, $user, 'editor' ); |
|
| 72 | + if ($input->getOption('editor')) { |
|
| 73 | + $this->addGroup($input, $context, $user, 'editor'); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -83,24 +83,24 @@ discard block |
||
| 83 | 83 | * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object |
| 84 | 84 | * @param string $group Unique customer group code |
| 85 | 85 | */ |
| 86 | - protected function addGroup( InputInterface $input, \Aimeos\MShop\Context\Item\Iface $context, |
|
| 87 | - \Aimeos\MShop\Customer\Item\Iface $user, $group ) |
|
| 86 | + protected function addGroup(InputInterface $input, \Aimeos\MShop\Context\Item\Iface $context, |
|
| 87 | + \Aimeos\MShop\Customer\Item\Iface $user, $group) |
|
| 88 | 88 | { |
| 89 | - $output->writeln( sprintf( 'Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode() ) ); |
|
| 89 | + $output->writeln(sprintf('Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode())); |
|
| 90 | 90 | |
| 91 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
| 91 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
| 92 | 92 | |
| 93 | - foreach( $this->getSiteItems( $context, $input ) as $siteItem ) |
|
| 93 | + foreach ($this->getSiteItems($context, $input) as $siteItem) |
|
| 94 | 94 | { |
| 95 | - $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
| 95 | + $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); |
|
| 96 | 96 | |
| 97 | 97 | $lcontext = clone $context; |
| 98 | - $lcontext->setLocale( $localeItem ); |
|
| 98 | + $lcontext->setLocale($localeItem); |
|
| 99 | 99 | |
| 100 | - $output->writeln( '- ' . $siteItem->getCode() ); |
|
| 100 | + $output->writeln('- '.$siteItem->getCode()); |
|
| 101 | 101 | |
| 102 | - $groupItem = $this->getGroupItem( $lcontext, $group ); |
|
| 103 | - $this->addListItem( $lcontext, $user->getId(), $groupItem->getId() ); |
|
| 102 | + $groupItem = $this->getGroupItem($lcontext, $group); |
|
| 103 | + $this->addListItem($lcontext, $user->getId(), $groupItem->getId()); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
@@ -112,31 +112,31 @@ discard block |
||
| 112 | 112 | * @param string $userid Unique user ID |
| 113 | 113 | * @param string $groupid Unique group ID |
| 114 | 114 | */ |
| 115 | - protected function addListItem( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid ) |
|
| 115 | + protected function addListItem(\Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid) |
|
| 116 | 116 | { |
| 117 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'lists' ); |
|
| 118 | - $typeid = $manager->getSubmanager( 'type' )->findItem( 'default', array(), 'customer/group' )->getId(); |
|
| 117 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('lists'); |
|
| 118 | + $typeid = $manager->getSubmanager('type')->findItem('default', array(), 'customer/group')->getId(); |
|
| 119 | 119 | |
| 120 | 120 | $search = $manager->createSearch(); |
| 121 | 121 | $expr = array( |
| 122 | - $search->compare( '==', 'customer.lists.parentid', $userid ), |
|
| 123 | - $search->compare( '==', 'customer.lists.refid', $groupid ), |
|
| 124 | - $search->compare( '==', 'customer.lists.domain', 'customer/group' ), |
|
| 125 | - $search->compare( '==', 'customer.lists.typeid', $typeid ), |
|
| 122 | + $search->compare('==', 'customer.lists.parentid', $userid), |
|
| 123 | + $search->compare('==', 'customer.lists.refid', $groupid), |
|
| 124 | + $search->compare('==', 'customer.lists.domain', 'customer/group'), |
|
| 125 | + $search->compare('==', 'customer.lists.typeid', $typeid), |
|
| 126 | 126 | ); |
| 127 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 128 | - $search->setSlice( 0, 1 ); |
|
| 127 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 128 | + $search->setSlice(0, 1); |
|
| 129 | 129 | |
| 130 | - if( count( $manager->searchItems( $search ) ) === 0 ) |
|
| 130 | + if (count($manager->searchItems($search)) === 0) |
|
| 131 | 131 | { |
| 132 | 132 | $item = $manager->createItem(); |
| 133 | - $item->setDomain( 'customer/group' ); |
|
| 134 | - $item->setParentId( $userid ); |
|
| 135 | - $item->setTypeId( $typeid ); |
|
| 136 | - $item->setRefId( $groupid ); |
|
| 137 | - $item->setStatus( 1 ); |
|
| 133 | + $item->setDomain('customer/group'); |
|
| 134 | + $item->setParentId($userid); |
|
| 135 | + $item->setTypeId($typeid); |
|
| 136 | + $item->setRefId($groupid); |
|
| 137 | + $item->setStatus(1); |
|
| 138 | 138 | |
| 139 | - $manager->saveItem( $item, false ); |
|
| 139 | + $manager->saveItem($item, false); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -151,22 +151,22 @@ discard block |
||
| 151 | 151 | * @param string $password New user password |
| 152 | 152 | * @return \Aimeos\MShop\Customer\Item\Iface Aimeos customer item object |
| 153 | 153 | */ |
| 154 | - protected function createCustomerItem( \Aimeos\MShop\Context\Item\Iface $context, $email, $password ) |
|
| 154 | + protected function createCustomerItem(\Aimeos\MShop\Context\Item\Iface $context, $email, $password) |
|
| 155 | 155 | { |
| 156 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 156 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 157 | 157 | |
| 158 | 158 | try { |
| 159 | - $item = $manager->findItem( $email ); |
|
| 160 | - } catch( \Aimeos\MShop\Exception $e ) { |
|
| 159 | + $item = $manager->findItem($email); |
|
| 160 | + } catch (\Aimeos\MShop\Exception $e) { |
|
| 161 | 161 | $item = $manager->createItem(); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $item->setCode( $email ); |
|
| 165 | - $item->setLabel( $email ); |
|
| 166 | - $item->getPaymentAddress()->setEmail( $email ); |
|
| 167 | - $item->setPassword( $password ); |
|
| 164 | + $item->setCode($email); |
|
| 165 | + $item->setLabel($email); |
|
| 166 | + $item->getPaymentAddress()->setEmail($email); |
|
| 167 | + $item->setPassword($password); |
|
| 168 | 168 | |
| 169 | - $manager->saveItem( $item ); |
|
| 169 | + $manager->saveItem($item); |
|
| 170 | 170 | |
| 171 | 171 | return $item; |
| 172 | 172 | } |
@@ -179,21 +179,21 @@ discard block |
||
| 179 | 179 | * @param string $code Unique customer group code |
| 180 | 180 | * @return \Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object |
| 181 | 181 | */ |
| 182 | - protected function getGroupItem( \Aimeos\MShop\Context\Item\Iface $context, $code ) |
|
| 182 | + protected function getGroupItem(\Aimeos\MShop\Context\Item\Iface $context, $code) |
|
| 183 | 183 | { |
| 184 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'group' ); |
|
| 184 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('group'); |
|
| 185 | 185 | |
| 186 | 186 | try |
| 187 | 187 | { |
| 188 | - $item = $manager->findItem( $code ); |
|
| 188 | + $item = $manager->findItem($code); |
|
| 189 | 189 | } |
| 190 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 190 | + catch (\Aimeos\MShop\Exception $e) |
|
| 191 | 191 | { |
| 192 | 192 | $item = $manager->createItem(); |
| 193 | - $item->setLabel( $code ); |
|
| 194 | - $item->setCode( $code ); |
|
| 193 | + $item->setLabel($code); |
|
| 194 | + $item->setCode($code); |
|
| 195 | 195 | |
| 196 | - $manager->saveItem( $item ); |
|
| 196 | + $manager->saveItem($item); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | return $item; |
@@ -186,8 +186,7 @@ |
||
| 186 | 186 | try |
| 187 | 187 | { |
| 188 | 188 | $item = $manager->findItem( $code ); |
| 189 | - } |
|
| 190 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 189 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 191 | 190 | { |
| 192 | 191 | $item = $manager->createItem(); |
| 193 | 192 | $item->setLabel( $code ); |