@@ -29,14 +29,14 @@ 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"', 'default' ); |
|
36 | - $this->addOption( 'password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)' ); |
|
37 | - $this->addOption( 'super', null, InputOption::VALUE_NONE, 'If account should have super user privileges' ); |
|
38 | - $this->addOption( 'admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges' ); |
|
39 | - $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"', 'default'); |
|
36 | + $this->addOption('password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)'); |
|
37 | + $this->addOption('super', null, InputOption::VALUE_NONE, 'If account should have super user privileges'); |
|
38 | + $this->addOption('admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges'); |
|
39 | + $this->addOption('editor', null, InputOption::VALUE_NONE, 'If account should have limited editor privileges'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -46,37 +46,37 @@ discard block |
||
46 | 46 | * @param InputInterface $input Input object |
47 | 47 | * @param OutputInterface $output Output object |
48 | 48 | */ |
49 | - protected function execute( InputInterface $input, OutputInterface $output ) |
|
49 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
50 | 50 | { |
51 | - $code = $input->getArgument( 'email' ); |
|
52 | - if( ( $password = $input->getOption( 'password' ) ) === null ) |
|
51 | + $code = $input->getArgument('email'); |
|
52 | + if (($password = $input->getOption('password')) === null) |
|
53 | 53 | { |
54 | - $helper = $this->getHelper( 'question' ); |
|
55 | - $question = new Question( 'Password' ); |
|
56 | - $question->setHidden( true ); |
|
54 | + $helper = $this->getHelper('question'); |
|
55 | + $question = new Question('Password'); |
|
56 | + $question->setHidden(true); |
|
57 | 57 | |
58 | - $password = $helper->ask( $input, $output, $question ); |
|
58 | + $password = $helper->ask($input, $output, $question); |
|
59 | 59 | } |
60 | 60 | |
61 | - $context = $this->getContainer()->get( 'aimeos_context' )->get( false, 'command' ); |
|
62 | - $context->setEditor( 'aimeos:account' ); |
|
61 | + $context = $this->getContainer()->get('aimeos_context')->get(false, 'command'); |
|
62 | + $context->setEditor('aimeos:account'); |
|
63 | 63 | |
64 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
65 | - $localeItem = $localeManager->bootstrap( $input->getArgument( 'site' ), '', '', false ); |
|
66 | - $context->setLocale( $localeItem ); |
|
64 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
65 | + $localeItem = $localeManager->bootstrap($input->getArgument('site'), '', '', false); |
|
66 | + $context->setLocale($localeItem); |
|
67 | 67 | |
68 | - $user = $this->createCustomerItem( $context, $code, $password ); |
|
68 | + $user = $this->createCustomerItem($context, $code, $password); |
|
69 | 69 | |
70 | - if( $input->getOption( 'super' ) ) { |
|
71 | - $this->addGroup( $input, $output, $context, $user, 'super' ); |
|
70 | + if ($input->getOption('super')) { |
|
71 | + $this->addGroup($input, $output, $context, $user, 'super'); |
|
72 | 72 | } |
73 | 73 | |
74 | - if( $input->getOption( 'admin' ) ) { |
|
75 | - $this->addGroup( $input, $output, $context, $user, 'admin' ); |
|
74 | + if ($input->getOption('admin')) { |
|
75 | + $this->addGroup($input, $output, $context, $user, 'admin'); |
|
76 | 76 | } |
77 | 77 | |
78 | - if( $input->getOption( 'editor' ) ) { |
|
79 | - $this->addGroup( $input, $output, $context, $user, 'editor' ); |
|
78 | + if ($input->getOption('editor')) { |
|
79 | + $this->addGroup($input, $output, $context, $user, 'editor'); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object |
91 | 91 | * @param string $group Unique customer group code |
92 | 92 | */ |
93 | - protected function addGroup( InputInterface $input, OutputInterface $output, |
|
94 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group ) |
|
93 | + protected function addGroup(InputInterface $input, OutputInterface $output, |
|
94 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group) |
|
95 | 95 | { |
96 | - $output->writeln( sprintf( 'Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode() ) ); |
|
96 | + $output->writeln(sprintf('Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode())); |
|
97 | 97 | |
98 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
98 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
99 | 99 | |
100 | - foreach( $this->getSiteItems( $context, $input ) as $siteItem ) |
|
100 | + foreach ($this->getSiteItems($context, $input) as $siteItem) |
|
101 | 101 | { |
102 | - $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
102 | + $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); |
|
103 | 103 | |
104 | 104 | $lcontext = clone $context; |
105 | - $lcontext->setLocale( $localeItem ); |
|
105 | + $lcontext->setLocale($localeItem); |
|
106 | 106 | |
107 | - $output->writeln( '- ' . $siteItem->getCode() ); |
|
107 | + $output->writeln('- '.$siteItem->getCode()); |
|
108 | 108 | |
109 | - $groupItem = $this->getGroupItem( $lcontext, $group ); |
|
110 | - $this->addListItem( $lcontext, $user->getId(), $groupItem->getId() ); |
|
109 | + $groupItem = $this->getGroupItem($lcontext, $group); |
|
110 | + $this->addListItem($lcontext, $user->getId(), $groupItem->getId()); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -119,31 +119,31 @@ discard block |
||
119 | 119 | * @param string $userid Unique user ID |
120 | 120 | * @param string $groupid Unique group ID |
121 | 121 | */ |
122 | - protected function addListItem( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid ) |
|
122 | + protected function addListItem(\Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid) |
|
123 | 123 | { |
124 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'lists' ); |
|
125 | - $typeid = $manager->getSubmanager( 'type' )->findItem( 'default', array(), 'customer/group' )->getId(); |
|
124 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('lists'); |
|
125 | + $typeid = $manager->getSubmanager('type')->findItem('default', array(), 'customer/group')->getId(); |
|
126 | 126 | |
127 | 127 | $search = $manager->createSearch(); |
128 | 128 | $expr = array( |
129 | - $search->compare( '==', 'customer.lists.parentid', $userid ), |
|
130 | - $search->compare( '==', 'customer.lists.refid', $groupid ), |
|
131 | - $search->compare( '==', 'customer.lists.domain', 'customer/group' ), |
|
132 | - $search->compare( '==', 'customer.lists.typeid', $typeid ), |
|
129 | + $search->compare('==', 'customer.lists.parentid', $userid), |
|
130 | + $search->compare('==', 'customer.lists.refid', $groupid), |
|
131 | + $search->compare('==', 'customer.lists.domain', 'customer/group'), |
|
132 | + $search->compare('==', 'customer.lists.typeid', $typeid), |
|
133 | 133 | ); |
134 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
135 | - $search->setSlice( 0, 1 ); |
|
134 | + $search->setConditions($search->combine('&&', $expr)); |
|
135 | + $search->setSlice(0, 1); |
|
136 | 136 | |
137 | - if( count( $manager->searchItems( $search ) ) === 0 ) |
|
137 | + if (count($manager->searchItems($search)) === 0) |
|
138 | 138 | { |
139 | 139 | $item = $manager->createItem(); |
140 | - $item->setDomain( 'customer/group' ); |
|
141 | - $item->setParentId( $userid ); |
|
142 | - $item->setTypeId( $typeid ); |
|
143 | - $item->setRefId( $groupid ); |
|
144 | - $item->setStatus( 1 ); |
|
140 | + $item->setDomain('customer/group'); |
|
141 | + $item->setParentId($userid); |
|
142 | + $item->setTypeId($typeid); |
|
143 | + $item->setRefId($groupid); |
|
144 | + $item->setStatus(1); |
|
145 | 145 | |
146 | - $manager->saveItem( $item, false ); |
|
146 | + $manager->saveItem($item, false); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
@@ -158,23 +158,23 @@ discard block |
||
158 | 158 | * @param string $password New user password |
159 | 159 | * @return \Aimeos\MShop\Customer\Item\Iface Aimeos customer item object |
160 | 160 | */ |
161 | - protected function createCustomerItem( \Aimeos\MShop\Context\Item\Iface $context, $email, $password ) |
|
161 | + protected function createCustomerItem(\Aimeos\MShop\Context\Item\Iface $context, $email, $password) |
|
162 | 162 | { |
163 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
163 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
164 | 164 | |
165 | 165 | try { |
166 | - $item = $manager->findItem( $email ); |
|
167 | - } catch( \Aimeos\MShop\Exception $e ) { |
|
166 | + $item = $manager->findItem($email); |
|
167 | + } catch (\Aimeos\MShop\Exception $e) { |
|
168 | 168 | $item = $manager->createItem(); |
169 | 169 | } |
170 | 170 | |
171 | - $item->setCode( $email ); |
|
172 | - $item->setLabel( $email ); |
|
173 | - $item->getPaymentAddress()->setEmail( $email ); |
|
174 | - $item->setPassword( $password ); |
|
175 | - $item->setStatus( 1 ); |
|
171 | + $item->setCode($email); |
|
172 | + $item->setLabel($email); |
|
173 | + $item->getPaymentAddress()->setEmail($email); |
|
174 | + $item->setPassword($password); |
|
175 | + $item->setStatus(1); |
|
176 | 176 | |
177 | - $manager->saveItem( $item ); |
|
177 | + $manager->saveItem($item); |
|
178 | 178 | |
179 | 179 | return $item; |
180 | 180 | } |
@@ -187,21 +187,21 @@ discard block |
||
187 | 187 | * @param string $code Unique customer group code |
188 | 188 | * @return \Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object |
189 | 189 | */ |
190 | - protected function getGroupItem( \Aimeos\MShop\Context\Item\Iface $context, $code ) |
|
190 | + protected function getGroupItem(\Aimeos\MShop\Context\Item\Iface $context, $code) |
|
191 | 191 | { |
192 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'group' ); |
|
192 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('group'); |
|
193 | 193 | |
194 | 194 | try |
195 | 195 | { |
196 | - $item = $manager->findItem( $code ); |
|
196 | + $item = $manager->findItem($code); |
|
197 | 197 | } |
198 | - catch( \Aimeos\MShop\Exception $e ) |
|
198 | + catch (\Aimeos\MShop\Exception $e) |
|
199 | 199 | { |
200 | 200 | $item = $manager->createItem(); |
201 | - $item->setLabel( $code ); |
|
202 | - $item->setCode( $code ); |
|
201 | + $item->setLabel($code); |
|
202 | + $item->setCode($code); |
|
203 | 203 | |
204 | - $manager->saveItem( $item ); |
|
204 | + $manager->saveItem($item); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return $item; |