@@ -31,36 +31,36 @@ discard block |
||
| 31 | 31 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 32 | 32 | * @since 2017.03 |
| 33 | 33 | */ |
| 34 | - public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds ) |
|
| 34 | + public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds) |
|
| 35 | 35 | { |
| 36 | - if( ( $attrIds = $this->validateIds( $attrIds ) ) !== [] ) |
|
| 36 | + if (($attrIds = $this->validateIds($attrIds)) !== []) |
|
| 37 | 37 | { |
| 38 | - $func = $filter->createFunction( 'index.attribute:all', [$attrIds] ); |
|
| 38 | + $func = $filter->createFunction('index.attribute:all', [$attrIds]); |
|
| 39 | 39 | $expr = array( |
| 40 | - $filter->compare( '!=', $func, null ), |
|
| 40 | + $filter->compare('!=', $func, null), |
|
| 41 | 41 | $filter->getConditions(), |
| 42 | 42 | ); |
| 43 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 43 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if( ( $optIds = $this->validateIds( $optIds ) ) !== [] ) |
|
| 46 | + if (($optIds = $this->validateIds($optIds)) !== []) |
|
| 47 | 47 | { |
| 48 | 48 | $expr = array( |
| 49 | - $filter->compare( '==', 'index.attribute.id', $optIds ), |
|
| 49 | + $filter->compare('==', 'index.attribute.id', $optIds), |
|
| 50 | 50 | $filter->getConditions(), |
| 51 | 51 | ); |
| 52 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 52 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - foreach( $oneIds as $type => $list ) |
|
| 55 | + foreach ($oneIds as $type => $list) |
|
| 56 | 56 | { |
| 57 | - if( ( $list = $this->validateIds( (array) $list ) ) !== [] ) |
|
| 57 | + if (($list = $this->validateIds((array) $list)) !== []) |
|
| 58 | 58 | { |
| 59 | 59 | $expr = array( |
| 60 | - $filter->compare( '==', 'index.attribute.id', $list ), |
|
| 60 | + $filter->compare('==', 'index.attribute.id', $list), |
|
| 61 | 61 | $filter->getConditions(), |
| 62 | 62 | ); |
| 63 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 63 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -78,42 +78,42 @@ discard block |
||
| 78 | 78 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 79 | 79 | * @since 2017.03 |
| 80 | 80 | */ |
| 81 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catIds, $listtype = 'default', |
|
| 82 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
| 81 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catIds, $listtype = 'default', |
|
| 82 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
| 83 | 83 | { |
| 84 | - if( ( $catIds = $this->validateIds( (array) $catIds ) ) === [] ) { |
|
| 84 | + if (($catIds = $this->validateIds((array) $catIds)) === []) { |
|
| 85 | 85 | return $filter; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
| 88 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
| 89 | 89 | { |
| 90 | 90 | $list = []; |
| 91 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
| 91 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
| 92 | 92 | |
| 93 | - foreach( $catIds as $catId ) |
|
| 93 | + foreach ($catIds as $catId) |
|
| 94 | 94 | { |
| 95 | - $tree = $cntl->getTree( $catId, [], $level ); |
|
| 96 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
| 95 | + $tree = $cntl->getTree($catId, [], $level); |
|
| 96 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $catIds = $list; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $expr = [$filter->getConditions()]; |
| 103 | - $expr[] = $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ); |
|
| 103 | + $expr[] = $filter->compare('==', 'index.catalog.id', array_unique($catIds)); |
|
| 104 | 104 | |
| 105 | - if( isset( $filter->sortname ) && $filter->sortname === 'relevance' ) |
|
| 105 | + if (isset($filter->sortname) && $filter->sortname === 'relevance') |
|
| 106 | 106 | { |
| 107 | - $dir = ( isset( $filter->sortdir ) ? $filter->sortdir : '+' ); |
|
| 107 | + $dir = (isset($filter->sortdir) ? $filter->sortdir : '+'); |
|
| 108 | 108 | |
| 109 | - $cmpfunc = $filter->createFunction( 'index.catalog:position', [$listtype, $catIds] ); |
|
| 110 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
| 109 | + $cmpfunc = $filter->createFunction('index.catalog:position', [$listtype, $catIds]); |
|
| 110 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
| 111 | 111 | |
| 112 | - $sortfunc = $filter->createFunction( 'sort:index.catalog:position', [$listtype, $catIds] ); |
|
| 113 | - $filter->setSortations( [$filter->sort( $dir, $sortfunc ), $filter->sort( '+', 'product.id' )] ); |
|
| 112 | + $sortfunc = $filter->createFunction('sort:index.catalog:position', [$listtype, $catIds]); |
|
| 113 | + $filter->setSortations([$filter->sort($dir, $sortfunc), $filter->sort('+', 'product.id')]); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 116 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 117 | 117 | |
| 118 | 118 | return $filter; |
| 119 | 119 | } |
@@ -128,27 +128,27 @@ discard block |
||
| 128 | 128 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 129 | 129 | * @since 2018.07 |
| 130 | 130 | */ |
| 131 | - public function addFilterSupplier( \Aimeos\MW\Criteria\Iface $filter, $supIds, $listtype = 'default' ) |
|
| 131 | + public function addFilterSupplier(\Aimeos\MW\Criteria\Iface $filter, $supIds, $listtype = 'default') |
|
| 132 | 132 | { |
| 133 | - if( ( $supIds = $this->validateIds( (array) $supIds ) ) === [] ) { |
|
| 133 | + if (($supIds = $this->validateIds((array) $supIds)) === []) { |
|
| 134 | 134 | return $filter; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $expr = [$filter->getConditions()]; |
| 138 | - $expr[] = $filter->compare( '==', 'index.supplier.id', array_unique( $supIds ) ); |
|
| 138 | + $expr[] = $filter->compare('==', 'index.supplier.id', array_unique($supIds)); |
|
| 139 | 139 | |
| 140 | - if( isset( $filter->sortname ) && $filter->sortname === 'relevance' ) |
|
| 140 | + if (isset($filter->sortname) && $filter->sortname === 'relevance') |
|
| 141 | 141 | { |
| 142 | - $dir = ( isset( $filter->sortdir ) ? $filter->sortdir : '+' ); |
|
| 142 | + $dir = (isset($filter->sortdir) ? $filter->sortdir : '+'); |
|
| 143 | 143 | |
| 144 | - $cmpfunc = $filter->createFunction( 'index.supplier:position', [$listtype, $supIds] ); |
|
| 145 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
| 144 | + $cmpfunc = $filter->createFunction('index.supplier:position', [$listtype, $supIds]); |
|
| 145 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
| 146 | 146 | |
| 147 | - $sortfunc = $filter->createFunction( 'sort:index.supplier:position', [$listtype, $supIds] ); |
|
| 148 | - $filter->setSortations( [$filter->sort( $dir, $sortfunc ), $filter->sort( '+', 'product.id' )] ); |
|
| 147 | + $sortfunc = $filter->createFunction('sort:index.supplier:position', [$listtype, $supIds]); |
|
| 148 | + $filter->setSortations([$filter->sort($dir, $sortfunc), $filter->sort('+', 'product.id')]); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 151 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 161 | 161 | * @since 2017.03 |
| 162 | 162 | */ |
| 163 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input ) |
|
| 163 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input) |
|
| 164 | 164 | { |
| 165 | 165 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
| 166 | - $cmpfunc = $filter->createFunction( 'index.text:relevance', [$langid, $input] ); |
|
| 167 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
| 166 | + $cmpfunc = $filter->createFunction('index.text:relevance', [$langid, $input]); |
|
| 167 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
| 168 | 168 | |
| 169 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 169 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | * @return array Associative list of key values as key and the product count for this key as value |
| 179 | 179 | * @since 2017.03 |
| 180 | 180 | */ |
| 181 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
| 181 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
| 182 | 182 | { |
| 183 | - return \Aimeos\MShop::create( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
| 183 | + return \Aimeos\MShop::create($this->getContext(), 'index')->aggregate($filter, $key); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 195 | 195 | * @since 2017.03 |
| 196 | 196 | */ |
| 197 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100 ) |
|
| 197 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100) |
|
| 198 | 198 | { |
| 199 | 199 | $sortations = []; |
| 200 | 200 | $context = $this->getContext(); |
| 201 | - $manager = \Aimeos\MShop::create( $context, 'index' ); |
|
| 201 | + $manager = \Aimeos\MShop::create($context, 'index'); |
|
| 202 | 202 | |
| 203 | 203 | |
| 204 | 204 | /** controller/frontend/product/ignore-dates |
@@ -213,55 +213,55 @@ discard block |
||
| 213 | 213 | * @since 2017.10 |
| 214 | 214 | * @category Developer |
| 215 | 215 | */ |
| 216 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
| 216 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
| 217 | 217 | { |
| 218 | 218 | $search = $manager->createSearch(); |
| 219 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
| 219 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
| 220 | 220 | } |
| 221 | 221 | else |
| 222 | 222 | { |
| 223 | - $search = $manager->createSearch( true ); |
|
| 223 | + $search = $manager->createSearch(true); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
| 227 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
| 227 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
| 228 | 228 | |
| 229 | - switch( $sort ) |
|
| 229 | + switch ($sort) |
|
| 230 | 230 | { |
| 231 | 231 | case 'code': |
| 232 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
| 232 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
| 233 | 233 | break; |
| 234 | 234 | |
| 235 | 235 | case 'ctime': |
| 236 | - $sortations[] = $search->sort( $direction, 'product.ctime' ); |
|
| 236 | + $sortations[] = $search->sort($direction, 'product.ctime'); |
|
| 237 | 237 | break; |
| 238 | 238 | |
| 239 | 239 | case 'name': |
| 240 | 240 | $langid = $context->getLocale()->getLanguageId(); |
| 241 | 241 | |
| 242 | - $cmpfunc = $search->createFunction( 'index.text:name', [$langid] ); |
|
| 243 | - $expr[] = $search->compare( '!=', $cmpfunc, null ); |
|
| 242 | + $cmpfunc = $search->createFunction('index.text:name', [$langid]); |
|
| 243 | + $expr[] = $search->compare('!=', $cmpfunc, null); |
|
| 244 | 244 | |
| 245 | - $sortfunc = $search->createFunction( 'sort:index.text:name', [$langid] ); |
|
| 246 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
| 245 | + $sortfunc = $search->createFunction('sort:index.text:name', [$langid]); |
|
| 246 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
| 247 | 247 | break; |
| 248 | 248 | |
| 249 | 249 | case 'price': |
| 250 | 250 | $currencyid = $context->getLocale()->getCurrencyId(); |
| 251 | 251 | |
| 252 | - $cmpfunc = $search->createFunction( 'index.price:value', [$currencyid] ); |
|
| 253 | - $expr[] = $search->compare( '!=', $cmpfunc, null ); |
|
| 252 | + $cmpfunc = $search->createFunction('index.price:value', [$currencyid]); |
|
| 253 | + $expr[] = $search->compare('!=', $cmpfunc, null); |
|
| 254 | 254 | |
| 255 | - $sortfunc = $search->createFunction( 'sort:index.price:value', [$currencyid] ); |
|
| 256 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
| 255 | + $sortfunc = $search->createFunction('sort:index.price:value', [$currencyid]); |
|
| 256 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
| 257 | 257 | break; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $expr[] = $search->getConditions(); |
| 261 | 261 | |
| 262 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 263 | - $search->setSortations( $sortations ); |
|
| 264 | - $search->setSlice( $start, $size ); |
|
| 262 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 263 | + $search->setSortations($sortations); |
|
| 264 | + $search->setSlice($start, $size); |
|
| 265 | 265 | $search->sortdir = $direction; |
| 266 | 266 | $search->sortname = $sort; |
| 267 | 267 | |
@@ -277,15 +277,15 @@ discard block |
||
| 277 | 277 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
| 278 | 278 | * @since 2017.03 |
| 279 | 279 | */ |
| 280 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
| 280 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
| 281 | 281 | { |
| 282 | - $items = $this->getItems( [$productId], $domains ); |
|
| 282 | + $items = $this->getItems([$productId], $domains); |
|
| 283 | 283 | |
| 284 | - if( ( $item = reset( $items ) ) !== false ) { |
|
| 284 | + if (($item = reset($items)) !== false) { |
|
| 285 | 285 | return $item; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) ); |
|
| 288 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId)); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
| 298 | 298 | * @since 2017.03 |
| 299 | 299 | */ |
| 300 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
| 300 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
| 301 | 301 | { |
| 302 | 302 | $context = $this->getContext(); |
| 303 | - $manager = \Aimeos\MShop::create( $context, 'product' ); |
|
| 303 | + $manager = \Aimeos\MShop::create($context, 'product'); |
|
| 304 | 304 | |
| 305 | 305 | /** controller/frontend/order/ignore-dates |
| 306 | 306 | * Ignore start and end dates of products |
@@ -314,24 +314,24 @@ discard block |
||
| 314 | 314 | * @since 2017.08 |
| 315 | 315 | * @category Developer |
| 316 | 316 | */ |
| 317 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
| 317 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
| 318 | 318 | { |
| 319 | 319 | $search = $manager->createSearch(); |
| 320 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
| 320 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
| 321 | 321 | } |
| 322 | 322 | else |
| 323 | 323 | { |
| 324 | - $search = $manager->createSearch( true ); |
|
| 324 | + $search = $manager->createSearch(true); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | $expr = array( |
| 328 | - $search->compare( '==', 'product.id', $productIds ), |
|
| 328 | + $search->compare('==', 'product.id', $productIds), |
|
| 329 | 329 | $search->getConditions(), |
| 330 | 330 | ); |
| 331 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 332 | - $search->setSlice( 0, count( $productIds ) ); |
|
| 331 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 332 | + $search->setSlice(0, count($productIds)); |
|
| 333 | 333 | |
| 334 | - return $manager->searchItems( $search, $domains ); |
|
| 334 | + return $manager->searchItems($search, $domains); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
| 345 | 345 | * @since 2017.03 |
| 346 | 346 | */ |
| 347 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
| 347 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
| 348 | 348 | { |
| 349 | - return \Aimeos\MShop::create( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
| 349 | + return \Aimeos\MShop::create($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
| 357 | 357 | * @return array List of catalog IDs |
| 358 | 358 | */ |
| 359 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
| 359 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
| 360 | 360 | { |
| 361 | - if( $item->getStatus() < 1 ) { |
|
| 361 | + if ($item->getStatus() < 1) { |
|
| 362 | 362 | return []; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $list = [ $item->getId() ]; |
|
| 365 | + $list = [$item->getId()]; |
|
| 366 | 366 | |
| 367 | - foreach( $item->getChildren() as $child ) { |
|
| 368 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
| 367 | + foreach ($item->getChildren() as $child) { |
|
| 368 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | return $list; |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | * @param array $ids List of IDs to validate |
| 379 | 379 | * @return array List of validated IDs |
| 380 | 380 | */ |
| 381 | - protected function validateIds( array $ids ) |
|
| 381 | + protected function validateIds(array $ids) |
|
| 382 | 382 | { |
| 383 | 383 | $list = []; |
| 384 | 384 | |
| 385 | - foreach( $ids as $id ) |
|
| 385 | + foreach ($ids as $id) |
|
| 386 | 386 | { |
| 387 | - if( $id != '' && preg_match( '/^[A-Za-z0-9\-\_]+$/', $id ) === 1 ) { |
|
| 387 | + if ($id != '' && preg_match('/^[A-Za-z0-9\-\_]+$/', $id) === 1) { |
|
| 388 | 388 | $list[] = (string) $id; |
| 389 | 389 | } |
| 390 | 390 | } |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | * @param string $id Unique subscription ID |
| 28 | 28 | * @return \Aimeos\MShop\Subscription\Item\Iface Canceled subscription item |
| 29 | 29 | */ |
| 30 | - public function cancel( $id ) |
|
| 30 | + public function cancel($id) |
|
| 31 | 31 | { |
| 32 | - $item = $this->getItem( $id ); |
|
| 33 | - $item->setDateEnd( $item->getDateNext() ); |
|
| 34 | - $item->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_CANCEL ); |
|
| 32 | + $item = $this->getItem($id); |
|
| 33 | + $item->setDateEnd($item->getDateNext()); |
|
| 34 | + $item->setReason(\Aimeos\MShop\Subscription\Item\Iface::REASON_CANCEL); |
|
| 35 | 35 | |
| 36 | - return $this->saveItem( $item ); |
|
| 36 | + return $this->saveItem($item); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function createFilter() |
| 46 | 46 | { |
| 47 | - return \Aimeos\MShop::create( $this->getContext(), 'subscription' )->createSearch(); |
|
| 47 | + return \Aimeos\MShop::create($this->getContext(), 'subscription')->createSearch(); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
@@ -54,25 +54,25 @@ discard block |
||
| 54 | 54 | * @param string $id Unique subscription ID |
| 55 | 55 | * @return \Aimeos\MShop\Subscription\Item\Iface Subscription object |
| 56 | 56 | */ |
| 57 | - public function getItem( $id ) |
|
| 57 | + public function getItem($id) |
|
| 58 | 58 | { |
| 59 | 59 | $context = $this->getContext(); |
| 60 | - $manager = \Aimeos\MShop::create( $context, 'subscription' ); |
|
| 60 | + $manager = \Aimeos\MShop::create($context, 'subscription'); |
|
| 61 | 61 | |
| 62 | 62 | $filter = $manager->createSearch(); |
| 63 | 63 | $expr = [ |
| 64 | - $filter->compare( '==', 'subscription.id', $id ), |
|
| 65 | - $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), |
|
| 64 | + $filter->compare('==', 'subscription.id', $id), |
|
| 65 | + $filter->compare('==', 'order.base.customerid', $context->getUserId()), |
|
| 66 | 66 | $filter->getConditions(), |
| 67 | 67 | ]; |
| 68 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 68 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 69 | 69 | |
| 70 | - $items = $this->searchItems( $filter ); |
|
| 70 | + $items = $this->searchItems($filter); |
|
| 71 | 71 | |
| 72 | - if( ( $item = reset( $items ) ) === false ) |
|
| 72 | + if (($item = reset($items)) === false) |
|
| 73 | 73 | { |
| 74 | 74 | $msg = 'Invalid subscription ID "%1$s" for customer ID "%2$s"'; |
| 75 | - throw new \Aimeos\Controller\Frontend\Subscription\Exception( sprintf( $msg, $id, $context->getUserId() ) ); |
|
| 75 | + throw new \Aimeos\Controller\Frontend\Subscription\Exception(sprintf($msg, $id, $context->getUserId())); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $item; |
@@ -87,18 +87,18 @@ discard block |
||
| 87 | 87 | public function getIntervals() |
| 88 | 88 | { |
| 89 | 89 | $intervals = []; |
| 90 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' ); |
|
| 90 | + $manager = \Aimeos\MShop::create($this->getContext(), 'attribute'); |
|
| 91 | 91 | |
| 92 | - $search = $manager->createSearch( true ); |
|
| 92 | + $search = $manager->createSearch(true); |
|
| 93 | 93 | $expr = array( |
| 94 | 94 | $search->getConditions(), |
| 95 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 96 | - $search->compare( '==', 'attribute.type', 'interval' ), |
|
| 95 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 96 | + $search->compare('==', 'attribute.type', 'interval'), |
|
| 97 | 97 | ); |
| 98 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 99 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 98 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 99 | + $search->setSlice(0, 0x7fffffff); |
|
| 100 | 100 | |
| 101 | - foreach( $manager->searchItems( $search, ['text'] ) as $attrItem ) { |
|
| 101 | + foreach ($manager->searchItems($search, ['text']) as $attrItem) { |
|
| 102 | 102 | $intervals[$attrItem->getCode()] = $attrItem; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | * @param \Aimeos\MShop\Subscription\Item\Iface $item Subscription object |
| 112 | 112 | * @return \Aimeos\MShop\Subscription\Item\Iface Saved subscription item |
| 113 | 113 | */ |
| 114 | - public function saveItem( \Aimeos\MShop\Subscription\Item\Iface $item ) |
|
| 114 | + public function saveItem(\Aimeos\MShop\Subscription\Item\Iface $item) |
|
| 115 | 115 | { |
| 116 | - return \Aimeos\MShop::create( $this->getContext(), 'subscription' )->saveItem( $item ); |
|
| 116 | + return \Aimeos\MShop::create($this->getContext(), 'subscription')->saveItem($item); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | * @param integer &$total|null Variable that will contain the total number of available items |
| 125 | 125 | * @return \Aimeos\MShop\Subscription\Item\Iface[] Associative list of IDs as keys and subscription objects as values |
| 126 | 126 | */ |
| 127 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
| 127 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
| 128 | 128 | { |
| 129 | 129 | $context = $this->getContext(); |
| 130 | - $manager = \Aimeos\MShop::create( $context, 'subscription' ); |
|
| 130 | + $manager = \Aimeos\MShop::create($context, 'subscription'); |
|
| 131 | 131 | |
| 132 | 132 | $expr = [ |
| 133 | - $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), |
|
| 133 | + $filter->compare('==', 'order.base.customerid', $context->getUserId()), |
|
| 134 | 134 | $filter->getConditions(), |
| 135 | 135 | ]; |
| 136 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 136 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 137 | 137 | |
| 138 | - return $manager->searchItems( $filter, [], $total ); |
|
| 138 | + return $manager->searchItems($filter, [], $total); |
|
| 139 | 139 | } |
| 140 | 140 | } |
@@ -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 | |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | * @param string $type Arbitrary order type (max. eight chars) |
| 30 | 30 | * @return \Aimeos\MShop\Order\Item\Iface Created order object |
| 31 | 31 | */ |
| 32 | - public function addItem( $baseId, $type ) |
|
| 32 | + public function addItem($baseId, $type) |
|
| 33 | 33 | { |
| 34 | 34 | $total = 0; |
| 35 | 35 | $context = $this->getContext(); |
| 36 | - $manager = \Aimeos\MShop::create( $context, 'order' ); |
|
| 36 | + $manager = \Aimeos\MShop::create($context, 'order'); |
|
| 37 | 37 | |
| 38 | 38 | /** controller/frontend/order/limit-seconds |
| 39 | 39 | * Order limitation time frame in seconds |
@@ -51,24 +51,24 @@ discard block |
||
| 51 | 51 | * @see controller/frontend/basket/limit-count |
| 52 | 52 | * @see controller/frontend/basket/limit-seconds |
| 53 | 53 | */ |
| 54 | - $seconds = $context->getConfig()->get( 'controller/frontend/order/limit-seconds', 300 ); |
|
| 54 | + $seconds = $context->getConfig()->get('controller/frontend/order/limit-seconds', 300); |
|
| 55 | 55 | |
| 56 | 56 | $search = $manager->createSearch(); |
| 57 | 57 | $expr = [ |
| 58 | - $search->compare( '==', 'order.baseid', $baseId ), |
|
| 59 | - $search->compare( '>=', 'order.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
| 58 | + $search->compare('==', 'order.baseid', $baseId), |
|
| 59 | + $search->compare('>=', 'order.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
| 60 | 60 | ]; |
| 61 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 62 | - $search->setSlice( 0, 0 ); |
|
| 61 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 62 | + $search->setSlice(0, 0); |
|
| 63 | 63 | |
| 64 | - $manager->searchItems( $search, [], $total ); |
|
| 64 | + $manager->searchItems($search, [], $total); |
|
| 65 | 65 | |
| 66 | - if( $total > 0 ) { |
|
| 67 | - throw new \Aimeos\Controller\Frontend\Order\Exception( sprintf( 'The order has already been created' ) ); |
|
| 66 | + if ($total > 0) { |
|
| 67 | + throw new \Aimeos\Controller\Frontend\Order\Exception(sprintf('The order has already been created')); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $item = $manager->createItem()->setBaseId( $baseId )->setType( $type ); |
|
| 71 | - return $manager->saveItem( $item ); |
|
| 70 | + $item = $manager->createItem()->setBaseId($baseId)->setType($type); |
|
| 71 | + return $manager->saveItem($item); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function createFilter() |
| 81 | 81 | { |
| 82 | - return \Aimeos\MShop::create( $this->getContext(), 'order' )->createSearch( true ); |
|
| 82 | + return \Aimeos\MShop::create($this->getContext(), 'order')->createSearch(true); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
@@ -90,30 +90,30 @@ discard block |
||
| 90 | 90 | * @param boolean $default Use default criteria to limit orders |
| 91 | 91 | * @return \Aimeos\MShop\Order\Item\Iface Order object |
| 92 | 92 | */ |
| 93 | - public function getItem( $id, $default = true ) |
|
| 93 | + public function getItem($id, $default = true) |
|
| 94 | 94 | { |
| 95 | 95 | $context = $this->getContext(); |
| 96 | - $manager = \Aimeos\MShop::create( $context, 'order' ); |
|
| 96 | + $manager = \Aimeos\MShop::create($context, 'order'); |
|
| 97 | 97 | |
| 98 | - $search = $manager->createSearch( true ); |
|
| 98 | + $search = $manager->createSearch(true); |
|
| 99 | 99 | $expr = [ |
| 100 | - $search->compare( '==', 'order.id', $id ), |
|
| 100 | + $search->compare('==', 'order.id', $id), |
|
| 101 | 101 | $search->getConditions(), |
| 102 | 102 | ]; |
| 103 | 103 | |
| 104 | - if( $default !== false ) { |
|
| 105 | - $expr[] = $search->compare( '==', 'order.editor', $context->getEditor() ); |
|
| 104 | + if ($default !== false) { |
|
| 105 | + $expr[] = $search->compare('==', 'order.editor', $context->getEditor()); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 108 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 109 | 109 | |
| 110 | - $items = $manager->searchItems( $search ); |
|
| 110 | + $items = $manager->searchItems($search); |
|
| 111 | 111 | |
| 112 | - if( ( $item = reset( $items ) ) !== false ) { |
|
| 112 | + if (($item = reset($items)) !== false) { |
|
| 113 | 113 | return $item; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - throw new \Aimeos\Controller\Frontend\Order\Exception( sprintf( 'No order item for ID "%1$s" found', $id ) ); |
|
| 116 | + throw new \Aimeos\Controller\Frontend\Order\Exception(sprintf('No order item for ID "%1$s" found', $id)); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | * @param \Aimeos\MShop\Order\Item\Iface $item Order object |
| 124 | 124 | * @return \Aimeos\MShop\Order\Item\Iface Saved order item |
| 125 | 125 | */ |
| 126 | - public function saveItem( \Aimeos\MShop\Order\Item\Iface $item ) |
|
| 126 | + public function saveItem(\Aimeos\MShop\Order\Item\Iface $item) |
|
| 127 | 127 | { |
| 128 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'order' ); |
|
| 129 | - return $manager->saveItem( $item ); |
|
| 128 | + $manager = \Aimeos\MShop::create($this->getContext(), 'order'); |
|
| 129 | + return $manager->saveItem($item); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | |
@@ -137,18 +137,18 @@ discard block |
||
| 137 | 137 | * @param integer|null &$total Variable that will contain the total number of available items |
| 138 | 138 | * @return \Aimeos\MShop\Order\Item\Iface[] Associative list of IDs as keys and order objects as values |
| 139 | 139 | */ |
| 140 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
| 140 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
| 141 | 141 | { |
| 142 | 142 | $context = $this->getContext(); |
| 143 | - $manager = \Aimeos\MShop::create( $context, 'order' ); |
|
| 143 | + $manager = \Aimeos\MShop::create($context, 'order'); |
|
| 144 | 144 | |
| 145 | 145 | $expr = [ |
| 146 | 146 | $filter->getConditions(), |
| 147 | - $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), |
|
| 147 | + $filter->compare('==', 'order.base.customerid', $context->getUserId()), |
|
| 148 | 148 | ]; |
| 149 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 149 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 150 | 150 | |
| 151 | - return $manager->searchItems( $filter, [], $total ); |
|
| 151 | + return $manager->searchItems($filter, [], $total); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
| 172 | 172 | */ |
| 173 | - public function block( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
| 173 | + public function block(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
| 174 | 174 | { |
| 175 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->block( $orderItem ); |
|
| 175 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->block($orderItem); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -194,9 +194,9 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
| 196 | 196 | */ |
| 197 | - public function unblock( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
| 197 | + public function unblock(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
| 198 | 198 | { |
| 199 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->unblock( $orderItem ); |
|
| 199 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->unblock($orderItem); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
| 216 | 216 | */ |
| 217 | - public function update( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
| 217 | + public function update(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
| 218 | 218 | { |
| 219 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->update( $orderItem ); |
|
| 219 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->update($orderItem); |
|
| 220 | 220 | } |
| 221 | 221 | } |
@@ -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,28 +279,28 @@ 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 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
| 287 | + if (!isset($values['customer.lists.typeid'])) |
|
| 288 | 288 | { |
| 289 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
| 290 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
| 289 | + if (!isset($values['customer.lists.type'])) { |
|
| 290 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
| 294 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
| 293 | + if (!isset($values['customer.lists.domain'])) { |
|
| 294 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - $typeManager = \Aimeos\MShop::create( $context, 'customer/lists/type' ); |
|
| 298 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
| 297 | + $typeManager = \Aimeos\MShop::create($context, 'customer/lists/type'); |
|
| 298 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
| 299 | 299 | $values['customer.lists.typeid'] = $typeItem->getId(); |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $item = $manager->createItem()->fromArray( $values )->setId( null )->setParentId( $context->getUserId() ); |
|
| 303 | - return $manager->saveItem( $item ); |
|
| 302 | + $item = $manager->createItem()->fromArray($values)->setId(null)->setParentId($context->getUserId()); |
|
| 303 | + return $manager->saveItem($item); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | public function createListsFilter() |
| 314 | 314 | { |
| 315 | 315 | $context = $this->getContext(); |
| 316 | - $manager = \Aimeos\MShop::create( $context, 'customer/lists' ); |
|
| 316 | + $manager = \Aimeos\MShop::create($context, 'customer/lists'); |
|
| 317 | 317 | |
| 318 | 318 | $filter = $manager->createSearch(); |
| 319 | - $filter->setConditions( $filter->compare( '==', 'customer.lists.parentid', $context->getUserId() ) ); |
|
| 319 | + $filter->setConditions($filter->compare('==', 'customer.lists.parentid', $context->getUserId())); |
|
| 320 | 320 | |
| 321 | 321 | return $filter; |
| 322 | 322 | } |
@@ -328,13 +328,13 @@ discard block |
||
| 328 | 328 | * @param string $id Unique customer address ID |
| 329 | 329 | * @since 2017.06 |
| 330 | 330 | */ |
| 331 | - public function deleteListItem( $id ) |
|
| 331 | + public function deleteListItem($id) |
|
| 332 | 332 | { |
| 333 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists' ); |
|
| 333 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/lists'); |
|
| 334 | 334 | |
| 335 | - $this->checkUser( $manager->getItem( $id )->getParentId() ); |
|
| 335 | + $this->checkUser($manager->getItem($id)->getParentId()); |
|
| 336 | 336 | |
| 337 | - $manager->deleteItem( $id ); |
|
| 337 | + $manager->deleteItem($id); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
@@ -346,31 +346,31 @@ discard block |
||
| 346 | 346 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
| 347 | 347 | * @since 2017.06 |
| 348 | 348 | */ |
| 349 | - public function editListItem( $id, array $values ) |
|
| 349 | + public function editListItem($id, array $values) |
|
| 350 | 350 | { |
| 351 | 351 | $context = $this->getContext(); |
| 352 | - $manager = \Aimeos\MShop::create( $context, 'customer/lists' ); |
|
| 352 | + $manager = \Aimeos\MShop::create($context, 'customer/lists'); |
|
| 353 | 353 | |
| 354 | - $item = $manager->getItem( $id, [], true ); |
|
| 355 | - $this->checkUser( $item->getParentId() ); |
|
| 356 | - unset( $values['customer.lists.id'] ); |
|
| 354 | + $item = $manager->getItem($id, [], true); |
|
| 355 | + $this->checkUser($item->getParentId()); |
|
| 356 | + unset($values['customer.lists.id']); |
|
| 357 | 357 | |
| 358 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
| 358 | + if (!isset($values['customer.lists.typeid'])) |
|
| 359 | 359 | { |
| 360 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
| 361 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
| 360 | + if (!isset($values['customer.lists.type'])) { |
|
| 361 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
| 365 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
| 364 | + if (!isset($values['customer.lists.domain'])) { |
|
| 365 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $typeManager = \Aimeos\MShop::create( $context, 'customer/lists/type' ); |
|
| 369 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'], true ); |
|
| 368 | + $typeManager = \Aimeos\MShop::create($context, 'customer/lists/type'); |
|
| 369 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain'], true); |
|
| 370 | 370 | $values['customer.lists.typeid'] = $typeItem->getId(); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - return $manager->saveItem( $item->fromArray( $values ) ); |
|
| 373 | + return $manager->saveItem($item->fromArray($values)); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | |
@@ -381,12 +381,12 @@ discard block |
||
| 381 | 381 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 382 | 382 | * @since 2017.06 |
| 383 | 383 | */ |
| 384 | - public function getListItem( $id ) |
|
| 384 | + public function getListItem($id) |
|
| 385 | 385 | { |
| 386 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists' ); |
|
| 387 | - $item = $manager->getItem( $id ); |
|
| 386 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/lists'); |
|
| 387 | + $item = $manager->getItem($id); |
|
| 388 | 388 | |
| 389 | - $this->checkUser( $item->getParentId() ); |
|
| 389 | + $this->checkUser($item->getParentId()); |
|
| 390 | 390 | |
| 391 | 391 | return $item; |
| 392 | 392 | } |
@@ -400,11 +400,11 @@ discard block |
||
| 400 | 400 | * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items |
| 401 | 401 | * @since 2017.06 |
| 402 | 402 | */ |
| 403 | - public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
| 403 | + public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
| 404 | 404 | { |
| 405 | - $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/lists' ); |
|
| 405 | + $manager = \Aimeos\MShop::create($this->getContext(), 'customer/lists'); |
|
| 406 | 406 | |
| 407 | - return $manager->searchItems( $filter, [], $total ); |
|
| 407 | + return $manager->searchItems($filter, [], $total); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | |
@@ -414,33 +414,33 @@ discard block |
||
| 414 | 414 | * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values |
| 415 | 415 | * @return string[] Associative list of customer key/value pairs with default values set |
| 416 | 416 | */ |
| 417 | - protected function addItemDefaults( array $values ) |
|
| 417 | + protected function addItemDefaults(array $values) |
|
| 418 | 418 | { |
| 419 | - if( !isset( $values['customer.label'] ) || $values['customer.label'] == '' ) |
|
| 419 | + if (!isset($values['customer.label']) || $values['customer.label'] == '') |
|
| 420 | 420 | { |
| 421 | 421 | $label = ''; |
| 422 | 422 | |
| 423 | - if( isset( $values['customer.lastname'] ) ) { |
|
| 423 | + if (isset($values['customer.lastname'])) { |
|
| 424 | 424 | $label = $values['customer.lastname']; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - if( isset( $values['customer.firstname'] ) && $values['customer.firstname'] != '' ) { |
|
| 427 | + if (isset($values['customer.firstname']) && $values['customer.firstname'] != '') { |
|
| 428 | 428 | $label = $values['customer.firstname'] . ' ' . $label; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - if( isset( $values['customer.company'] ) && $values['customer.company'] != '' ) { |
|
| 431 | + if (isset($values['customer.company']) && $values['customer.company'] != '') { |
|
| 432 | 432 | $label .= ' (' . $values['customer.company'] . ')'; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | $values['customer.label'] = $label; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if( !isset( $values['customer.code'] ) && isset( $values['customer.email'] ) ) { |
|
| 438 | + if (!isset($values['customer.code']) && isset($values['customer.email'])) { |
|
| 439 | 439 | $values['customer.code'] = $values['customer.email']; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if( !isset( $values['customer.password'] ) ) { |
|
| 443 | - $values['customer.password'] = substr( md5( microtime( true ) . getmypid() . rand() ), -8 ); |
|
| 442 | + if (!isset($values['customer.password'])) { |
|
| 443 | + $values['customer.password'] = substr(md5(microtime(true) . getmypid() . rand()), -8); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | return $values; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values |
| 454 | 454 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
| 455 | 455 | */ |
| 456 | - protected function checkLimit( array $values ) |
|
| 456 | + protected function checkLimit(array $values) |
|
| 457 | 457 | { |
| 458 | 458 | $total = 0; |
| 459 | 459 | $context = $this->getContext(); |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | * @category Developer |
| 475 | 475 | * @see controller/frontend/customer/limit-seconds |
| 476 | 476 | */ |
| 477 | - $count = $config->get( 'controller/frontend/customer/limit-count', 5 ); |
|
| 477 | + $count = $config->get('controller/frontend/customer/limit-count', 5); |
|
| 478 | 478 | |
| 479 | 479 | /** controller/frontend/customer/limit-seconds |
| 480 | 480 | * Customer account limitation time frame in seconds |
@@ -492,22 +492,22 @@ discard block |
||
| 492 | 492 | * @category Developer |
| 493 | 493 | * @see controller/frontend/customer/limit-count |
| 494 | 494 | */ |
| 495 | - $seconds = $config->get( 'controller/frontend/customer/limit-seconds', 300 ); |
|
| 495 | + $seconds = $config->get('controller/frontend/customer/limit-seconds', 300); |
|
| 496 | 496 | |
| 497 | - $manager = \Aimeos\MShop::create( $context, 'customer' ); |
|
| 497 | + $manager = \Aimeos\MShop::create($context, 'customer'); |
|
| 498 | 498 | |
| 499 | 499 | $search = $manager->createSearch(); |
| 500 | 500 | $expr = [ |
| 501 | - $search->compare( '==', 'customer.editor', $context->getEditor() ), |
|
| 502 | - $search->compare( '>=', 'customer.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
| 501 | + $search->compare('==', 'customer.editor', $context->getEditor()), |
|
| 502 | + $search->compare('>=', 'customer.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
| 503 | 503 | ]; |
| 504 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 505 | - $search->setSlice( 0, 0 ); |
|
| 504 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 505 | + $search->setSlice(0, 0); |
|
| 506 | 506 | |
| 507 | - $manager->searchItems( $search, [], $total ); |
|
| 507 | + $manager->searchItems($search, [], $total); |
|
| 508 | 508 | |
| 509 | - if( $total > $count ) { |
|
| 510 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Temporary limit reached' ) ); |
|
| 509 | + if ($total > $count) { |
|
| 510 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Temporary limit reached')); |
|
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | |
@@ -518,12 +518,12 @@ discard block |
||
| 518 | 518 | * @param string $id Unique customer ID |
| 519 | 519 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
| 520 | 520 | */ |
| 521 | - protected function checkUser( $id ) |
|
| 521 | + protected function checkUser($id) |
|
| 522 | 522 | { |
| 523 | - if( $id != $this->getContext()->getUserId() ) |
|
| 523 | + if ($id != $this->getContext()->getUserId()) |
|
| 524 | 524 | { |
| 525 | - $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); |
|
| 526 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); |
|
| 525 | + $msg = sprintf('Not allowed to access customer data for ID "%1$s"', $id); |
|
| 526 | + throw new \Aimeos\Controller\Frontend\Customer\Exception($msg); |
|
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | } |
@@ -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 | } |
@@ -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; |