@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function configure() |
34 | 34 | { |
35 | - $this->setName( self::$defaultName ); |
|
36 | - $this->setDescription( 'Creates new (admin) accounts' ); |
|
37 | - $this->addArgument( 'email', InputArgument::REQUIRED, 'E-mail address of the account that should be created' ); |
|
38 | - $this->addArgument( 'site', InputArgument::OPTIONAL, 'Site codes to create accounts for like "default"', 'default' ); |
|
39 | - $this->addOption( 'password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)' ); |
|
40 | - $this->addOption( 'super', null, InputOption::VALUE_NONE, 'If account should have super user privileges' ); |
|
41 | - $this->addOption( 'admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges' ); |
|
42 | - $this->addOption( 'editor', null, InputOption::VALUE_NONE, 'If account should have limited editor privileges' ); |
|
35 | + $this->setName(self::$defaultName); |
|
36 | + $this->setDescription('Creates new (admin) accounts'); |
|
37 | + $this->addArgument('email', InputArgument::REQUIRED, 'E-mail address of the account that should be created'); |
|
38 | + $this->addArgument('site', InputArgument::OPTIONAL, 'Site codes to create accounts for like "default"', 'default'); |
|
39 | + $this->addOption('password', null, InputOption::VALUE_REQUIRED, 'Optional password for the account (will ask for if not given)'); |
|
40 | + $this->addOption('super', null, InputOption::VALUE_NONE, 'If account should have super user privileges'); |
|
41 | + $this->addOption('admin', null, InputOption::VALUE_NONE, 'If account should have administrator privileges'); |
|
42 | + $this->addOption('editor', null, InputOption::VALUE_NONE, 'If account should have limited editor privileges'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -49,54 +49,54 @@ discard block |
||
49 | 49 | * @param InputInterface $input Input object |
50 | 50 | * @param OutputInterface $output Output object |
51 | 51 | */ |
52 | - protected function execute( InputInterface $input, OutputInterface $output ) |
|
52 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
53 | 53 | { |
54 | - $code = $input->getArgument( 'email' ); |
|
55 | - if( ( $password = $input->getOption( 'password' ) ) === null ) |
|
54 | + $code = $input->getArgument('email'); |
|
55 | + if (($password = $input->getOption('password')) === null) |
|
56 | 56 | { |
57 | - $helper = $this->getHelper( 'question' ); |
|
58 | - $question = new Question( 'Password' ); |
|
59 | - $question->setHidden( true ); |
|
57 | + $helper = $this->getHelper('question'); |
|
58 | + $question = new Question('Password'); |
|
59 | + $question->setHidden(true); |
|
60 | 60 | |
61 | - $password = $helper->ask( $input, $output, $question ); |
|
61 | + $password = $helper->ask($input, $output, $question); |
|
62 | 62 | } |
63 | 63 | |
64 | - $context = $this->getContainer()->get( 'aimeos_context' )->get( false, 'command' ); |
|
65 | - $context->setEditor( 'aimeos:account' ); |
|
64 | + $context = $this->getContainer()->get('aimeos_context')->get(false, 'command'); |
|
65 | + $context->setEditor('aimeos:account'); |
|
66 | 66 | |
67 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
68 | - $localeItem = $localeManager->bootstrap( $input->getArgument( 'site' ), '', '', false ); |
|
69 | - $context->setLocale( $localeItem ); |
|
67 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
68 | + $localeItem = $localeManager->bootstrap($input->getArgument('site'), '', '', false); |
|
69 | + $context->setLocale($localeItem); |
|
70 | 70 | |
71 | - $user = $this->createCustomerItem( $context, $code, $password ); |
|
71 | + $user = $this->createCustomerItem($context, $code, $password); |
|
72 | 72 | |
73 | - if( $input->getOption( 'admin' ) ) { |
|
74 | - $this->addGroup( $input, $output, $context, $user, 'admin' ); |
|
73 | + if ($input->getOption('admin')) { |
|
74 | + $this->addGroup($input, $output, $context, $user, 'admin'); |
|
75 | 75 | } |
76 | 76 | |
77 | - if( $input->getOption( 'editor' ) ) { |
|
78 | - $this->addGroup( $input, $output, $context, $user, 'editor' ); |
|
77 | + if ($input->getOption('editor')) { |
|
78 | + $this->addGroup($input, $output, $context, $user, 'editor'); |
|
79 | 79 | } |
80 | 80 | |
81 | - if( $this->getContainer()->has( 'fos_user.user_manager' ) ) |
|
81 | + if ($this->getContainer()->has('fos_user.user_manager')) |
|
82 | 82 | { |
83 | - $userManager = $this->getContainer()->get( 'fos_user.user_manager' ); |
|
83 | + $userManager = $this->getContainer()->get('fos_user.user_manager'); |
|
84 | 84 | |
85 | - if( ( $fosUser = $userManager->findUserByUsername( $code ) ) === null ) { |
|
86 | - throw new \RuntimeException( 'No user created' ); |
|
85 | + if (($fosUser = $userManager->findUserByUsername($code)) === null) { |
|
86 | + throw new \RuntimeException('No user created'); |
|
87 | 87 | } |
88 | 88 | |
89 | - $fosUser->setSuperAdmin( false ); |
|
89 | + $fosUser->setSuperAdmin(false); |
|
90 | 90 | |
91 | - if( $input->getOption( 'super' ) ) { |
|
92 | - $fosUser->setSuperAdmin( true ); |
|
91 | + if ($input->getOption('super')) { |
|
92 | + $fosUser->setSuperAdmin(true); |
|
93 | 93 | } |
94 | 94 | |
95 | - if( $input->getOption( 'admin' ) || $input->getOption( 'editor' ) ) { |
|
96 | - $fosUser->addRole( 'ROLE_ADMIN' ); |
|
95 | + if ($input->getOption('admin') || $input->getOption('editor')) { |
|
96 | + $fosUser->addRole('ROLE_ADMIN'); |
|
97 | 97 | } |
98 | 98 | |
99 | - $userManager->updateUser( $fosUser ); |
|
99 | + $userManager->updateUser($fosUser); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -110,24 +110,24 @@ discard block |
||
110 | 110 | * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object |
111 | 111 | * @param string $group Unique customer group code |
112 | 112 | */ |
113 | - protected function addGroup( InputInterface $input, OutputInterface $output, |
|
114 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group ) |
|
113 | + protected function addGroup(InputInterface $input, OutputInterface $output, |
|
114 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group) |
|
115 | 115 | { |
116 | - $output->writeln( sprintf( 'Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode() ) ); |
|
116 | + $output->writeln(sprintf('Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode())); |
|
117 | 117 | |
118 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
118 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
119 | 119 | |
120 | - foreach( $this->getSiteItems( $context, $input ) as $siteItem ) |
|
120 | + foreach ($this->getSiteItems($context, $input) as $siteItem) |
|
121 | 121 | { |
122 | - $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
122 | + $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); |
|
123 | 123 | |
124 | 124 | $lcontext = clone $context; |
125 | - $lcontext->setLocale( $localeItem ); |
|
125 | + $lcontext->setLocale($localeItem); |
|
126 | 126 | |
127 | - $output->writeln( '- ' . $siteItem->getCode() ); |
|
127 | + $output->writeln('- '.$siteItem->getCode()); |
|
128 | 128 | |
129 | - $groupItem = $this->getGroupItem( $lcontext, $group ); |
|
130 | - $this->addListItem( $lcontext, $user->getId(), $groupItem->getId() ); |
|
129 | + $groupItem = $this->getGroupItem($lcontext, $group); |
|
130 | + $this->addListItem($lcontext, $user->getId(), $groupItem->getId()); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -139,31 +139,31 @@ discard block |
||
139 | 139 | * @param string $userid Unique user ID |
140 | 140 | * @param string $groupid Unique group ID |
141 | 141 | */ |
142 | - protected function addListItem( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid ) |
|
142 | + protected function addListItem(\Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid) |
|
143 | 143 | { |
144 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'lists' ); |
|
145 | - $typeid = $manager->getSubmanager( 'type' )->findItem( 'default', array(), 'customer/group' )->getId(); |
|
144 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('lists'); |
|
145 | + $typeid = $manager->getSubmanager('type')->findItem('default', array(), 'customer/group')->getId(); |
|
146 | 146 | |
147 | 147 | $search = $manager->createSearch(); |
148 | 148 | $expr = array( |
149 | - $search->compare( '==', 'customer.lists.parentid', $userid ), |
|
150 | - $search->compare( '==', 'customer.lists.refid', $groupid ), |
|
151 | - $search->compare( '==', 'customer.lists.domain', 'customer/group' ), |
|
152 | - $search->compare( '==', 'customer.lists.typeid', $typeid ), |
|
149 | + $search->compare('==', 'customer.lists.parentid', $userid), |
|
150 | + $search->compare('==', 'customer.lists.refid', $groupid), |
|
151 | + $search->compare('==', 'customer.lists.domain', 'customer/group'), |
|
152 | + $search->compare('==', 'customer.lists.typeid', $typeid), |
|
153 | 153 | ); |
154 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
155 | - $search->setSlice( 0, 1 ); |
|
154 | + $search->setConditions($search->combine('&&', $expr)); |
|
155 | + $search->setSlice(0, 1); |
|
156 | 156 | |
157 | - if( count( $manager->searchItems( $search ) ) === 0 ) |
|
157 | + if (count($manager->searchItems($search)) === 0) |
|
158 | 158 | { |
159 | 159 | $item = $manager->createItem(); |
160 | - $item->setDomain( 'customer/group' ); |
|
161 | - $item->setParentId( $userid ); |
|
162 | - $item->setTypeId( $typeid ); |
|
163 | - $item->setRefId( $groupid ); |
|
164 | - $item->setStatus( 1 ); |
|
160 | + $item->setDomain('customer/group'); |
|
161 | + $item->setParentId($userid); |
|
162 | + $item->setTypeId($typeid); |
|
163 | + $item->setRefId($groupid); |
|
164 | + $item->setStatus(1); |
|
165 | 165 | |
166 | - $manager->saveItem( $item, false ); |
|
166 | + $manager->saveItem($item, false); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -178,23 +178,23 @@ discard block |
||
178 | 178 | * @param string $password New user password |
179 | 179 | * @return \Aimeos\MShop\Customer\Item\Iface Aimeos customer item object |
180 | 180 | */ |
181 | - protected function createCustomerItem( \Aimeos\MShop\Context\Item\Iface $context, $email, $password ) |
|
181 | + protected function createCustomerItem(\Aimeos\MShop\Context\Item\Iface $context, $email, $password) |
|
182 | 182 | { |
183 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
183 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
184 | 184 | |
185 | 185 | try { |
186 | - $item = $manager->findItem( $email ); |
|
187 | - } catch( \Aimeos\MShop\Exception $e ) { |
|
186 | + $item = $manager->findItem($email); |
|
187 | + } catch (\Aimeos\MShop\Exception $e) { |
|
188 | 188 | $item = $manager->createItem(); |
189 | 189 | } |
190 | 190 | |
191 | - $item->setCode( $email ); |
|
192 | - $item->setLabel( $email ); |
|
193 | - $item->getPaymentAddress()->setEmail( $email ); |
|
194 | - $item->setPassword( $password ); |
|
195 | - $item->setStatus( 1 ); |
|
191 | + $item->setCode($email); |
|
192 | + $item->setLabel($email); |
|
193 | + $item->getPaymentAddress()->setEmail($email); |
|
194 | + $item->setPassword($password); |
|
195 | + $item->setStatus(1); |
|
196 | 196 | |
197 | - $manager->saveItem( $item ); |
|
197 | + $manager->saveItem($item); |
|
198 | 198 | |
199 | 199 | return $item; |
200 | 200 | } |
@@ -207,21 +207,21 @@ discard block |
||
207 | 207 | * @param string $code Unique customer group code |
208 | 208 | * @return \Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object |
209 | 209 | */ |
210 | - protected function getGroupItem( \Aimeos\MShop\Context\Item\Iface $context, $code ) |
|
210 | + protected function getGroupItem(\Aimeos\MShop\Context\Item\Iface $context, $code) |
|
211 | 211 | { |
212 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'group' ); |
|
212 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('group'); |
|
213 | 213 | |
214 | 214 | try |
215 | 215 | { |
216 | - $item = $manager->findItem( $code ); |
|
216 | + $item = $manager->findItem($code); |
|
217 | 217 | } |
218 | - catch( \Aimeos\MShop\Exception $e ) |
|
218 | + catch (\Aimeos\MShop\Exception $e) |
|
219 | 219 | { |
220 | 220 | $item = $manager->createItem(); |
221 | - $item->setLabel( $code ); |
|
222 | - $item->setCode( $code ); |
|
221 | + $item->setLabel($code); |
|
222 | + $item->setCode($code); |
|
223 | 223 | |
224 | - $manager->saveItem( $item ); |
|
224 | + $manager->saveItem($item); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $item; |