@@ -47,8 +47,7 @@ |
||
| 47 | 47 | try |
| 48 | 48 | { |
| 49 | 49 | $item = $manager->findItem( $list['customer.code'], [], true ); |
| 50 | - } |
|
| 51 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 50 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 52 | 51 | { |
| 53 | 52 | $this->checkLimit( $list ); |
| 54 | 53 | |
@@ -28,29 +28,29 @@ discard block |
||
| 28 | 28 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
| 29 | 29 | * @since 2017.04 |
| 30 | 30 | */ |
| 31 | - public function addItem( array $values ) |
|
| 31 | + public function addItem(array $values) |
|
| 32 | 32 | { |
| 33 | 33 | $list = []; |
| 34 | 34 | $context = $this->getContext(); |
| 35 | 35 | $config = $context->getConfig(); |
| 36 | 36 | |
| 37 | - foreach( $values as $key => $val ) { |
|
| 38 | - $list[str_replace( 'order.base.address', 'customer', $key )] = $val; |
|
| 37 | + foreach ($values as $key => $val) { |
|
| 38 | + $list[str_replace('order.base.address', 'customer', $key)] = $val; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $manager = \Aimeos\MShop::create( $context, 'customer' ); |
|
| 42 | - $list = $this->addItemDefaults( $list ); |
|
| 41 | + $manager = \Aimeos\MShop::create($context, 'customer'); |
|
| 42 | + $list = $this->addItemDefaults($list); |
|
| 43 | 43 | $passwd = $list['customer.password']; |
| 44 | 44 | |
| 45 | 45 | try |
| 46 | 46 | { |
| 47 | - $item = $manager->findItem( $list['customer.code'], [], true ); |
|
| 47 | + $item = $manager->findItem($list['customer.code'], [], true); |
|
| 48 | 48 | } |
| 49 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 49 | + catch (\Aimeos\MShop\Exception $e) |
|
| 50 | 50 | { |
| 51 | - $this->checkLimit( $list ); |
|
| 51 | + $this->checkLimit($list); |
|
| 52 | 52 | |
| 53 | - $item = $manager->createItem()->fromArray( $list )->setId( null ); |
|
| 53 | + $item = $manager->createItem()->fromArray($list)->setId(null); |
|
| 54 | 54 | |
| 55 | 55 | /** controller/frontend/customer/groupids |
| 56 | 56 | * List of groups new customers should be assigned to |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | * @category User |
| 65 | 65 | * @category Developer |
| 66 | 66 | */ |
| 67 | - $item->setGroups( (array) $config->get( 'controller/frontend/customer/groupids', [] ) ); |
|
| 67 | + $item->setGroups((array) $config->get('controller/frontend/customer/groupids', [])); |
|
| 68 | 68 | |
| 69 | - $item = $manager->saveItem( $item ); |
|
| 69 | + $item = $manager->saveItem($item); |
|
| 70 | 70 | |
| 71 | 71 | $msg = $item->toArray(); |
| 72 | 72 | // Show only generated passwords in account creation e-mails |
| 73 | - $msg['customer.password'] = ( isset( $values['customer.password'] ) ? null : $passwd ); |
|
| 74 | - $context->getMessageQueue( 'mq-email', 'customer/email/account' )->add( json_encode( $msg ) ); |
|
| 73 | + $msg['customer.password'] = (isset($values['customer.password']) ? null : $passwd); |
|
| 74 | + $context->getMessageQueue('mq-email', 'customer/email/account')->add(json_encode($msg)); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | return $item; |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
| 85 | 85 | */ |
| 86 | - public function createItem( array $values = [] ) |
|
| 86 | + public function createItem(array $values = []) |
|
| 87 | 87 | { |
| 88 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer' ); |
|
| 89 | - return $manager->createItem()->fromArray( $values )->setId( null ); |
|
| 88 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer'); |
|
| 89 | + return $manager->createItem()->fromArray($values)->setId(null); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | * @param string $id Unique customer ID |
| 97 | 97 | * @since 2017.04 |
| 98 | 98 | */ |
| 99 | - public function deleteItem( $id ) |
|
| 99 | + public function deleteItem($id) |
|
| 100 | 100 | { |
| 101 | - $this->checkUser( $id ); |
|
| 101 | + $this->checkUser($id); |
|
| 102 | 102 | |
| 103 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer' ); |
|
| 104 | - $manager->deleteItem( $id ); |
|
| 103 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer'); |
|
| 104 | + $manager->deleteItem($id); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
| 114 | 114 | * @since 2017.04 |
| 115 | 115 | */ |
| 116 | - public function editItem( $id, array $values ) |
|
| 116 | + public function editItem($id, array $values) |
|
| 117 | 117 | { |
| 118 | - $this->checkUser( $id ); |
|
| 119 | - unset( $values['customer.id'] ); |
|
| 118 | + $this->checkUser($id); |
|
| 119 | + unset($values['customer.id']); |
|
| 120 | 120 | |
| 121 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer' ); |
|
| 122 | - $item = $manager->getItem( $id, ['customer/group'], true )->fromArray( $values ); |
|
| 121 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer'); |
|
| 122 | + $item = $manager->getItem($id, ['customer/group'], true)->fromArray($values); |
|
| 123 | 123 | |
| 124 | - return $manager->saveItem( $item ); |
|
| 124 | + return $manager->saveItem($item); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
@@ -133,17 +133,17 @@ discard block |
||
| 133 | 133 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
| 134 | 134 | * @since 2017.04 |
| 135 | 135 | */ |
| 136 | - public function getItem( $id = null, array $domains = [] ) |
|
| 136 | + public function getItem($id = null, array $domains = []) |
|
| 137 | 137 | { |
| 138 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer' ); |
|
| 138 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer'); |
|
| 139 | 139 | |
| 140 | - if( $id == null ) { |
|
| 141 | - return $manager->getItem( $this->getContext()->getUserId(), $domains, true ); |
|
| 140 | + if ($id == null) { |
|
| 141 | + return $manager->getItem($this->getContext()->getUserId(), $domains, true); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $this->checkUser( $id ); |
|
| 144 | + $this->checkUser($id); |
|
| 145 | 145 | |
| 146 | - return $manager->getItem( $id, $domains, true ); |
|
| 146 | + return $manager->getItem($id, $domains, true); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
| 158 | 158 | * @since 2017.04 |
| 159 | 159 | */ |
| 160 | - public function findItem( $code, array $domains = [] ) |
|
| 160 | + public function findItem($code, array $domains = []) |
|
| 161 | 161 | { |
| 162 | - return \Aimeos\MShop::create( $this->getContext(), 'customer' )->findItem( $code, $domains, true ); |
|
| 162 | + return \Aimeos\MShop::create($this->getContext(), 'customer')->findItem($code, $domains, true); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item |
| 170 | 170 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID |
| 171 | 171 | */ |
| 172 | - public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ) |
|
| 172 | + public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item) |
|
| 173 | 173 | { |
| 174 | - return \Aimeos\MShop::create( $this->getContext(), 'customer' )->saveItem( $item ); |
|
| 174 | + return \Aimeos\MShop::create($this->getContext(), 'customer')->saveItem($item); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 183 | 183 | * @since 2017.04 |
| 184 | 184 | */ |
| 185 | - public function addAddressItem( array $values ) |
|
| 185 | + public function addAddressItem(array $values) |
|
| 186 | 186 | { |
| 187 | 187 | $context = $this->getContext(); |
| 188 | - $manager = \Aimeos\MShop::create( $context, 'customer/address' ); |
|
| 188 | + $manager = \Aimeos\MShop::create($context, 'customer/address'); |
|
| 189 | 189 | |
| 190 | - $item = $manager->createItem()->fromArray( $values )->setId( null )->setParentId( $context->getUserId() ); |
|
| 191 | - return $manager->saveItem( $item ); |
|
| 190 | + $item = $manager->createItem()->fromArray($values)->setId(null)->setParentId($context->getUserId()); |
|
| 191 | + return $manager->saveItem($item); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 199 | 199 | */ |
| 200 | - public function createAddressItem( array $values = [] ) |
|
| 200 | + public function createAddressItem(array $values = []) |
|
| 201 | 201 | { |
| 202 | 202 | $context = $this->getContext(); |
| 203 | - $manager = \Aimeos\MShop::create( $context, 'customer/address' ); |
|
| 203 | + $manager = \Aimeos\MShop::create($context, 'customer/address'); |
|
| 204 | 204 | |
| 205 | - return $manager->createItem()->fromArray( $values )->setId( null )->setParentId( $context->getUserId() ); |
|
| 205 | + return $manager->createItem()->fromArray($values)->setId(null)->setParentId($context->getUserId()); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
@@ -212,13 +212,13 @@ discard block |
||
| 212 | 212 | * @param string $id Unique customer address ID |
| 213 | 213 | * @since 2017.04 |
| 214 | 214 | */ |
| 215 | - public function deleteAddressItem( $id ) |
|
| 215 | + public function deleteAddressItem($id) |
|
| 216 | 216 | { |
| 217 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/address' ); |
|
| 217 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/address'); |
|
| 218 | 218 | |
| 219 | - $this->checkUser( $manager->getItem( $id, [], true )->getParentId() ); |
|
| 219 | + $this->checkUser($manager->getItem($id, [], true)->getParentId()); |
|
| 220 | 220 | |
| 221 | - $manager->deleteItem( $id ); |
|
| 221 | + $manager->deleteItem($id); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
@@ -230,15 +230,15 @@ discard block |
||
| 230 | 230 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 231 | 231 | * @since 2017.04 |
| 232 | 232 | */ |
| 233 | - public function editAddressItem( $id, array $values ) |
|
| 233 | + public function editAddressItem($id, array $values) |
|
| 234 | 234 | { |
| 235 | - unset( $values['customer.address.id'] ); |
|
| 236 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/address' ); |
|
| 235 | + unset($values['customer.address.id']); |
|
| 236 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/address'); |
|
| 237 | 237 | |
| 238 | - $item = $manager->getItem( $id, [], true ); |
|
| 239 | - $this->checkUser( $item->getParentId() ); |
|
| 238 | + $item = $manager->getItem($id, [], true); |
|
| 239 | + $this->checkUser($item->getParentId()); |
|
| 240 | 240 | |
| 241 | - return $manager->saveItem( $item->fromArray( $values ) ); |
|
| 241 | + return $manager->saveItem($item->fromArray($values)); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 250 | 250 | * @since 2017.04 |
| 251 | 251 | */ |
| 252 | - public function getAddressItem( $id ) |
|
| 252 | + public function getAddressItem($id) |
|
| 253 | 253 | { |
| 254 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/address' ); |
|
| 254 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/address'); |
|
| 255 | 255 | |
| 256 | - $item = $manager->getItem( $id ); |
|
| 257 | - $this->checkUser( $item->getParentId() ); |
|
| 256 | + $item = $manager->getItem($id); |
|
| 257 | + $this->checkUser($item->getParentId()); |
|
| 258 | 258 | |
| 259 | 259 | return $item; |
| 260 | 260 | } |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | * @param \Aimeos\MShop\Customer\Item\Address\Iface $item Customer address item |
| 267 | 267 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID |
| 268 | 268 | */ |
| 269 | - public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ) |
|
| 269 | + public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item) |
|
| 270 | 270 | { |
| 271 | - return \Aimeos\MShop::create( $this->getContext(), 'customer/address' )->saveItem( $item ); |
|
| 271 | + return \Aimeos\MShop::create($this->getContext(), 'customer/address')->saveItem($item); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
| 280 | 280 | * @since 2017.06 |
| 281 | 281 | */ |
| 282 | - public function addListItem( array $values ) |
|
| 282 | + public function addListItem(array $values) |
|
| 283 | 283 | { |
| 284 | 284 | $context = $this->getContext(); |
| 285 | - $manager = \Aimeos\MShop::create( $context, 'customer/lists' ); |
|
| 285 | + $manager = \Aimeos\MShop::create($context, 'customer/lists'); |
|
| 286 | 286 | |
| 287 | - $item = $manager->createItem()->fromArray( $values )->setId( null )->setParentId( $context->getUserId() ); |
|
| 288 | - return $manager->saveItem( $item ); |
|
| 287 | + $item = $manager->createItem()->fromArray($values)->setId(null)->setParentId($context->getUserId()); |
|
| 288 | + return $manager->saveItem($item); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | public function createListsFilter() |
| 299 | 299 | { |
| 300 | 300 | $context = $this->getContext(); |
| 301 | - $manager = \Aimeos\MShop::create( $context, 'customer/lists' ); |
|
| 301 | + $manager = \Aimeos\MShop::create($context, 'customer/lists'); |
|
| 302 | 302 | |
| 303 | 303 | $filter = $manager->createSearch(); |
| 304 | - $filter->setConditions( $filter->compare( '==', 'customer.lists.parentid', $context->getUserId() ) ); |
|
| 304 | + $filter->setConditions($filter->compare('==', 'customer.lists.parentid', $context->getUserId())); |
|
| 305 | 305 | |
| 306 | 306 | return $filter; |
| 307 | 307 | } |
@@ -313,13 +313,13 @@ discard block |
||
| 313 | 313 | * @param string $id Unique customer address ID |
| 314 | 314 | * @since 2017.06 |
| 315 | 315 | */ |
| 316 | - public function deleteListItem( $id ) |
|
| 316 | + public function deleteListItem($id) |
|
| 317 | 317 | { |
| 318 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists' ); |
|
| 318 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/lists'); |
|
| 319 | 319 | |
| 320 | - $this->checkUser( $manager->getItem( $id )->getParentId() ); |
|
| 320 | + $this->checkUser($manager->getItem($id)->getParentId()); |
|
| 321 | 321 | |
| 322 | - $manager->deleteItem( $id ); |
|
| 322 | + $manager->deleteItem($id); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -331,16 +331,16 @@ discard block |
||
| 331 | 331 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
| 332 | 332 | * @since 2017.06 |
| 333 | 333 | */ |
| 334 | - public function editListItem( $id, array $values ) |
|
| 334 | + public function editListItem($id, array $values) |
|
| 335 | 335 | { |
| 336 | 336 | $context = $this->getContext(); |
| 337 | - $manager = \Aimeos\MShop::create( $context, 'customer/lists' ); |
|
| 337 | + $manager = \Aimeos\MShop::create($context, 'customer/lists'); |
|
| 338 | 338 | |
| 339 | - $item = $manager->getItem( $id, [], true ); |
|
| 340 | - $this->checkUser( $item->getParentId() ); |
|
| 341 | - unset( $values['customer.lists.id'] ); |
|
| 339 | + $item = $manager->getItem($id, [], true); |
|
| 340 | + $this->checkUser($item->getParentId()); |
|
| 341 | + unset($values['customer.lists.id']); |
|
| 342 | 342 | |
| 343 | - return $manager->saveItem( $item->fromArray( $values ) ); |
|
| 343 | + return $manager->saveItem($item->fromArray($values)); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 352 | 352 | * @since 2017.06 |
| 353 | 353 | */ |
| 354 | - public function getListItem( $id ) |
|
| 354 | + public function getListItem($id) |
|
| 355 | 355 | { |
| 356 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists' ); |
|
| 357 | - $item = $manager->getItem( $id ); |
|
| 356 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/lists'); |
|
| 357 | + $item = $manager->getItem($id); |
|
| 358 | 358 | |
| 359 | - $this->checkUser( $item->getParentId() ); |
|
| 359 | + $this->checkUser($item->getParentId()); |
|
| 360 | 360 | |
| 361 | 361 | return $item; |
| 362 | 362 | } |
@@ -370,11 +370,11 @@ discard block |
||
| 370 | 370 | * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items |
| 371 | 371 | * @since 2017.06 |
| 372 | 372 | */ |
| 373 | - public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
| 373 | + public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
| 374 | 374 | { |
| 375 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists' ); |
|
| 375 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/lists'); |
|
| 376 | 376 | |
| 377 | - return $manager->searchItems( $filter, [], $total ); |
|
| 377 | + return $manager->searchItems($filter, [], $total); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | |
@@ -384,33 +384,33 @@ discard block |
||
| 384 | 384 | * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values |
| 385 | 385 | * @return string[] Associative list of customer key/value pairs with default values set |
| 386 | 386 | */ |
| 387 | - protected function addItemDefaults( array $values ) |
|
| 387 | + protected function addItemDefaults(array $values) |
|
| 388 | 388 | { |
| 389 | - if( !isset( $values['customer.label'] ) || $values['customer.label'] == '' ) |
|
| 389 | + if (!isset($values['customer.label']) || $values['customer.label'] == '') |
|
| 390 | 390 | { |
| 391 | 391 | $label = ''; |
| 392 | 392 | |
| 393 | - if( isset( $values['customer.lastname'] ) ) { |
|
| 393 | + if (isset($values['customer.lastname'])) { |
|
| 394 | 394 | $label = $values['customer.lastname']; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if( isset( $values['customer.firstname'] ) && $values['customer.firstname'] != '' ) { |
|
| 397 | + if (isset($values['customer.firstname']) && $values['customer.firstname'] != '') { |
|
| 398 | 398 | $label = $values['customer.firstname'] . ' ' . $label; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if( isset( $values['customer.company'] ) && $values['customer.company'] != '' ) { |
|
| 401 | + if (isset($values['customer.company']) && $values['customer.company'] != '') { |
|
| 402 | 402 | $label .= ' (' . $values['customer.company'] . ')'; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | $values['customer.label'] = $label; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if( !isset( $values['customer.code'] ) && isset( $values['customer.email'] ) ) { |
|
| 408 | + if (!isset($values['customer.code']) && isset($values['customer.email'])) { |
|
| 409 | 409 | $values['customer.code'] = $values['customer.email']; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if( !isset( $values['customer.password'] ) ) { |
|
| 413 | - $values['customer.password'] = substr( md5( microtime( true ) . getmypid() . rand() ), -8 ); |
|
| 412 | + if (!isset($values['customer.password'])) { |
|
| 413 | + $values['customer.password'] = substr(md5(microtime(true) . getmypid() . rand()), -8); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | return $values; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values |
| 424 | 424 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
| 425 | 425 | */ |
| 426 | - protected function checkLimit( array $values ) |
|
| 426 | + protected function checkLimit(array $values) |
|
| 427 | 427 | { |
| 428 | 428 | $total = 0; |
| 429 | 429 | $context = $this->getContext(); |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * @category Developer |
| 445 | 445 | * @see controller/frontend/customer/limit-seconds |
| 446 | 446 | */ |
| 447 | - $count = $config->get( 'controller/frontend/customer/limit-count', 5 ); |
|
| 447 | + $count = $config->get('controller/frontend/customer/limit-count', 5); |
|
| 448 | 448 | |
| 449 | 449 | /** controller/frontend/customer/limit-seconds |
| 450 | 450 | * Customer account limitation time frame in seconds |
@@ -462,22 +462,22 @@ discard block |
||
| 462 | 462 | * @category Developer |
| 463 | 463 | * @see controller/frontend/customer/limit-count |
| 464 | 464 | */ |
| 465 | - $seconds = $config->get( 'controller/frontend/customer/limit-seconds', 300 ); |
|
| 465 | + $seconds = $config->get('controller/frontend/customer/limit-seconds', 300); |
|
| 466 | 466 | |
| 467 | - $manager = \Aimeos\MShop::create( $context, 'customer' ); |
|
| 467 | + $manager = \Aimeos\MShop::create($context, 'customer'); |
|
| 468 | 468 | |
| 469 | 469 | $search = $manager->createSearch(); |
| 470 | 470 | $expr = [ |
| 471 | - $search->compare( '==', 'customer.editor', $context->getEditor() ), |
|
| 472 | - $search->compare( '>=', 'customer.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
| 471 | + $search->compare('==', 'customer.editor', $context->getEditor()), |
|
| 472 | + $search->compare('>=', 'customer.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
| 473 | 473 | ]; |
| 474 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 475 | - $search->setSlice( 0, 0 ); |
|
| 474 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 475 | + $search->setSlice(0, 0); |
|
| 476 | 476 | |
| 477 | - $manager->searchItems( $search, [], $total ); |
|
| 477 | + $manager->searchItems($search, [], $total); |
|
| 478 | 478 | |
| 479 | - if( $total > $count ) { |
|
| 480 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Temporary limit reached' ) ); |
|
| 479 | + if ($total > $count) { |
|
| 480 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Temporary limit reached')); |
|
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | |
@@ -488,12 +488,12 @@ discard block |
||
| 488 | 488 | * @param string $id Unique customer ID |
| 489 | 489 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
| 490 | 490 | */ |
| 491 | - protected function checkUser( $id ) |
|
| 491 | + protected function checkUser($id) |
|
| 492 | 492 | { |
| 493 | - if( $id != $this->getContext()->getUserId() ) |
|
| 493 | + if ($id != $this->getContext()->getUserId()) |
|
| 494 | 494 | { |
| 495 | - $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); |
|
| 496 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); |
|
| 495 | + $msg = sprintf('Not allowed to access customer data for ID "%1$s"', $id); |
|
| 496 | + throw new \Aimeos\Controller\Frontend\Customer\Exception($msg); |
|
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | } |
@@ -121,10 +121,11 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | $msg = $context->getI18n()->dt( 'controller/frontend', 'No unique article found for selected attributes and product ID "%1$s"' ); |
| 123 | 123 | throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $productItem->getId() ) ); |
| 124 | - } |
|
| 125 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
| 124 | + } else if( ( $result = reset( $productItems ) ) !== false ) { |
|
| 125 | + // count == 1 |
|
| 126 | 126 | { |
| 127 | 127 | $productItem = $result; |
| 128 | + } |
|
| 128 | 129 | $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
| 129 | 130 | |
| 130 | 131 | $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
@@ -150,10 +151,11 @@ discard block |
||
| 150 | 151 | |
| 151 | 152 | $attr[] = $orderAttributeItem; |
| 152 | 153 | } |
| 153 | - } |
|
| 154 | - else if( $requireVariant != false ) // count == 0 |
|
| 154 | + } else if( $requireVariant != false ) { |
|
| 155 | + // count == 0 |
|
| 155 | 156 | { |
| 156 | 157 | $msg = $context->getI18n()->dt( 'controller/frontend', 'No article found for selected attributes and product ID "%1$s"' ); |
| 158 | + } |
|
| 157 | 159 | throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $productItem->getId() ) ); |
| 158 | 160 | } |
| 159 | 161 | |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 38 | 38 | */ |
| 39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
| 39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
| 41 | 41 | { |
| 42 | 42 | $context = $this->getContext(); |
| 43 | - $productManager = \Aimeos\MShop::create( $context, 'product' ); |
|
| 44 | - $productItem = $productManager->getItem( $prodid, [], true ); |
|
| 43 | + $productManager = \Aimeos\MShop::create($context, 'product'); |
|
| 44 | + $productItem = $productManager->getItem($prodid, [], true); |
|
| 45 | 45 | |
| 46 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'select' ) |
|
| 46 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'select') |
|
| 47 | 47 | { |
| 48 | 48 | return $this->getController()->addProduct( |
| 49 | 49 | $prodid, $quantity, $stocktype, $variantAttributeIds, |
@@ -51,30 +51,30 @@ discard block |
||
| 51 | 51 | ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $productItem = $productManager->getItem( $prodid, ['attribute', 'media', 'supplier', 'price', 'product', 'text'], true ); |
|
| 55 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 56 | - $hidden = $productItem->getRefItems( 'attribute', null, 'hidden' ); |
|
| 54 | + $productItem = $productManager->getItem($prodid, ['attribute', 'media', 'supplier', 'price', 'product', 'text'], true); |
|
| 55 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 56 | + $hidden = $productItem->getRefItems('attribute', null, 'hidden'); |
|
| 57 | 57 | |
| 58 | - $orderBaseProductItem = \Aimeos\MShop::create( $context, 'order/base/product' )->createItem(); |
|
| 59 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
| 58 | + $orderBaseProductItem = \Aimeos\MShop::create($context, 'order/base/product')->createItem(); |
|
| 59 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
| 60 | 60 | |
| 61 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds ); |
|
| 62 | - $hidden += $productItem->getRefItems( 'attribute', null, 'hidden' ); |
|
| 61 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds); |
|
| 62 | + $hidden += $productItem->getRefItems('attribute', null, 'hidden'); |
|
| 63 | 63 | |
| 64 | 64 | $attributeMap = [ |
| 65 | - 'custom' => array_keys( $customAttributeValues ), |
|
| 66 | - 'config' => array_keys( $configAttributeIds ), |
|
| 65 | + 'custom' => array_keys($customAttributeValues), |
|
| 66 | + 'config' => array_keys($configAttributeIds), |
|
| 67 | 67 | ]; |
| 68 | - $this->checkListRef( array( $prodid, $productItem->getId() ), 'attribute', $attributeMap ); |
|
| 68 | + $this->checkListRef(array($prodid, $productItem->getId()), 'attribute', $attributeMap); |
|
| 69 | 69 | |
| 70 | - $custAttr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
| 71 | - $confAttr = $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ); |
|
| 72 | - $attr = array_merge( $attr, $custAttr, $confAttr, $this->getOrderProductAttributes( 'hidden', array_keys( $hidden ) ) ); |
|
| 70 | + $custAttr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
| 71 | + $confAttr = $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds); |
|
| 72 | + $attr = array_merge($attr, $custAttr, $confAttr, $this->getOrderProductAttributes('hidden', array_keys($hidden))); |
|
| 73 | 73 | |
| 74 | - $orderBaseProductItem->setAttributeItems( $attr ); |
|
| 75 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
| 74 | + $orderBaseProductItem->setAttributeItems($attr); |
|
| 75 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
| 76 | 76 | |
| 77 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
| 77 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
| 78 | 78 | $this->getController()->save(); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
| 90 | 90 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
| 91 | 91 | */ |
| 92 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 93 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds ) |
|
| 92 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 93 | + \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds) |
|
| 94 | 94 | { |
| 95 | 95 | $attr = []; |
| 96 | 96 | $context = $this->getContext(); |
| 97 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
| 97 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
| 98 | 98 | |
| 99 | 99 | /** controller/frontend/basket/require-variant |
| 100 | 100 | * A variant of a selection product must be chosen |
@@ -115,47 +115,47 @@ discard block |
||
| 115 | 115 | * @category Developer |
| 116 | 116 | * @category User |
| 117 | 117 | */ |
| 118 | - $requireVariant = $context->getConfig()->get( 'controller/frontend/basket/require-variant', true ); |
|
| 118 | + $requireVariant = $context->getConfig()->get('controller/frontend/basket/require-variant', true); |
|
| 119 | 119 | |
| 120 | 120 | |
| 121 | - if( count( $productItems ) > 1 ) |
|
| 121 | + if (count($productItems) > 1) |
|
| 122 | 122 | { |
| 123 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'No unique article found for selected attributes and product ID "%1$s"' ); |
|
| 124 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $productItem->getId() ) ); |
|
| 123 | + $msg = $context->getI18n()->dt('controller/frontend', 'No unique article found for selected attributes and product ID "%1$s"'); |
|
| 124 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $productItem->getId())); |
|
| 125 | 125 | } |
| 126 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
| 126 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
| 127 | 127 | { |
| 128 | 128 | $productItem = $result; |
| 129 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
| 129 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
| 130 | 130 | |
| 131 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 131 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 132 | 132 | |
| 133 | - if( !empty( $subprices ) ) { |
|
| 133 | + if (!empty($subprices)) { |
|
| 134 | 134 | $prices = $subprices; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $submedia = $productItem->getRefItems( 'media', 'default', 'default' ); |
|
| 137 | + $submedia = $productItem->getRefItems('media', 'default', 'default'); |
|
| 138 | 138 | |
| 139 | - if( ( $mediaItem = reset( $submedia ) ) !== false ) { |
|
| 140 | - $orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() ); |
|
| 139 | + if (($mediaItem = reset($submedia)) !== false) { |
|
| 140 | + $orderBaseProductItem->setMediaUrl($mediaItem->getPreview()); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $orderProductAttrManager = \Aimeos\MShop::create( $this->getContext(), 'order/base/product/attribute' ); |
|
| 144 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
| 143 | + $orderProductAttrManager = \Aimeos\MShop::create($this->getContext(), 'order/base/product/attribute'); |
|
| 144 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
| 145 | 145 | |
| 146 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
| 146 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
| 147 | 147 | { |
| 148 | 148 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
| 149 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
| 150 | - $orderAttributeItem->setType( 'variant' ); |
|
| 149 | + $orderAttributeItem->copyFrom($attrItem); |
|
| 150 | + $orderAttributeItem->setType('variant'); |
|
| 151 | 151 | |
| 152 | 152 | $attr[] = $orderAttributeItem; |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | - else if( $requireVariant != false ) // count == 0 |
|
| 155 | + else if ($requireVariant != false) // count == 0 |
|
| 156 | 156 | { |
| 157 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'No article found for selected attributes and product ID "%1$s"' ); |
|
| 158 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $productItem->getId() ) ); |
|
| 157 | + $msg = $context->getI18n()->dt('controller/frontend', 'No article found for selected attributes and product ID "%1$s"'); |
|
| 158 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $productItem->getId())); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | return $attr; |
@@ -18,31 +18,31 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $context = \TestHelperFrontend::getContext(); |
| 20 | 20 | |
| 21 | - $this->object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Base::class ) |
|
| 22 | - ->setConstructorArgs( [$context] ) |
|
| 21 | + $this->object = $this->getMockBuilder(\Aimeos\Controller\Frontend\Base::class) |
|
| 22 | + ->setConstructorArgs([$context]) |
|
| 23 | 23 | ->getMockForAbstractClass(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | protected function tearDown() |
| 28 | 28 | { |
| 29 | - unset( $this->object ); |
|
| 29 | + unset($this->object); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | public function testGetContext() |
| 34 | 34 | { |
| 35 | - $result = $this->access( 'getContext' )->invokeArgs( $this->object, [] ); |
|
| 35 | + $result = $this->access('getContext')->invokeArgs($this->object, []); |
|
| 36 | 36 | |
| 37 | - $this->assertInstanceOf( \Aimeos\MShop\Context\Item\Iface::class, $result ); |
|
| 37 | + $this->assertInstanceOf(\Aimeos\MShop\Context\Item\Iface::class, $result); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
| 41 | - protected function access( $name ) |
|
| 41 | + protected function access($name) |
|
| 42 | 42 | { |
| 43 | - $class = new \ReflectionClass( \Aimeos\Controller\Frontend\Base::class ); |
|
| 44 | - $method = $class->getMethod( $name ); |
|
| 45 | - $method->setAccessible( true ); |
|
| 43 | + $class = new \ReflectionClass(\Aimeos\Controller\Frontend\Base::class); |
|
| 44 | + $method = $class->getMethod($name); |
|
| 45 | + $method->setAccessible(true); |
|
| 46 | 46 | |
| 47 | 47 | return $method; |
| 48 | 48 | } |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | * @param string[] $attributes List of attribute codes as keys and strings entered by the customer as value |
| 36 | 36 | * @return string[] List of attributes codes as keys and error messages as values for invalid or missing values |
| 37 | 37 | */ |
| 38 | - public function checkAttributes( $serviceId, array $attributes ) |
|
| 38 | + public function checkAttributes($serviceId, array $attributes) |
|
| 39 | 39 | { |
| 40 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'service' ); |
|
| 40 | + $manager = \Aimeos\MShop::create($this->getContext(), 'service'); |
|
| 41 | 41 | |
| 42 | - $item = $manager->getItem( $serviceId, [], true ); |
|
| 43 | - $provider = $manager->getProvider( $item, $item->getType() ); |
|
| 42 | + $item = $manager->getItem($serviceId, [], true); |
|
| 43 | + $provider = $manager->getProvider($item, $item->getType()); |
|
| 44 | 44 | |
| 45 | - return array_filter( $provider->checkConfigFE( $attributes ) ); |
|
| 45 | + return array_filter($provider->checkConfigFE($attributes)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * @param string[] $ref List of domain names whose items should be fetched too |
| 54 | 54 | * @return \Aimeos\MShop\Service\Provider\Iface Service provider object |
| 55 | 55 | */ |
| 56 | - public function getProvider( $serviceId, $ref = ['media', 'price', 'text'] ) |
|
| 56 | + public function getProvider($serviceId, $ref = ['media', 'price', 'text']) |
|
| 57 | 57 | { |
| 58 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'service' ); |
|
| 59 | - $item = $manager->getItem( $serviceId, $ref, true ); |
|
| 58 | + $manager = \Aimeos\MShop::create($this->getContext(), 'service'); |
|
| 59 | + $item = $manager->getItem($serviceId, $ref, true); |
|
| 60 | 60 | |
| 61 | - return $manager->getProvider( $item, $item->getType() ); |
|
| 61 | + return $manager->getProvider($item, $item->getType()); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -69,25 +69,25 @@ discard block |
||
| 69 | 69 | * @param string[] $ref List of domain names whose items should be fetched too |
| 70 | 70 | * @return \Aimeos\MShop\Service\Provider\Iface[] List of service IDs as keys and service provider objects as values |
| 71 | 71 | */ |
| 72 | - public function getProviders( $type = null, $ref = ['media', 'price', 'text'] ) |
|
| 72 | + public function getProviders($type = null, $ref = ['media', 'price', 'text']) |
|
| 73 | 73 | { |
| 74 | 74 | $list = []; |
| 75 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'service' ); |
|
| 75 | + $manager = \Aimeos\MShop::create($this->getContext(), 'service'); |
|
| 76 | 76 | |
| 77 | - $search = $manager->createSearch( true ); |
|
| 78 | - $search->setSortations( [$search->sort( '+', 'service.position' )] ); |
|
| 77 | + $search = $manager->createSearch(true); |
|
| 78 | + $search->setSortations([$search->sort('+', 'service.position')]); |
|
| 79 | 79 | |
| 80 | - if( $type != null ) |
|
| 80 | + if ($type != null) |
|
| 81 | 81 | { |
| 82 | 82 | $expr = array( |
| 83 | 83 | $search->getConditions(), |
| 84 | - $search->compare( '==', 'service.type', $type ), |
|
| 84 | + $search->compare('==', 'service.type', $type), |
|
| 85 | 85 | ); |
| 86 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 86 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - foreach( $manager->searchItems( $search, $ref ) as $id => $item ) { |
|
| 90 | - $list[$id] = $manager->getProvider( $item, $item->getType() ); |
|
| 89 | + foreach ($manager->searchItems($search, $ref) as $id => $item) { |
|
| 90 | + $list[$id] = $manager->getProvider($item, $item->getType()); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | return $list; |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface|null Form object with URL, parameters, etc. |
| 106 | 106 | * or null if no form data is required |
| 107 | 107 | */ |
| 108 | - public function process( \Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params ) |
|
| 108 | + public function process(\Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params) |
|
| 109 | 109 | { |
| 110 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'service' ); |
|
| 111 | - $item = $manager->getItem( $serviceId, [], true ); |
|
| 110 | + $manager = \Aimeos\MShop::create($this->getContext(), 'service'); |
|
| 111 | + $item = $manager->getItem($serviceId, [], true); |
|
| 112 | 112 | |
| 113 | - $provider = $manager->getProvider( $item, $item->getType() ); |
|
| 114 | - $provider->injectGlobalConfigBE( $urls ); |
|
| 113 | + $provider = $manager->getProvider($item, $item->getType()); |
|
| 114 | + $provider->injectGlobalConfigBE($urls); |
|
| 115 | 115 | |
| 116 | - return $provider->process( $orderItem, $params ); |
|
| 116 | + return $provider->process($orderItem, $params); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | * @param string $code Unique code of the service used for the current order |
| 126 | 126 | * @return \Psr\Http\Message\ResponseInterface Response object |
| 127 | 127 | */ |
| 128 | - public function updatePush( ServerRequestInterface $request, ResponseInterface $response, $code ) |
|
| 128 | + public function updatePush(ServerRequestInterface $request, ResponseInterface $response, $code) |
|
| 129 | 129 | { |
| 130 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'service' ); |
|
| 131 | - $item = $manager->findItem( $code ); |
|
| 130 | + $manager = \Aimeos\MShop::create($this->getContext(), 'service'); |
|
| 131 | + $item = $manager->findItem($code); |
|
| 132 | 132 | |
| 133 | - $provider = $manager->getProvider( $item, $item->getType() ); |
|
| 133 | + $provider = $manager->getProvider($item, $item->getType()); |
|
| 134 | 134 | |
| 135 | - return $provider->updatePush( $request, $response ); |
|
| 135 | + return $provider->updatePush($request, $response); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -144,24 +144,24 @@ discard block |
||
| 144 | 144 | * @param string $orderid ID of the order whose payment status should be updated |
| 145 | 145 | * @return \Aimeos\MShop\Order\Item\Iface $orderItem Order item that has been updated |
| 146 | 146 | */ |
| 147 | - public function updateSync( ServerRequestInterface $request, $code, $orderid ) |
|
| 147 | + public function updateSync(ServerRequestInterface $request, $code, $orderid) |
|
| 148 | 148 | { |
| 149 | 149 | $context = $this->getContext(); |
| 150 | - $orderManager = \Aimeos\MShop::create( $context, 'order' ); |
|
| 151 | - $serviceManager = \Aimeos\MShop::create( $context, 'service' ); |
|
| 150 | + $orderManager = \Aimeos\MShop::create($context, 'order'); |
|
| 151 | + $serviceManager = \Aimeos\MShop::create($context, 'service'); |
|
| 152 | 152 | |
| 153 | - $orderItem = $orderManager->getItem( $orderid ); |
|
| 154 | - $serviceItem = $serviceManager->findItem( $code ); |
|
| 153 | + $orderItem = $orderManager->getItem($orderid); |
|
| 154 | + $serviceItem = $serviceManager->findItem($code); |
|
| 155 | 155 | |
| 156 | - $provider = $serviceManager->getProvider( $serviceItem, $serviceItem->getType() ); |
|
| 156 | + $provider = $serviceManager->getProvider($serviceItem, $serviceItem->getType()); |
|
| 157 | 157 | |
| 158 | 158 | |
| 159 | - if( ( $orderItem = $provider->updateSync( $request, $orderItem ) ) !== null ) |
|
| 159 | + if (($orderItem = $provider->updateSync($request, $orderItem)) !== null) |
|
| 160 | 160 | { |
| 161 | - if( $orderItem->getPaymentStatus() === \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED |
|
| 162 | - && $provider->isImplemented( \Aimeos\MShop\Service\Provider\Payment\Base::FEAT_QUERY ) |
|
| 161 | + if ($orderItem->getPaymentStatus() === \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED |
|
| 162 | + && $provider->isImplemented(\Aimeos\MShop\Service\Provider\Payment\Base::FEAT_QUERY) |
|
| 163 | 163 | ) { |
| 164 | - $provider->query( $orderItem ); |
|
| 164 | + $provider->query($orderItem); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -31,15 +31,15 @@ discard block |
||
| 31 | 31 | public function createFilter() |
| 32 | 32 | { |
| 33 | 33 | $context = $this->getContext(); |
| 34 | - $filter = \Aimeos\MShop::create( $context, 'locale' )->createSearch( true ); |
|
| 34 | + $filter = \Aimeos\MShop::create($context, 'locale')->createSearch(true); |
|
| 35 | 35 | |
| 36 | 36 | $expr = array( |
| 37 | - $filter->compare( '==', 'locale.siteid', $context->getLocale()->getSitePath() ), |
|
| 37 | + $filter->compare('==', 'locale.siteid', $context->getLocale()->getSitePath()), |
|
| 38 | 38 | $filter->getConditions(), |
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 42 | - $filter->setSortations( array( $filter->sort( '+', 'locale.position' ) ) ); |
|
| 41 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 42 | + $filter->setSortations(array($filter->sort('+', 'locale.position'))); |
|
| 43 | 43 | |
| 44 | 44 | return $filter; |
| 45 | 45 | } |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items |
| 54 | 54 | * @since 2017.03 |
| 55 | 55 | */ |
| 56 | - public function getItem( $id, array $domains = [] ) |
|
| 56 | + public function getItem($id, array $domains = []) |
|
| 57 | 57 | { |
| 58 | - return \Aimeos\MShop::create( $this->getContext(), 'locale' )->getItem( $id, $domains, true ); |
|
| 58 | + return \Aimeos\MShop::create($this->getContext(), 'locale')->getItem($id, $domains, true); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
| 69 | 69 | * @since 2017.03 |
| 70 | 70 | */ |
| 71 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null ) |
|
| 71 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null) |
|
| 72 | 72 | { |
| 73 | - return \Aimeos\MShop::create( $this->getContext(), 'locale' )->searchItems( $filter, $domains, $total ); |
|
| 73 | + return \Aimeos\MShop::create($this->getContext(), 'locale')->searchItems($filter, $domains, $total); |
|
| 74 | 74 | } |
| 75 | 75 | } |
@@ -36,27 +36,27 @@ |
||
| 36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 38 | 38 | */ |
| 39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
| 39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
| 41 | 41 | { |
| 42 | 42 | $context = $this->getContext(); |
| 43 | - $catalogListManager = \Aimeos\MShop::create( $context, 'catalog/lists' ); |
|
| 43 | + $catalogListManager = \Aimeos\MShop::create($context, 'catalog/lists'); |
|
| 44 | 44 | |
| 45 | - $search = $catalogListManager->createSearch( true ); |
|
| 45 | + $search = $catalogListManager->createSearch(true); |
|
| 46 | 46 | $expr = array( |
| 47 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
| 48 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
| 47 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
| 48 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
| 49 | 49 | $search->getConditions() |
| 50 | 50 | ); |
| 51 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 52 | - $search->setSlice( 0, 1 ); |
|
| 51 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 52 | + $search->setSlice(0, 1); |
|
| 53 | 53 | |
| 54 | - $result = $catalogListManager->searchItems( $search ); |
|
| 54 | + $result = $catalogListManager->searchItems($search); |
|
| 55 | 55 | |
| 56 | - if( reset( $result ) === false ) |
|
| 56 | + if (reset($result) === false) |
|
| 57 | 57 | { |
| 58 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Adding product with ID "%1$s" is not allowed' ); |
|
| 59 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $prodid ) ); |
|
| 58 | + $msg = $context->getI18n()->dt('controller/frontend', 'Adding product with ID "%1$s" is not allowed'); |
|
| 59 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $prodid)); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $this->getController()->addProduct( |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 38 | 38 | */ |
| 39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
| 39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
| 41 | 41 | { |
| 42 | 42 | $context = $this->getContext(); |
| 43 | - $productManager = \Aimeos\MShop::create( $context, 'product' ); |
|
| 43 | + $productManager = \Aimeos\MShop::create($context, 'product'); |
|
| 44 | 44 | |
| 45 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'bundle' ) |
|
| 45 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'bundle') |
|
| 46 | 46 | { |
| 47 | 47 | return $this->getController()->addProduct( |
| 48 | 48 | $prodid, $quantity, $stocktype, $variantAttributeIds, |
@@ -51,29 +51,29 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $attributeMap = [ |
| 54 | - 'custom' => array_keys( $customAttributeValues ), |
|
| 55 | - 'config' => array_keys( $configAttributeIds ), |
|
| 54 | + 'custom' => array_keys($customAttributeValues), |
|
| 55 | + 'config' => array_keys($configAttributeIds), |
|
| 56 | 56 | ]; |
| 57 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
| 57 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - $productItem = $productManager->getItem( $prodid, ['attribute', 'media', 'supplier', 'price', 'product', 'text'], true ); |
|
| 61 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 62 | - $hidden = $productItem->getRefItems( 'attribute', null, 'hidden' ); |
|
| 60 | + $productItem = $productManager->getItem($prodid, ['attribute', 'media', 'supplier', 'price', 'product', 'text'], true); |
|
| 61 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 62 | + $hidden = $productItem->getRefItems('attribute', null, 'hidden'); |
|
| 63 | 63 | |
| 64 | - $orderBaseProductItem = \Aimeos\MShop::create( $context, 'order/base/product' )->createItem(); |
|
| 65 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
| 64 | + $orderBaseProductItem = \Aimeos\MShop::create($context, 'order/base/product')->createItem(); |
|
| 65 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
| 66 | 66 | |
| 67 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
| 67 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
| 68 | 68 | |
| 69 | - $custAttr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
| 70 | - $confAttr = $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ); |
|
| 71 | - $attr = array_merge( $custAttr, $confAttr, $this->getOrderProductAttributes( 'hidden', array_keys( $hidden ) ) ); |
|
| 69 | + $custAttr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
| 70 | + $confAttr = $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds); |
|
| 71 | + $attr = array_merge($custAttr, $confAttr, $this->getOrderProductAttributes('hidden', array_keys($hidden))); |
|
| 72 | 72 | |
| 73 | - $orderBaseProductItem->setAttributeItems( $attr ); |
|
| 74 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
| 73 | + $orderBaseProductItem->setAttributeItems($attr); |
|
| 74 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
| 75 | 75 | |
| 76 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
| 76 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
| 77 | 77 | $this->getController()->save(); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -86,43 +86,43 @@ discard block |
||
| 86 | 86 | * @param array $variantAttributeIds List of product variant attribute IDs |
| 87 | 87 | * @param string $stocktype |
| 88 | 88 | */ |
| 89 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 90 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
| 89 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 90 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
| 91 | 91 | { |
| 92 | 92 | $quantity = $orderBaseProductItem->getQuantity(); |
| 93 | 93 | $products = $subProductIds = $orderProducts = []; |
| 94 | - $orderProductManager = \Aimeos\MShop::create( $this->getContext(), 'order/base/product' ); |
|
| 94 | + $orderProductManager = \Aimeos\MShop::create($this->getContext(), 'order/base/product'); |
|
| 95 | 95 | |
| 96 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
| 96 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
| 97 | 97 | $subProductIds[] = $item->getId(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if( count( $subProductIds ) > 0 ) |
|
| 100 | + if (count($subProductIds) > 0) |
|
| 101 | 101 | { |
| 102 | - $productManager = \Aimeos\MShop::create( $this->getContext(), 'product' ); |
|
| 102 | + $productManager = \Aimeos\MShop::create($this->getContext(), 'product'); |
|
| 103 | 103 | |
| 104 | - $search = $productManager->createSearch( true ); |
|
| 104 | + $search = $productManager->createSearch(true); |
|
| 105 | 105 | $expr = array( |
| 106 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 106 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 107 | 107 | $search->getConditions(), |
| 108 | 108 | ); |
| 109 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 109 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 110 | 110 | |
| 111 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
| 111 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - foreach( $products as $product ) |
|
| 114 | + foreach ($products as $product) |
|
| 115 | 115 | { |
| 116 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
| 116 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
| 117 | 117 | |
| 118 | 118 | $orderProduct = $orderProductManager->createItem(); |
| 119 | - $orderProduct->copyFrom( $product ); |
|
| 120 | - $orderProduct->setStockType( $stocktype ); |
|
| 121 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
| 119 | + $orderProduct->copyFrom($product); |
|
| 120 | + $orderProduct->setStockType($stocktype); |
|
| 121 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
| 122 | 122 | |
| 123 | 123 | $orderProducts[] = $orderProduct; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
| 126 | + $orderBaseProductItem->setProducts($orderProducts); |
|
| 127 | 127 | } |
| 128 | 128 | } |
@@ -20,130 +20,130 @@ |
||
| 20 | 20 | { |
| 21 | 21 | $this->context = \TestHelperFrontend::getContext(); |
| 22 | 22 | |
| 23 | - $this->stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Service\Standard::class ) |
|
| 23 | + $this->stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Service\Standard::class) |
|
| 24 | 24 | ->disableOriginalConstructor() |
| 25 | 25 | ->getMock(); |
| 26 | 26 | |
| 27 | - $this->object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Service\Decorator\Base::class ) |
|
| 28 | - ->setConstructorArgs( [$this->stub, $this->context] ) |
|
| 27 | + $this->object = $this->getMockBuilder(\Aimeos\Controller\Frontend\Service\Decorator\Base::class) |
|
| 28 | + ->setConstructorArgs([$this->stub, $this->context]) |
|
| 29 | 29 | ->getMockForAbstractClass(); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | protected function tearDown() |
| 34 | 34 | { |
| 35 | - unset( $this->context, $this->object, $this->stub ); |
|
| 35 | + unset($this->context, $this->object, $this->stub); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | public function testConstructException() |
| 40 | 40 | { |
| 41 | - $stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Iface::class )->getMock(); |
|
| 41 | + $stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Iface::class)->getMock(); |
|
| 42 | 42 | |
| 43 | - $this->setExpectedException( \Aimeos\MW\Common\Exception::class ); |
|
| 43 | + $this->setExpectedException(\Aimeos\MW\Common\Exception::class); |
|
| 44 | 44 | |
| 45 | - $this->getMockBuilder( \Aimeos\Controller\Frontend\Service\Decorator\Base::class ) |
|
| 46 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
| 45 | + $this->getMockBuilder(\Aimeos\Controller\Frontend\Service\Decorator\Base::class) |
|
| 46 | + ->setConstructorArgs([$stub, $this->context]) |
|
| 47 | 47 | ->getMockForAbstractClass(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | public function testCall() |
| 52 | 52 | { |
| 53 | - $stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Service\Standard::class ) |
|
| 53 | + $stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Service\Standard::class) |
|
| 54 | 54 | ->disableOriginalConstructor() |
| 55 | - ->setMethods( ['invalid'] ) |
|
| 55 | + ->setMethods(['invalid']) |
|
| 56 | 56 | ->getMock(); |
| 57 | 57 | |
| 58 | - $object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Service\Decorator\Base::class ) |
|
| 59 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
| 58 | + $object = $this->getMockBuilder(\Aimeos\Controller\Frontend\Service\Decorator\Base::class) |
|
| 59 | + ->setConstructorArgs([$stub, $this->context]) |
|
| 60 | 60 | ->getMockForAbstractClass(); |
| 61 | 61 | |
| 62 | - $stub->expects( $this->once() )->method( 'invalid' )->will( $this->returnValue( true ) ); |
|
| 62 | + $stub->expects($this->once())->method('invalid')->will($this->returnValue(true)); |
|
| 63 | 63 | |
| 64 | - $this->assertTrue( $object->invalid() ); |
|
| 64 | + $this->assertTrue($object->invalid()); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | public function testCheckAttributes() |
| 69 | 69 | { |
| 70 | - $this->stub->expects( $this->once() )->method( 'checkAttributes' ) |
|
| 71 | - ->will( $this->returnValue( [] ) ); |
|
| 70 | + $this->stub->expects($this->once())->method('checkAttributes') |
|
| 71 | + ->will($this->returnValue([])); |
|
| 72 | 72 | |
| 73 | - $this->assertEquals( [], $this->object->checkAttributes( -1, [] ) ); |
|
| 73 | + $this->assertEquals([], $this->object->checkAttributes( -1, [] )); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | public function testGetProvider() |
| 78 | 78 | { |
| 79 | - $manager = \Aimeos\MShop::create( $this->context, 'service' ); |
|
| 80 | - $provider = $manager->getProvider( $manager->findItem( 'unitcode', [], 'service', 'delivery' ), 'delivery' ); |
|
| 79 | + $manager = \Aimeos\MShop::create($this->context, 'service'); |
|
| 80 | + $provider = $manager->getProvider($manager->findItem('unitcode', [], 'service', 'delivery'), 'delivery'); |
|
| 81 | 81 | |
| 82 | - $this->stub->expects( $this->once() )->method( 'getProvider' ) |
|
| 83 | - ->will( $this->returnValue( $provider ) ); |
|
| 82 | + $this->stub->expects($this->once())->method('getProvider') |
|
| 83 | + ->will($this->returnValue($provider)); |
|
| 84 | 84 | |
| 85 | - $this->assertSame( $provider, $this->object->getProvider( -1 ) ); |
|
| 85 | + $this->assertSame($provider, $this->object->getProvider( -1 )); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | public function testGetProviders() |
| 90 | 90 | { |
| 91 | - $this->stub->expects( $this->once() )->method( 'getProviders' ) |
|
| 92 | - ->will( $this->returnValue( [] ) ); |
|
| 91 | + $this->stub->expects($this->once())->method('getProviders') |
|
| 92 | + ->will($this->returnValue([])); |
|
| 93 | 93 | |
| 94 | - $this->assertEquals( [], $this->object->getProviders( 'payment' ) ); |
|
| 94 | + $this->assertEquals([], $this->object->getProviders('payment')); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | public function testProcess() |
| 99 | 99 | { |
| 100 | - $item = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
|
| 100 | + $item = \Aimeos\MShop::create($this->context, 'order')->createItem(); |
|
| 101 | 101 | |
| 102 | - $this->stub->expects( $this->once() )->method( 'process' ) |
|
| 103 | - ->will( $this->returnValue( new \Aimeos\MShop\Common\Item\Helper\Form\Standard() ) ); |
|
| 102 | + $this->stub->expects($this->once())->method('process') |
|
| 103 | + ->will($this->returnValue(new \Aimeos\MShop\Common\Item\Helper\Form\Standard())); |
|
| 104 | 104 | |
| 105 | - $this->assertInstanceOf( 'Aimeos\MShop\Common\Item\Helper\Form\Iface', $this->object->process( $item, -1, [], [] ) ); |
|
| 105 | + $this->assertInstanceOf('Aimeos\MShop\Common\Item\Helper\Form\Iface', $this->object->process($item, -1, [], [])); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | public function testUpdatePush() |
| 110 | 110 | { |
| 111 | - $response = $this->getMockBuilder( \Psr\Http\Message\ResponseInterface::class )->getMock(); |
|
| 112 | - $request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock(); |
|
| 111 | + $response = $this->getMockBuilder(\Psr\Http\Message\ResponseInterface::class)->getMock(); |
|
| 112 | + $request = $this->getMockBuilder(\Psr\Http\Message\ServerRequestInterface::class)->getMock(); |
|
| 113 | 113 | |
| 114 | - $this->stub->expects( $this->once() )->method( 'updatePush' ) |
|
| 115 | - ->will( $this->returnValue( $response ) ); |
|
| 114 | + $this->stub->expects($this->once())->method('updatePush') |
|
| 115 | + ->will($this->returnValue($response)); |
|
| 116 | 116 | |
| 117 | - $this->assertInstanceOf( \Psr\Http\Message\ResponseInterface::class, $this->object->updatePush( $request, $response, 'test' ) ); |
|
| 117 | + $this->assertInstanceOf(\Psr\Http\Message\ResponseInterface::class, $this->object->updatePush($request, $response, 'test')); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | public function testUpdateSync() |
| 122 | 122 | { |
| 123 | - $response = $this->getMockBuilder( \Psr\Http\Message\ResponseInterface::class )->getMock(); |
|
| 124 | - $request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock(); |
|
| 125 | - $item = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
|
| 123 | + $response = $this->getMockBuilder(\Psr\Http\Message\ResponseInterface::class)->getMock(); |
|
| 124 | + $request = $this->getMockBuilder(\Psr\Http\Message\ServerRequestInterface::class)->getMock(); |
|
| 125 | + $item = \Aimeos\MShop::create($this->context, 'order')->createItem(); |
|
| 126 | 126 | |
| 127 | - $this->stub->expects( $this->once() )->method( 'updateSync' ) |
|
| 128 | - ->will( $this->returnValue( $item ) ); |
|
| 127 | + $this->stub->expects($this->once())->method('updateSync') |
|
| 128 | + ->will($this->returnValue($item)); |
|
| 129 | 129 | |
| 130 | - $this->assertInstanceOf( 'Aimeos\MShop\Order\Item\Iface', $this->object->updateSync( $request, $response, [], 'test', -1 ) ); |
|
| 130 | + $this->assertInstanceOf('Aimeos\MShop\Order\Item\Iface', $this->object->updateSync($request, $response, [], 'test', -1)); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | public function testGetController() |
| 135 | 135 | { |
| 136 | - $result = $this->access( 'getController' )->invokeArgs( $this->object, [] ); |
|
| 136 | + $result = $this->access('getController')->invokeArgs($this->object, []); |
|
| 137 | 137 | |
| 138 | - $this->assertSame( $this->stub, $result ); |
|
| 138 | + $this->assertSame($this->stub, $result); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
| 142 | - protected function access( $name ) |
|
| 142 | + protected function access($name) |
|
| 143 | 143 | { |
| 144 | - $class = new \ReflectionClass( \Aimeos\Controller\Frontend\Service\Decorator\Base::class ); |
|
| 145 | - $method = $class->getMethod( $name ); |
|
| 146 | - $method->setAccessible( true ); |
|
| 144 | + $class = new \ReflectionClass(\Aimeos\Controller\Frontend\Service\Decorator\Base::class); |
|
| 145 | + $method = $class->getMethod($name); |
|
| 146 | + $method->setAccessible(true); |
|
| 147 | 147 | |
| 148 | 148 | return $method; |
| 149 | 149 | } |
@@ -20,134 +20,134 @@ |
||
| 20 | 20 | { |
| 21 | 21 | $this->context = \TestHelperFrontend::getContext(); |
| 22 | 22 | |
| 23 | - $this->stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Order\Standard::class ) |
|
| 23 | + $this->stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Order\Standard::class) |
|
| 24 | 24 | ->disableOriginalConstructor() |
| 25 | 25 | ->getMock(); |
| 26 | 26 | |
| 27 | - $this->object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Order\Decorator\Base::class ) |
|
| 28 | - ->setConstructorArgs( [$this->stub, $this->context] ) |
|
| 27 | + $this->object = $this->getMockBuilder(\Aimeos\Controller\Frontend\Order\Decorator\Base::class) |
|
| 28 | + ->setConstructorArgs([$this->stub, $this->context]) |
|
| 29 | 29 | ->getMockForAbstractClass(); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | protected function tearDown() |
| 34 | 34 | { |
| 35 | - unset( $this->context, $this->object, $this->stub ); |
|
| 35 | + unset($this->context, $this->object, $this->stub); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | public function testConstructException() |
| 40 | 40 | { |
| 41 | - $stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Iface::class )->getMock(); |
|
| 41 | + $stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Iface::class)->getMock(); |
|
| 42 | 42 | |
| 43 | - $this->setExpectedException( \Aimeos\MW\Common\Exception::class ); |
|
| 43 | + $this->setExpectedException(\Aimeos\MW\Common\Exception::class); |
|
| 44 | 44 | |
| 45 | - $this->getMockBuilder( \Aimeos\Controller\Frontend\Order\Decorator\Base::class ) |
|
| 46 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
| 45 | + $this->getMockBuilder(\Aimeos\Controller\Frontend\Order\Decorator\Base::class) |
|
| 46 | + ->setConstructorArgs([$stub, $this->context]) |
|
| 47 | 47 | ->getMockForAbstractClass(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | public function testCall() |
| 52 | 52 | { |
| 53 | - $stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Order\Standard::class ) |
|
| 53 | + $stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Order\Standard::class) |
|
| 54 | 54 | ->disableOriginalConstructor() |
| 55 | - ->setMethods( ['invalid'] ) |
|
| 55 | + ->setMethods(['invalid']) |
|
| 56 | 56 | ->getMock(); |
| 57 | 57 | |
| 58 | - $object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Order\Decorator\Base::class ) |
|
| 59 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
| 58 | + $object = $this->getMockBuilder(\Aimeos\Controller\Frontend\Order\Decorator\Base::class) |
|
| 59 | + ->setConstructorArgs([$stub, $this->context]) |
|
| 60 | 60 | ->getMockForAbstractClass(); |
| 61 | 61 | |
| 62 | - $stub->expects( $this->once() )->method( 'invalid' )->will( $this->returnValue( true ) ); |
|
| 62 | + $stub->expects($this->once())->method('invalid')->will($this->returnValue(true)); |
|
| 63 | 63 | |
| 64 | - $this->assertTrue( $object->invalid() ); |
|
| 64 | + $this->assertTrue($object->invalid()); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | public function testAddItem() |
| 69 | 69 | { |
| 70 | - $item = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
|
| 70 | + $item = \Aimeos\MShop::create($this->context, 'order')->createItem(); |
|
| 71 | 71 | |
| 72 | - $this->stub->expects( $this->once() )->method( 'addItem' )->will( $this->returnValue( $item ) ); |
|
| 72 | + $this->stub->expects($this->once())->method('addItem')->will($this->returnValue($item)); |
|
| 73 | 73 | |
| 74 | - $this->assertInstanceOf( \Aimeos\MShop\Order\Item\Iface::class, $this->object->addItem( -1, '' ) ); |
|
| 74 | + $this->assertInstanceOf(\Aimeos\MShop\Order\Item\Iface::class, $this->object->addItem( -1, '' )); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | public function testCreateFilter() |
| 79 | 79 | { |
| 80 | - $search = \Aimeos\MShop::create( $this->context, 'order' )->createSearch(); |
|
| 80 | + $search = \Aimeos\MShop::create($this->context, 'order')->createSearch(); |
|
| 81 | 81 | |
| 82 | - $this->stub->expects( $this->once() )->method( 'createFilter' )->will( $this->returnValue( $search ) ); |
|
| 82 | + $this->stub->expects($this->once())->method('createFilter')->will($this->returnValue($search)); |
|
| 83 | 83 | |
| 84 | - $this->assertInstanceOf( \Aimeos\MW\Criteria\Iface::class, $this->object->createFilter() ); |
|
| 84 | + $this->assertInstanceOf(\Aimeos\MW\Criteria\Iface::class, $this->object->createFilter()); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | public function testGetItem() |
| 89 | 89 | { |
| 90 | - $item = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
|
| 90 | + $item = \Aimeos\MShop::create($this->context, 'order')->createItem(); |
|
| 91 | 91 | |
| 92 | - $this->stub->expects( $this->once() )->method( 'getItem' )->will( $this->returnValue( $item ) ); |
|
| 92 | + $this->stub->expects($this->once())->method('getItem')->will($this->returnValue($item)); |
|
| 93 | 93 | |
| 94 | - $this->assertInstanceOf( \Aimeos\MShop\Order\Item\Iface::class, $this->object->getItem( -1 ) ); |
|
| 94 | + $this->assertInstanceOf(\Aimeos\MShop\Order\Item\Iface::class, $this->object->getItem( -1 )); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | public function testSaveItem() |
| 99 | 99 | { |
| 100 | - $item = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
|
| 100 | + $item = \Aimeos\MShop::create($this->context, 'order')->createItem(); |
|
| 101 | 101 | |
| 102 | - $this->stub->expects( $this->once() )->method( 'saveItem' ); |
|
| 102 | + $this->stub->expects($this->once())->method('saveItem'); |
|
| 103 | 103 | |
| 104 | - $this->object->saveItem( $item ); |
|
| 104 | + $this->object->saveItem($item); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | public function testSearchItems() |
| 109 | 109 | { |
| 110 | - $search = $this->getMockBuilder( \Aimeos\MW\Criteria\Iface::class )->getMock(); |
|
| 110 | + $search = $this->getMockBuilder(\Aimeos\MW\Criteria\Iface::class)->getMock(); |
|
| 111 | 111 | |
| 112 | - $this->stub->expects( $this->once() )->method( 'searchItems' )->will( $this->returnValue( [] ) ); |
|
| 112 | + $this->stub->expects($this->once())->method('searchItems')->will($this->returnValue([])); |
|
| 113 | 113 | |
| 114 | - $this->assertEquals( [], $this->object->searchItems( $search ) ); |
|
| 114 | + $this->assertEquals([], $this->object->searchItems($search)); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
| 118 | 118 | public function testUnblock() |
| 119 | 119 | { |
| 120 | - $orderItem = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
|
| 120 | + $orderItem = \Aimeos\MShop::create($this->context, 'order')->createItem(); |
|
| 121 | 121 | |
| 122 | - $this->stub->expects( $this->once() )->method( 'unblock' ); |
|
| 122 | + $this->stub->expects($this->once())->method('unblock'); |
|
| 123 | 123 | |
| 124 | - $this->object->unblock( $orderItem ); |
|
| 124 | + $this->object->unblock($orderItem); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 | public function testUpdate() |
| 129 | 129 | { |
| 130 | - $orderItem = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
|
| 130 | + $orderItem = \Aimeos\MShop::create($this->context, 'order')->createItem(); |
|
| 131 | 131 | |
| 132 | - $this->stub->expects( $this->once() )->method( 'update' ); |
|
| 132 | + $this->stub->expects($this->once())->method('update'); |
|
| 133 | 133 | |
| 134 | - $this->object->update( $orderItem ); |
|
| 134 | + $this->object->update($orderItem); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | public function testGetController() |
| 139 | 139 | { |
| 140 | - $result = $this->access( 'getController' )->invokeArgs( $this->object, [] ); |
|
| 140 | + $result = $this->access('getController')->invokeArgs($this->object, []); |
|
| 141 | 141 | |
| 142 | - $this->assertSame( $this->stub, $result ); |
|
| 142 | + $this->assertSame($this->stub, $result); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | - protected function access( $name ) |
|
| 146 | + protected function access($name) |
|
| 147 | 147 | { |
| 148 | - $class = new \ReflectionClass( \Aimeos\Controller\Frontend\Order\Decorator\Base::class ); |
|
| 149 | - $method = $class->getMethod( $name ); |
|
| 150 | - $method->setAccessible( true ); |
|
| 148 | + $class = new \ReflectionClass(\Aimeos\Controller\Frontend\Order\Decorator\Base::class); |
|
| 149 | + $method = $class->getMethod($name); |
|
| 150 | + $method->setAccessible(true); |
|
| 151 | 151 | |
| 152 | 152 | return $method; |
| 153 | 153 | } |