@@ -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,50 +46,50 @@ 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( 'admin' ) ) { |
|
71 | - $this->addGroup( $input, $output, $context, $user, 'admin' ); |
|
70 | + if ($input->getOption('admin')) { |
|
71 | + $this->addGroup($input, $output, $context, $user, 'admin'); |
|
72 | 72 | } |
73 | 73 | |
74 | - if( $input->getOption( 'editor' ) ) { |
|
75 | - $this->addGroup( $input, $output, $context, $user, 'editor' ); |
|
74 | + if ($input->getOption('editor')) { |
|
75 | + $this->addGroup($input, $output, $context, $user, 'editor'); |
|
76 | 76 | } |
77 | 77 | |
78 | - if( $this->getContainer()->has( 'fos_user.user_manager' ) ) |
|
78 | + if ($this->getContainer()->has('fos_user.user_manager')) |
|
79 | 79 | { |
80 | - $userManager = $this->getContainer()->get( 'fos_user.user_manager' ); |
|
81 | - $fosUser = $userManager->findUserByUsername( $code ); |
|
82 | - $fosUser->setSuperAdmin( false ); |
|
80 | + $userManager = $this->getContainer()->get('fos_user.user_manager'); |
|
81 | + $fosUser = $userManager->findUserByUsername($code); |
|
82 | + $fosUser->setSuperAdmin(false); |
|
83 | 83 | |
84 | - if( $input->getOption( 'super' ) ) { |
|
85 | - $fosUser->setSuperAdmin( true ); |
|
84 | + if ($input->getOption('super')) { |
|
85 | + $fosUser->setSuperAdmin(true); |
|
86 | 86 | } |
87 | 87 | |
88 | - if( $input->getOption( 'admin' ) || $input->getOption( 'editor' ) ) { |
|
89 | - $fosUser->addRole( 'ROLE_ADMIN' ); |
|
88 | + if ($input->getOption('admin') || $input->getOption('editor')) { |
|
89 | + $fosUser->addRole('ROLE_ADMIN'); |
|
90 | 90 | } |
91 | 91 | |
92 | - $userManager->updateUser( $fosUser ); |
|
92 | + $userManager->updateUser($fosUser); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -103,24 +103,24 @@ discard block |
||
103 | 103 | * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object |
104 | 104 | * @param string $group Unique customer group code |
105 | 105 | */ |
106 | - protected function addGroup( InputInterface $input, OutputInterface $output, |
|
107 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group ) |
|
106 | + protected function addGroup(InputInterface $input, OutputInterface $output, |
|
107 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group) |
|
108 | 108 | { |
109 | - $output->writeln( sprintf( 'Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode() ) ); |
|
109 | + $output->writeln(sprintf('Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode())); |
|
110 | 110 | |
111 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
111 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
112 | 112 | |
113 | - foreach( $this->getSiteItems( $context, $input ) as $siteItem ) |
|
113 | + foreach ($this->getSiteItems($context, $input) as $siteItem) |
|
114 | 114 | { |
115 | - $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
115 | + $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); |
|
116 | 116 | |
117 | 117 | $lcontext = clone $context; |
118 | - $lcontext->setLocale( $localeItem ); |
|
118 | + $lcontext->setLocale($localeItem); |
|
119 | 119 | |
120 | - $output->writeln( '- ' . $siteItem->getCode() ); |
|
120 | + $output->writeln('- '.$siteItem->getCode()); |
|
121 | 121 | |
122 | - $groupItem = $this->getGroupItem( $lcontext, $group ); |
|
123 | - $this->addListItem( $lcontext, $user->getId(), $groupItem->getId() ); |
|
122 | + $groupItem = $this->getGroupItem($lcontext, $group); |
|
123 | + $this->addListItem($lcontext, $user->getId(), $groupItem->getId()); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -132,31 +132,31 @@ discard block |
||
132 | 132 | * @param string $userid Unique user ID |
133 | 133 | * @param string $groupid Unique group ID |
134 | 134 | */ |
135 | - protected function addListItem( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid ) |
|
135 | + protected function addListItem(\Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid) |
|
136 | 136 | { |
137 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'lists' ); |
|
138 | - $typeid = $manager->getSubmanager( 'type' )->findItem( 'default', array(), 'customer/group' )->getId(); |
|
137 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('lists'); |
|
138 | + $typeid = $manager->getSubmanager('type')->findItem('default', array(), 'customer/group')->getId(); |
|
139 | 139 | |
140 | 140 | $search = $manager->createSearch(); |
141 | 141 | $expr = array( |
142 | - $search->compare( '==', 'customer.lists.parentid', $userid ), |
|
143 | - $search->compare( '==', 'customer.lists.refid', $groupid ), |
|
144 | - $search->compare( '==', 'customer.lists.domain', 'customer/group' ), |
|
145 | - $search->compare( '==', 'customer.lists.typeid', $typeid ), |
|
142 | + $search->compare('==', 'customer.lists.parentid', $userid), |
|
143 | + $search->compare('==', 'customer.lists.refid', $groupid), |
|
144 | + $search->compare('==', 'customer.lists.domain', 'customer/group'), |
|
145 | + $search->compare('==', 'customer.lists.typeid', $typeid), |
|
146 | 146 | ); |
147 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
148 | - $search->setSlice( 0, 1 ); |
|
147 | + $search->setConditions($search->combine('&&', $expr)); |
|
148 | + $search->setSlice(0, 1); |
|
149 | 149 | |
150 | - if( count( $manager->searchItems( $search ) ) === 0 ) |
|
150 | + if (count($manager->searchItems($search)) === 0) |
|
151 | 151 | { |
152 | 152 | $item = $manager->createItem(); |
153 | - $item->setDomain( 'customer/group' ); |
|
154 | - $item->setParentId( $userid ); |
|
155 | - $item->setTypeId( $typeid ); |
|
156 | - $item->setRefId( $groupid ); |
|
157 | - $item->setStatus( 1 ); |
|
153 | + $item->setDomain('customer/group'); |
|
154 | + $item->setParentId($userid); |
|
155 | + $item->setTypeId($typeid); |
|
156 | + $item->setRefId($groupid); |
|
157 | + $item->setStatus(1); |
|
158 | 158 | |
159 | - $manager->saveItem( $item, false ); |
|
159 | + $manager->saveItem($item, false); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -171,23 +171,23 @@ discard block |
||
171 | 171 | * @param string $password New user password |
172 | 172 | * @return \Aimeos\MShop\Customer\Item\Iface Aimeos customer item object |
173 | 173 | */ |
174 | - protected function createCustomerItem( \Aimeos\MShop\Context\Item\Iface $context, $email, $password ) |
|
174 | + protected function createCustomerItem(\Aimeos\MShop\Context\Item\Iface $context, $email, $password) |
|
175 | 175 | { |
176 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
176 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
177 | 177 | |
178 | 178 | try { |
179 | - $item = $manager->findItem( $email ); |
|
180 | - } catch( \Aimeos\MShop\Exception $e ) { |
|
179 | + $item = $manager->findItem($email); |
|
180 | + } catch (\Aimeos\MShop\Exception $e) { |
|
181 | 181 | $item = $manager->createItem(); |
182 | 182 | } |
183 | 183 | |
184 | - $item->setCode( $email ); |
|
185 | - $item->setLabel( $email ); |
|
186 | - $item->getPaymentAddress()->setEmail( $email ); |
|
187 | - $item->setPassword( $password ); |
|
188 | - $item->setStatus( 1 ); |
|
184 | + $item->setCode($email); |
|
185 | + $item->setLabel($email); |
|
186 | + $item->getPaymentAddress()->setEmail($email); |
|
187 | + $item->setPassword($password); |
|
188 | + $item->setStatus(1); |
|
189 | 189 | |
190 | - $manager->saveItem( $item ); |
|
190 | + $manager->saveItem($item); |
|
191 | 191 | |
192 | 192 | return $item; |
193 | 193 | } |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | * @param string $code Unique customer group code |
201 | 201 | * @return \Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object |
202 | 202 | */ |
203 | - protected function getGroupItem( \Aimeos\MShop\Context\Item\Iface $context, $code ) |
|
203 | + protected function getGroupItem(\Aimeos\MShop\Context\Item\Iface $context, $code) |
|
204 | 204 | { |
205 | - $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $context )->getSubmanager( 'group' ); |
|
205 | + $manager = \Aimeos\MShop\Customer\Manager\Factory::createManager($context)->getSubmanager('group'); |
|
206 | 206 | |
207 | 207 | try |
208 | 208 | { |
209 | - $item = $manager->findItem( $code ); |
|
209 | + $item = $manager->findItem($code); |
|
210 | 210 | } |
211 | - catch( \Aimeos\MShop\Exception $e ) |
|
211 | + catch (\Aimeos\MShop\Exception $e) |
|
212 | 212 | { |
213 | 213 | $item = $manager->createItem(); |
214 | - $item->setLabel( $code ); |
|
215 | - $item->setCode( $code ); |
|
214 | + $item->setLabel($code); |
|
215 | + $item->setCode($code); |
|
216 | 216 | |
217 | - $manager->saveItem( $item ); |
|
217 | + $manager->saveItem($item); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | return $item; |