@@ -18,121 +18,121 @@ discard block |
||
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | 20 | $this->context = \TestHelperFrontend::getContext(); |
21 | - $this->object = new \Aimeos\Controller\Frontend\Customer\Standard( $this->context ); |
|
21 | + $this->object = new \Aimeos\Controller\Frontend\Customer\Standard($this->context); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | 25 | protected function tearDown() |
26 | 26 | { |
27 | - unset( $this->context, $this->object ); |
|
27 | + unset($this->context, $this->object); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | 31 | public function testAddEditSaveDeleteItem() |
32 | 32 | { |
33 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
34 | - $id = $manager->findItem( 'UTC001' )->getId(); |
|
33 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
34 | + $id = $manager->findItem('UTC001')->getId(); |
|
35 | 35 | |
36 | - $this->context->setUserId( $id ); |
|
37 | - $item = $this->object->addItem( ['customer.code' => 'unittest-ctnl', 'customer.status' => 1] ); |
|
38 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
36 | + $this->context->setUserId($id); |
|
37 | + $item = $this->object->addItem(['customer.code' => 'unittest-ctnl', 'customer.status' => 1]); |
|
38 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
39 | 39 | |
40 | - $this->context->setUserId( $item->getId() ); |
|
41 | - $item = $this->object->editItem( $item->getId(), ['customer.code' => 'unittest-ctnl2'] ); |
|
42 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
40 | + $this->context->setUserId($item->getId()); |
|
41 | + $item = $this->object->editItem($item->getId(), ['customer.code' => 'unittest-ctnl2']); |
|
42 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
43 | 43 | |
44 | - $item->setStatus( 0 ); |
|
45 | - $item = $this->object->saveItem( $item ); |
|
46 | - $this->assertEquals( 0, $item->getStatus() ); |
|
44 | + $item->setStatus(0); |
|
45 | + $item = $this->object->saveItem($item); |
|
46 | + $this->assertEquals(0, $item->getStatus()); |
|
47 | 47 | |
48 | - $this->object->deleteItem( $item->getId() ); |
|
48 | + $this->object->deleteItem($item->getId()); |
|
49 | 49 | |
50 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
51 | - $manager->findItem( 'unittest-ctnl' ); |
|
50 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
51 | + $manager->findItem('unittest-ctnl'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testAddExistingItem() |
56 | 56 | { |
57 | - $item = $this->object->addItem( ['customer.code' => 'UTC001'] ); |
|
58 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
57 | + $item = $this->object->addItem(['customer.code' => 'UTC001']); |
|
58 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testCreateItem() |
63 | 63 | { |
64 | 64 | $result = $this->object->createItem(); |
65 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
65 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | public function testGetItem() |
70 | 70 | { |
71 | - $id = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' )->getId(); |
|
72 | - $this->context->setUserId( $id ); |
|
71 | + $id = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001')->getId(); |
|
72 | + $this->context->setUserId($id); |
|
73 | 73 | |
74 | - $result = $this->object->getItem( $id, ['customer/address', 'text'] ); |
|
74 | + $result = $this->object->getItem($id, ['customer/address', 'text']); |
|
75 | 75 | |
76 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
77 | - $this->assertEquals( 1, count( $result->getRefItems( 'text' ) ) ); |
|
78 | - $this->assertEquals( 1, count( $result->getAddressItems() ) ); |
|
76 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
77 | + $this->assertEquals(1, count($result->getRefItems('text'))); |
|
78 | + $this->assertEquals(1, count($result->getAddressItems())); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | 82 | public function testFindItem() |
83 | 83 | { |
84 | - $result = $this->object->findItem( 'UTC001' ); |
|
85 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
84 | + $result = $this->object->findItem('UTC001'); |
|
85 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | 89 | public function testAddEditSaveDeleteAddressItem() |
90 | 90 | { |
91 | - $customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
|
92 | - $this->context->setUserId( $customer->getId() ); |
|
91 | + $customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001'); |
|
92 | + $this->context->setUserId($customer->getId()); |
|
93 | 93 | |
94 | - $item = $this->object->addAddressItem( ['customer.address.lastname' => 'unittest-ctnl'] ); |
|
95 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
|
94 | + $item = $this->object->addAddressItem(['customer.address.lastname' => 'unittest-ctnl']); |
|
95 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item); |
|
96 | 96 | |
97 | - $item = $this->object->editAddressItem( $item->getId(), ['customer.address.lastname' => 'unittest-ctnl2'] ); |
|
98 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
|
97 | + $item = $this->object->editAddressItem($item->getId(), ['customer.address.lastname' => 'unittest-ctnl2']); |
|
98 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item); |
|
99 | 99 | |
100 | - $item->setLastName( 'test' ); |
|
101 | - $this->object->saveAddressItem( $item ); |
|
102 | - $this->assertEquals( 'test', $item->getLastName() ); |
|
100 | + $item->setLastName('test'); |
|
101 | + $this->object->saveAddressItem($item); |
|
102 | + $this->assertEquals('test', $item->getLastName()); |
|
103 | 103 | |
104 | - $this->object->deleteAddressItem( $item->getId() ); |
|
104 | + $this->object->deleteAddressItem($item->getId()); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | 108 | public function testCreateAddressItem() |
109 | 109 | { |
110 | 110 | $result = $this->object->createAddressItem(); |
111 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
|
111 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testGetAddressItem() |
116 | 116 | { |
117 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/address' ); |
|
117 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/address'); |
|
118 | 118 | $search = $manager->createSearch(); |
119 | - $search->setSlice( 0, 1 ); |
|
120 | - $result = $manager->searchItems( $search ); |
|
119 | + $search->setSlice(0, 1); |
|
120 | + $result = $manager->searchItems($search); |
|
121 | 121 | |
122 | - if( ( $item = reset( $result ) ) === false ) { |
|
123 | - throw new \RuntimeException( 'No customer address available' ); |
|
122 | + if (($item = reset($result)) === false) { |
|
123 | + throw new \RuntimeException('No customer address available'); |
|
124 | 124 | } |
125 | 125 | |
126 | - $this->context->setUserId( $item->getParentId() ); |
|
127 | - $result = $this->object->getAddressItem( $item->getId() ); |
|
128 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
|
126 | + $this->context->setUserId($item->getParentId()); |
|
127 | + $result = $this->object->getAddressItem($item->getId()); |
|
128 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | public function testAddEditDeleteListItem() |
133 | 133 | { |
134 | - $customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
|
135 | - $this->context->setUserId( $customer->getId() ); |
|
134 | + $customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001'); |
|
135 | + $this->context->setUserId($customer->getId()); |
|
136 | 136 | |
137 | 137 | $values = [ |
138 | 138 | 'customer.lists.type' => 'favorite', |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | 'customer.lists.refid' => '-1' |
141 | 141 | ]; |
142 | 142 | |
143 | - $item = $this->object->addListItem( $values ); |
|
144 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
143 | + $item = $this->object->addListItem($values); |
|
144 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
145 | 145 | |
146 | 146 | $values = [ |
147 | 147 | 'customer.lists.type' => 'favorite', |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | 'customer.lists.refid' => '-2' |
150 | 150 | ]; |
151 | 151 | |
152 | - $item = $this->object->editListItem( $item->getId(), $values ); |
|
153 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
152 | + $item = $this->object->editListItem($item->getId(), $values); |
|
153 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
154 | 154 | |
155 | - $this->object->deleteListItem( $item->getId() ); |
|
155 | + $this->object->deleteListItem($item->getId()); |
|
156 | 156 | |
157 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
158 | - $this->object->getListItem( $item->getId() ); |
|
157 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
158 | + $this->object->getListItem($item->getId()); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | 162 | public function testGetListItem() |
163 | 163 | { |
164 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/lists' ); |
|
164 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/lists'); |
|
165 | 165 | $search = $manager->createSearch(); |
166 | - $search->setSlice( 0, 1 ); |
|
167 | - $result = $manager->searchItems( $search ); |
|
166 | + $search->setSlice(0, 1); |
|
167 | + $result = $manager->searchItems($search); |
|
168 | 168 | |
169 | - if( ( $item = reset( $result ) ) === false ) { |
|
170 | - throw new \RuntimeException( 'No customer lists item available' ); |
|
169 | + if (($item = reset($result)) === false) { |
|
170 | + throw new \RuntimeException('No customer lists item available'); |
|
171 | 171 | } |
172 | 172 | |
173 | - $this->context->setUserId( $item->getParentId() ); |
|
174 | - $result = $this->object->getListItem( $item->getId() ); |
|
175 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $result ); |
|
173 | + $this->context->setUserId($item->getParentId()); |
|
174 | + $result = $this->object->getListItem($item->getId()); |
|
175 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $result); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
179 | 179 | public function testSearchListItem() |
180 | 180 | { |
181 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
182 | - $customer = $manager->findItem( 'UTC001' ); |
|
183 | - $this->context->setUserId( $customer->getId() ); |
|
181 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
182 | + $customer = $manager->findItem('UTC001'); |
|
183 | + $this->context->setUserId($customer->getId()); |
|
184 | 184 | |
185 | 185 | $filter = $this->object->createListsFilter(); |
186 | - $result = $this->object->searchListItems( $filter ); |
|
186 | + $result = $this->object->searchListItems($filter); |
|
187 | 187 | |
188 | - foreach( $result as $item ) |
|
188 | + foreach ($result as $item) |
|
189 | 189 | { |
190 | - $this->assertEquals( $customer->getId(), $item->getParentId() ); |
|
191 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
190 | + $this->assertEquals($customer->getId(), $item->getParentId()); |
|
191 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -180,8 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $search = $manager->createSearch(); |
182 | 182 | $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
183 | - } |
|
184 | - else |
|
183 | + } else |
|
185 | 184 | { |
186 | 185 | $search = $manager->createSearch( true ); |
187 | 186 | } |
@@ -275,8 +274,7 @@ discard block |
||
275 | 274 | { |
276 | 275 | $search = $manager->createSearch(); |
277 | 276 | $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
278 | - } |
|
279 | - else |
|
277 | + } else |
|
280 | 278 | { |
281 | 279 | $search = $manager->createSearch( true ); |
282 | 280 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * Returns the given search filter with the conditions attached for filtering by suppliers. |
124 | 124 | * |
125 | 125 | * @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for product search |
126 | - * @param array $supIds List of supplier IDs for faceted search |
|
126 | + * @param integer[] $supIds List of supplier IDs for faceted search |
|
127 | 127 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
128 | 128 | * @since 2018.07 |
129 | 129 | */ |
@@ -334,6 +334,7 @@ discard block |
||
334 | 334 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
335 | 335 | * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too |
336 | 336 | * @param integer &$total Parameter where the total number of found products will be stored in |
337 | + * @param integer $total |
|
337 | 338 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
338 | 339 | * @since 2017.03 |
339 | 340 | */ |
@@ -31,38 +31,38 @@ 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.attributeaggregate', array( $attrIds ) ); |
|
38 | + $func = $filter->createFunction('index.attributeaggregate', array($attrIds)); |
|
39 | 39 | $expr = array( |
40 | - $filter->compare( '==', $func, count( $attrIds ) ), |
|
40 | + $filter->compare('==', $func, count($attrIds)), |
|
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 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) ); |
|
48 | + $func = $filter->createFunction('index.attributeaggregate', array($optIds)); |
|
49 | 49 | $expr = array( |
50 | - $filter->compare( '>', $func, 0 ), |
|
50 | + $filter->compare('>', $func, 0), |
|
51 | 51 | $filter->getConditions(), |
52 | 52 | ); |
53 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
53 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
54 | 54 | } |
55 | 55 | |
56 | - foreach( $oneIds as $type => $list ) |
|
56 | + foreach ($oneIds as $type => $list) |
|
57 | 57 | { |
58 | - if( ( $list = $this->validateIds( (array) $list ) ) !== [] ) |
|
58 | + if (($list = $this->validateIds((array) $list)) !== []) |
|
59 | 59 | { |
60 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $list ) ); |
|
60 | + $func = $filter->createFunction('index.attributeaggregate', array($list)); |
|
61 | 61 | $expr = array( |
62 | - $filter->compare( '>', $func, 0 ), |
|
62 | + $filter->compare('>', $func, 0), |
|
63 | 63 | $filter->getConditions(), |
64 | 64 | ); |
65 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
65 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -82,38 +82,38 @@ discard block |
||
82 | 82 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
83 | 83 | * @since 2017.03 |
84 | 84 | */ |
85 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
86 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ) |
|
85 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
86 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default') |
|
87 | 87 | { |
88 | - $catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId ); |
|
88 | + $catIds = (!is_array($catId) ? explode(',', $catId) : $catId); |
|
89 | 89 | |
90 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
90 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
91 | 91 | { |
92 | 92 | $list = []; |
93 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
93 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
94 | 94 | |
95 | - foreach( $catIds as $catId ) |
|
95 | + foreach ($catIds as $catId) |
|
96 | 96 | { |
97 | - $tree = $cntl->getTree( $catId, [], $level ); |
|
98 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
97 | + $tree = $cntl->getTree($catId, [], $level); |
|
98 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | $catIds = $list; |
102 | 102 | } |
103 | 103 | |
104 | - $expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) ); |
|
104 | + $expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds))); |
|
105 | 105 | $expr[] = $filter->getConditions(); |
106 | 106 | |
107 | - if( $sort === 'relevance' ) |
|
107 | + if ($sort === 'relevance') |
|
108 | 108 | { |
109 | - $cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) ); |
|
110 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
109 | + $cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds)); |
|
110 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
111 | 111 | |
112 | - $sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) ); |
|
113 | - $filter->setSortations( [$filter->sort( $direction, $sortfunc ), $filter->sort( '+', 'product.id' )] ); |
|
112 | + $sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds)); |
|
113 | + $filter->setSortations([$filter->sort($direction, $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 | } |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
128 | 128 | * @since 2018.07 |
129 | 129 | */ |
130 | - public function addFilterSupplier( \Aimeos\MW\Criteria\Iface $filter, array $supIds ) |
|
130 | + public function addFilterSupplier(\Aimeos\MW\Criteria\Iface $filter, array $supIds) |
|
131 | 131 | { |
132 | - if( !empty( $supIds ) ) |
|
132 | + if (!empty($supIds)) |
|
133 | 133 | { |
134 | - $supIds = $this->validateIds( $supIds ); |
|
134 | + $supIds = $this->validateIds($supIds); |
|
135 | 135 | $expr = array( |
136 | - $filter->compare( '==', 'index.supplier.id', $supIds ), |
|
136 | + $filter->compare('==', 'index.supplier.id', $supIds), |
|
137 | 137 | $filter->getConditions(), |
138 | 138 | ); |
139 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
139 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $filter; |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
155 | 155 | * @since 2017.03 |
156 | 156 | */ |
157 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ) |
|
157 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default') |
|
158 | 158 | { |
159 | 159 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
160 | - $cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ); |
|
161 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
160 | + $cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input)); |
|
161 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
162 | 162 | |
163 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
163 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @return array Associative list of key values as key and the product count for this key as value |
173 | 173 | * @since 2017.03 |
174 | 174 | */ |
175 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
175 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
176 | 176 | { |
177 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
177 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
190 | 190 | * @since 2017.03 |
191 | 191 | */ |
192 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
192 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
193 | 193 | { |
194 | 194 | $sortations = []; |
195 | 195 | $context = $this->getContext(); |
196 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); |
|
196 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'index'); |
|
197 | 197 | |
198 | 198 | |
199 | 199 | /** controller/frontend/product/ignore-dates |
@@ -208,55 +208,55 @@ discard block |
||
208 | 208 | * @since 2017.10 |
209 | 209 | * @category Developer |
210 | 210 | */ |
211 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
211 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
212 | 212 | { |
213 | 213 | $search = $manager->createSearch(); |
214 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
214 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
218 | - $search = $manager->createSearch( true ); |
|
218 | + $search = $manager->createSearch(true); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
222 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
222 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
223 | 223 | |
224 | - switch( $sort ) |
|
224 | + switch ($sort) |
|
225 | 225 | { |
226 | 226 | case 'code': |
227 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
227 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
228 | 228 | break; |
229 | 229 | |
230 | 230 | case 'ctime': |
231 | - $sortations[] = $search->sort( $direction, 'product.ctime' ); |
|
231 | + $sortations[] = $search->sort($direction, 'product.ctime'); |
|
232 | 232 | break; |
233 | 233 | |
234 | 234 | case 'name': |
235 | 235 | $langid = $context->getLocale()->getLanguageId(); |
236 | 236 | |
237 | - $cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) ); |
|
238 | - $expr[] = $search->compare( '>=', $cmpfunc, '' ); |
|
237 | + $cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product')); |
|
238 | + $expr[] = $search->compare('>=', $cmpfunc, ''); |
|
239 | 239 | |
240 | - $sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) ); |
|
241 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
240 | + $sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name')); |
|
241 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
242 | 242 | break; |
243 | 243 | |
244 | 244 | case 'price': |
245 | 245 | $currencyid = $context->getLocale()->getCurrencyId(); |
246 | 246 | |
247 | - $cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
248 | - $expr[] = $search->compare( '>=', $cmpfunc, '0.00' ); |
|
247 | + $cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default')); |
|
248 | + $expr[] = $search->compare('>=', $cmpfunc, '0.00'); |
|
249 | 249 | |
250 | - $sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
251 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
250 | + $sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default')); |
|
251 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
252 | 252 | break; |
253 | 253 | } |
254 | 254 | |
255 | 255 | $expr[] = $search->getConditions(); |
256 | 256 | |
257 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
258 | - $search->setSortations( $sortations ); |
|
259 | - $search->setSlice( $start, $size ); |
|
257 | + $search->setConditions($search->combine('&&', $expr)); |
|
258 | + $search->setSortations($sortations); |
|
259 | + $search->setSlice($start, $size); |
|
260 | 260 | |
261 | 261 | return $search; |
262 | 262 | } |
@@ -270,15 +270,15 @@ discard block |
||
270 | 270 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
271 | 271 | * @since 2017.03 |
272 | 272 | */ |
273 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
273 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
274 | 274 | { |
275 | - $items = $this->getItems( [$productId], $domains ); |
|
275 | + $items = $this->getItems([$productId], $domains); |
|
276 | 276 | |
277 | - if( ( $item = reset( $items ) ) !== false ) { |
|
277 | + if (($item = reset($items)) !== false) { |
|
278 | 278 | return $item; |
279 | 279 | } |
280 | 280 | |
281 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) ); |
|
281 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
291 | 291 | * @since 2017.03 |
292 | 292 | */ |
293 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
293 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
294 | 294 | { |
295 | 295 | $context = $this->getContext(); |
296 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
296 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
297 | 297 | |
298 | 298 | /** controller/frontend/order/ignore-dates |
299 | 299 | * Ignore start and end dates of products |
@@ -307,25 +307,25 @@ discard block |
||
307 | 307 | * @since 2017.08 |
308 | 308 | * @category Developer |
309 | 309 | */ |
310 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
310 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
311 | 311 | { |
312 | 312 | $search = $manager->createSearch(); |
313 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
313 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
314 | 314 | } |
315 | 315 | else |
316 | 316 | { |
317 | - $search = $manager->createSearch( true ); |
|
317 | + $search = $manager->createSearch(true); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | $expr = array( |
321 | - $search->compare( '==', 'product.id', $productIds ), |
|
321 | + $search->compare('==', 'product.id', $productIds), |
|
322 | 322 | $search->getConditions(), |
323 | 323 | ); |
324 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
325 | - $search->setSortations( [$search->sort( '+', 'product.type.position' )] ); |
|
326 | - $search->setSlice( 0, count( $productIds ) ); |
|
324 | + $search->setConditions($search->combine('&&', $expr)); |
|
325 | + $search->setSortations([$search->sort('+', 'product.type.position')]); |
|
326 | + $search->setSlice(0, count($productIds)); |
|
327 | 327 | |
328 | - return $manager->searchItems( $search, $domains ); |
|
328 | + return $manager->searchItems($search, $domains); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
339 | 339 | * @since 2017.03 |
340 | 340 | */ |
341 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
341 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
342 | 342 | { |
343 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
343 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,16 +350,16 @@ discard block |
||
350 | 350 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
351 | 351 | * @return array List of catalog IDs |
352 | 352 | */ |
353 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
353 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
354 | 354 | { |
355 | - if( $item->getStatus() < 1 ) { |
|
355 | + if ($item->getStatus() < 1) { |
|
356 | 356 | return []; |
357 | 357 | } |
358 | 358 | |
359 | - $list = [ $item->getId() ]; |
|
359 | + $list = [$item->getId()]; |
|
360 | 360 | |
361 | - foreach( $item->getChildren() as $child ) { |
|
362 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
361 | + foreach ($item->getChildren() as $child) { |
|
362 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | return $list; |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | * @param array $ids List of IDs to validate |
373 | 373 | * @return array List of validated IDs |
374 | 374 | */ |
375 | - protected function validateIds( array $ids ) |
|
375 | + protected function validateIds(array $ids) |
|
376 | 376 | { |
377 | 377 | $list = []; |
378 | 378 | |
379 | - foreach( $ids as $id ) |
|
379 | + foreach ($ids as $id) |
|
380 | 380 | { |
381 | - if( $id != '' ) { |
|
381 | + if ($id != '') { |
|
382 | 382 | $list[] = (int) $id; |
383 | 383 | } |
384 | 384 | } |
@@ -431,17 +431,14 @@ |
||
431 | 431 | { |
432 | 432 | $address->copyFrom( $value ); |
433 | 433 | $this->get()->setAddress( $address, $type ); |
434 | - } |
|
435 | - else if( is_array( $value ) ) |
|
434 | + } else if( is_array( $value ) ) |
|
436 | 435 | { |
437 | 436 | $this->setAddressFromArray( $address, $value ); |
438 | 437 | $this->get()->setAddress( $address, $type ); |
439 | - } |
|
440 | - else if( $value === null ) |
|
438 | + } else if( $value === null ) |
|
441 | 439 | { |
442 | 440 | $this->get()->deleteAddress( $type ); |
443 | - } |
|
444 | - else |
|
441 | + } else |
|
445 | 442 | { |
446 | 443 | $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' ); |
447 | 444 | throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) ); |
@@ -150,7 +150,6 @@ |
||
150 | 150 | * Adds the delivery/payment service item based on the service ID. |
151 | 151 | * |
152 | 152 | * @param string $type Service type code like 'payment' or 'delivery' |
153 | - * @param string $id|null Unique ID of the service item or null to remove it |
|
154 | 153 | * @param array $attributes Associative list of key/value pairs containing the attributes selected or |
155 | 154 | * entered by the customer when choosing one of the delivery or payment options |
156 | 155 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
34 | 34 | * connections, logger, session, etc. |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
37 | 37 | { |
38 | - parent::__construct( $context ); |
|
38 | + parent::__construct($context); |
|
39 | 39 | |
40 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
40 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function clear() |
50 | 50 | { |
51 | 51 | $this->baskets[$this->type] = $this->domainManager->createItem(); |
52 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
52 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
53 | 53 | |
54 | 54 | return $this; |
55 | 55 | } |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function get() |
64 | 64 | { |
65 | - if( !isset( $this->baskets[$this->type] ) ) |
|
65 | + if (!isset($this->baskets[$this->type])) |
|
66 | 66 | { |
67 | - $this->baskets[$this->type] = $this->domainManager->getSession( $this->type ); |
|
68 | - $this->checkLocale( $this->baskets[$this->type]->getLocale(), $this->type ); |
|
67 | + $this->baskets[$this->type] = $this->domainManager->getSession($this->type); |
|
68 | + $this->checkLocale($this->baskets[$this->type]->getLocale(), $this->type); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | return $this->baskets[$this->type]; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function save() |
81 | 81 | { |
82 | - if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { |
|
83 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
82 | + if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) { |
|
83 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $this; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $type Basket type |
94 | 94 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
95 | 95 | */ |
96 | - public function setType( $type ) |
|
96 | + public function setType($type) |
|
97 | 97 | { |
98 | 98 | $this->type = $type; |
99 | 99 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @category Developer |
128 | 128 | * @see controller/frontend/basket/limit-seconds |
129 | 129 | */ |
130 | - $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); |
|
130 | + $count = $config->get('controller/frontend/basket/limit-count', 5); |
|
131 | 131 | |
132 | 132 | /** controller/frontend/basket/limit-seconds |
133 | 133 | * Order limitation time frame in seconds |
@@ -145,33 +145,33 @@ discard block |
||
145 | 145 | * @category Developer |
146 | 146 | * @see controller/frontend/basket/limit-count |
147 | 147 | */ |
148 | - $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); |
|
148 | + $seconds = $config->get('controller/frontend/basket/limit-seconds', 300); |
|
149 | 149 | |
150 | 150 | $search = $this->domainManager->createSearch(); |
151 | 151 | $expr = [ |
152 | - $search->compare( '==', 'order.base.editor', $context->getEditor() ), |
|
153 | - $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
152 | + $search->compare('==', 'order.base.editor', $context->getEditor()), |
|
153 | + $search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
154 | 154 | ]; |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
156 | - $search->setSlice( 0, 0 ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | + $search->setSlice(0, 0); |
|
157 | 157 | |
158 | - $this->domainManager->searchItems( $search, [], $total ); |
|
158 | + $this->domainManager->searchItems($search, [], $total); |
|
159 | 159 | |
160 | - if( $total > $count ) |
|
160 | + if ($total > $count) |
|
161 | 161 | { |
162 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Temporary order limit reached' ); |
|
163 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
162 | + $msg = $context->getI18n()->dt('controller/frontend', 'Temporary order limit reached'); |
|
163 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | 167 | $basket = $this->get()->finish(); |
168 | - $basket->setCustomerId( (string) $context->getUserId() ); |
|
168 | + $basket->setCustomerId((string) $context->getUserId()); |
|
169 | 169 | |
170 | 170 | $this->domainManager->begin(); |
171 | - $this->domainManager->store( $basket ); |
|
171 | + $this->domainManager->store($basket); |
|
172 | 172 | $this->domainManager->commit(); |
173 | 173 | |
174 | - $this->createSubscriptions( $basket ); |
|
174 | + $this->createSubscriptions($basket); |
|
175 | 175 | |
176 | 176 | return $basket; |
177 | 177 | } |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | * @param boolean $default True to add default criteria (user logged in), false if not |
186 | 186 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
187 | 187 | */ |
188 | - public function load( $id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true ) |
|
188 | + public function load($id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true) |
|
189 | 189 | { |
190 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
190 | + return $this->domainManager->load($id, $parts, false, $default); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * @param string $stocktype Unique code of the stock type to deliver the products from |
207 | 207 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
208 | 208 | */ |
209 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
210 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
209 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
210 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
211 | 211 | { |
212 | 212 | $attributeMap = [ |
213 | - 'custom' => array_keys( $customAttributeValues ), |
|
214 | - 'config' => array_keys( $configAttributeIds ), |
|
213 | + 'custom' => array_keys($customAttributeValues), |
|
214 | + 'config' => array_keys($configAttributeIds), |
|
215 | 215 | ]; |
216 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
216 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
217 | 217 | |
218 | 218 | |
219 | 219 | $context = $this->getContext(); |
220 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
220 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
221 | 221 | |
222 | - $productItem = $productManager->getItem( $prodid, ['attribute', 'media', 'supplier', 'price', 'product', 'text'], true ); |
|
223 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
224 | - $hidden = $productItem->getRefItems( 'attribute', null, 'hidden' ); |
|
222 | + $productItem = $productManager->getItem($prodid, ['attribute', 'media', 'supplier', 'price', 'product', 'text'], true); |
|
223 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
224 | + $hidden = $productItem->getRefItems('attribute', null, 'hidden'); |
|
225 | 225 | |
226 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
227 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
226 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
227 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
228 | 228 | |
229 | - $custAttr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
230 | - $confAttr = $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ); |
|
231 | - $attr = array_merge( $custAttr, $confAttr, $this->getOrderProductAttributes( 'hidden', array_keys( $hidden ) ) ); |
|
229 | + $custAttr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
230 | + $confAttr = $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds); |
|
231 | + $attr = array_merge($custAttr, $confAttr, $this->getOrderProductAttributes('hidden', array_keys($hidden))); |
|
232 | 232 | |
233 | - $orderBaseProductItem->setAttributes( $attr ); |
|
234 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
233 | + $orderBaseProductItem->setAttributes($attr); |
|
234 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
235 | 235 | |
236 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
236 | + $this->get()->addProduct($orderBaseProductItem); |
|
237 | 237 | $this->save(); |
238 | 238 | } |
239 | 239 | |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @param integer $position Position number (key) of the order product item |
245 | 245 | */ |
246 | - public function deleteProduct( $position ) |
|
246 | + public function deleteProduct($position) |
|
247 | 247 | { |
248 | - $product = $this->get()->getProduct( $position ); |
|
248 | + $product = $this->get()->getProduct($position); |
|
249 | 249 | |
250 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
250 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
251 | 251 | { |
252 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually' ); |
|
253 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) ); |
|
252 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually'); |
|
253 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position)); |
|
254 | 254 | } |
255 | 255 | |
256 | - $this->get()->deleteProduct( $position ); |
|
256 | + $this->get()->deleteProduct($position); |
|
257 | 257 | $this->save(); |
258 | 258 | } |
259 | 259 | |
@@ -265,32 +265,32 @@ discard block |
||
265 | 265 | * @param integer $quantity New quantiy of the product item |
266 | 266 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
267 | 267 | */ |
268 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ) |
|
268 | + public function editProduct($position, $quantity, array $configAttributeCodes = []) |
|
269 | 269 | { |
270 | - $product = $this->get()->getProduct( $position ); |
|
270 | + $product = $this->get()->getProduct($position); |
|
271 | 271 | |
272 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
272 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
273 | 273 | { |
274 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be changed' ); |
|
275 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) ); |
|
274 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be changed'); |
|
275 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position)); |
|
276 | 276 | } |
277 | 277 | |
278 | - $product->setQuantity( $quantity ); |
|
278 | + $product->setQuantity($quantity); |
|
279 | 279 | |
280 | 280 | $attributes = $product->getAttributes(); |
281 | - foreach( $attributes as $key => $attribute ) |
|
281 | + foreach ($attributes as $key => $attribute) |
|
282 | 282 | { |
283 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
284 | - unset( $attributes[$key] ); |
|
283 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
284 | + unset($attributes[$key]); |
|
285 | 285 | } |
286 | 286 | } |
287 | - $product->setAttributes( $attributes ); |
|
287 | + $product->setAttributes($attributes); |
|
288 | 288 | |
289 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
290 | - $productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ), true ); |
|
291 | - $product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) ); |
|
289 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
290 | + $productItem = $manager->findItem($product->getProductCode(), array('price', 'text'), true); |
|
291 | + $product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity)); |
|
292 | 292 | |
293 | - $this->get()->editProduct( $product, $position ); |
|
293 | + $this->get()->editProduct($product, $position); |
|
294 | 294 | |
295 | 295 | $this->save(); |
296 | 296 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string $code Coupon code entered by the user |
303 | 303 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
304 | 304 | */ |
305 | - public function addCoupon( $code ) |
|
305 | + public function addCoupon($code) |
|
306 | 306 | { |
307 | 307 | $context = $this->getContext(); |
308 | 308 | |
@@ -322,39 +322,39 @@ discard block |
||
322 | 322 | * @category User |
323 | 323 | * @category Developer |
324 | 324 | */ |
325 | - $allowed = $context->getConfig()->get( 'controller/frontend/basket/standard/coupon/allowed', 1 ); |
|
325 | + $allowed = $context->getConfig()->get('controller/frontend/basket/standard/coupon/allowed', 1); |
|
326 | 326 | |
327 | - if( $allowed <= count( $this->get()->getCoupons() ) ) |
|
327 | + if ($allowed <= count($this->get()->getCoupons())) |
|
328 | 328 | { |
329 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Number of coupon codes exceeds the limit' ); |
|
330 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
329 | + $msg = $context->getI18n()->dt('controller/frontend', 'Number of coupon codes exceeds the limit'); |
|
330 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
334 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' ); |
|
334 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'coupon'); |
|
335 | 335 | |
336 | 336 | $search = $manager->createSearch(); |
337 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
338 | - $search->setSlice( 0, 1 ); |
|
337 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
338 | + $search->setSlice(0, 1); |
|
339 | 339 | |
340 | - $result = $manager->searchItems( $search ); |
|
340 | + $result = $manager->searchItems($search); |
|
341 | 341 | |
342 | - if( ( $item = reset( $result ) ) === false ) |
|
342 | + if (($item = reset($result)) === false) |
|
343 | 343 | { |
344 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid or not available any more' ), $code ); |
|
345 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
344 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid or not available any more'), $code); |
|
345 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
349 | - $provider = $manager->getProvider( $item, $code ); |
|
349 | + $provider = $manager->getProvider($item, $code); |
|
350 | 350 | |
351 | - if( $provider->isAvailable( $this->get() ) !== true ) |
|
351 | + if ($provider->isAvailable($this->get()) !== true) |
|
352 | 352 | { |
353 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met' ), $code ); |
|
354 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
353 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met'), $code); |
|
354 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
355 | 355 | } |
356 | 356 | |
357 | - $provider->addCoupon( $this->get() ); |
|
357 | + $provider->addCoupon($this->get()); |
|
358 | 358 | $this->save(); |
359 | 359 | } |
360 | 360 | |
@@ -365,24 +365,24 @@ discard block |
||
365 | 365 | * @param string $code Coupon code entered by the user |
366 | 366 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
367 | 367 | */ |
368 | - public function deleteCoupon( $code ) |
|
368 | + public function deleteCoupon($code) |
|
369 | 369 | { |
370 | 370 | $context = $this->getContext(); |
371 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' ); |
|
371 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'coupon'); |
|
372 | 372 | |
373 | 373 | $search = $manager->createSearch(); |
374 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
375 | - $search->setSlice( 0, 1 ); |
|
374 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
375 | + $search->setSlice(0, 1); |
|
376 | 376 | |
377 | - $result = $manager->searchItems( $search ); |
|
377 | + $result = $manager->searchItems($search); |
|
378 | 378 | |
379 | - if( ( $item = reset( $result ) ) === false ) |
|
379 | + if (($item = reset($result)) === false) |
|
380 | 380 | { |
381 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid' ); |
|
382 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $code ) ); |
|
381 | + $msg = $context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid'); |
|
382 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $code)); |
|
383 | 383 | } |
384 | 384 | |
385 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
385 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
386 | 386 | $this->save(); |
387 | 387 | } |
388 | 388 | |
@@ -395,30 +395,30 @@ discard block |
||
395 | 395 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
396 | 396 | * if one of the keys is invalid when using an array with key/value pairs |
397 | 397 | */ |
398 | - public function setAddress( $type, $value ) |
|
398 | + public function setAddress($type, $value) |
|
399 | 399 | { |
400 | 400 | $context = $this->getContext(); |
401 | - $address = \Aimeos\MShop\Factory::createManager( $context, 'order/base/address' )->createItem(); |
|
402 | - $address->setType( $type ); |
|
401 | + $address = \Aimeos\MShop\Factory::createManager($context, 'order/base/address')->createItem(); |
|
402 | + $address->setType($type); |
|
403 | 403 | |
404 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
404 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
405 | 405 | { |
406 | - $address->copyFrom( $value ); |
|
407 | - $this->get()->setAddress( $address, $type ); |
|
406 | + $address->copyFrom($value); |
|
407 | + $this->get()->setAddress($address, $type); |
|
408 | 408 | } |
409 | - else if( is_array( $value ) ) |
|
409 | + else if (is_array($value)) |
|
410 | 410 | { |
411 | - $this->setAddressFromArray( $address, $value ); |
|
412 | - $this->get()->setAddress( $address, $type ); |
|
411 | + $this->setAddressFromArray($address, $value); |
|
412 | + $this->get()->setAddress($address, $type); |
|
413 | 413 | } |
414 | - else if( $value === null ) |
|
414 | + else if ($value === null) |
|
415 | 415 | { |
416 | - $this->get()->deleteAddress( $type ); |
|
416 | + $this->get()->deleteAddress($type); |
|
417 | 417 | } |
418 | 418 | else |
419 | 419 | { |
420 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' ); |
|
421 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) ); |
|
420 | + $msg = $context->getI18n()->dt('controller/frontend', 'Invalid value for address type "%1$s"'); |
|
421 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $type)); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | $this->save(); |
@@ -434,42 +434,42 @@ discard block |
||
434 | 434 | * entered by the customer when choosing one of the delivery or payment options |
435 | 435 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
436 | 436 | */ |
437 | - public function addService( $type, $id, array $attributes = [] ) |
|
437 | + public function addService($type, $id, array $attributes = []) |
|
438 | 438 | { |
439 | 439 | $context = $this->getContext(); |
440 | 440 | |
441 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
442 | - $serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) ); |
|
441 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
442 | + $serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text')); |
|
443 | 443 | |
444 | - $provider = $serviceManager->getProvider( $serviceItem, $serviceItem->getType() ); |
|
445 | - $result = $provider->checkConfigFE( $attributes ); |
|
446 | - $unknown = array_diff_key( $attributes, $result ); |
|
444 | + $provider = $serviceManager->getProvider($serviceItem, $serviceItem->getType()); |
|
445 | + $result = $provider->checkConfigFE($attributes); |
|
446 | + $unknown = array_diff_key($attributes, $result); |
|
447 | 447 | |
448 | - if( count( $unknown ) > 0 ) |
|
448 | + if (count($unknown) > 0) |
|
449 | 449 | { |
450 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Unknown attributes "%1$s"' ); |
|
451 | - $msg = sprintf( $msg, implode( '","', array_keys( $unknown ) ) ); |
|
452 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
450 | + $msg = $context->getI18n()->dt('controller/frontend', 'Unknown attributes "%1$s"'); |
|
451 | + $msg = sprintf($msg, implode('","', array_keys($unknown))); |
|
452 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
453 | 453 | } |
454 | 454 | |
455 | - foreach( $result as $key => $value ) |
|
455 | + foreach ($result as $key => $value) |
|
456 | 456 | { |
457 | - if( $value !== null ) { |
|
458 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
457 | + if ($value !== null) { |
|
458 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
462 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
462 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
463 | 463 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
464 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
464 | + $orderServiceItem->copyFrom($serviceItem); |
|
465 | 465 | |
466 | 466 | // remove service rebate of original price |
467 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
468 | - $orderServiceItem->setPrice( $price ); |
|
467 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
468 | + $orderServiceItem->setPrice($price); |
|
469 | 469 | |
470 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
470 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
471 | 471 | |
472 | - $this->get()->addService( $orderServiceItem, $type ); |
|
472 | + $this->get()->addService($orderServiceItem, $type); |
|
473 | 473 | $this->save(); |
474 | 474 | } |
475 | 475 | |
@@ -479,9 +479,9 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @param string $type Service type code like 'payment' or 'delivery' |
481 | 481 | */ |
482 | - public function deleteService( $type ) |
|
482 | + public function deleteService($type) |
|
483 | 483 | { |
484 | - $this->get()->deleteService( $type ); |
|
484 | + $this->get()->deleteService($type); |
|
485 | 485 | $this->save(); |
486 | 486 | } |
487 | 487 | |
@@ -494,18 +494,18 @@ discard block |
||
494 | 494 | * an address item. |
495 | 495 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
496 | 496 | */ |
497 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
497 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
498 | 498 | { |
499 | - foreach( $map as $key => $value ) { |
|
500 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
499 | + foreach ($map as $key => $value) { |
|
500 | + $map[$key] = strip_tags($value); // prevent XSS |
|
501 | 501 | } |
502 | 502 | |
503 | - $errors = $address->fromArray( $map ); |
|
503 | + $errors = $address->fromArray($map); |
|
504 | 504 | |
505 | - if( count( $errors ) > 0 ) |
|
505 | + if (count($errors) > 0) |
|
506 | 506 | { |
507 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Invalid address properties, please check your input' ); |
|
508 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
507 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Invalid address properties, please check your input'); |
|
508 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
509 | 509 | } |
510 | 510 | } |
511 | 511 | } |
@@ -150,7 +150,6 @@ |
||
150 | 150 | * Adds the delivery/payment service item based on the service ID. |
151 | 151 | * |
152 | 152 | * @param string $type Service type code like 'payment' or 'delivery' |
153 | - * @param string $id|null Unique ID of the service item or null to remove it |
|
154 | 153 | * @param array $attributes Associative list of key/value pairs containing the attributes selected or |
155 | 154 | * entered by the customer when choosing one of the delivery or payment options |
156 | 155 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param string $type Basket type |
51 | 51 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
52 | 52 | */ |
53 | - public function setType( $type ); |
|
53 | + public function setType($type); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param boolean $default True to add default criteria (user logged in), false if not |
70 | 70 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
71 | 71 | */ |
72 | - public function load( $id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true ); |
|
72 | + public function load($id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | /** |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
92 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ); |
|
91 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
92 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []); |
|
93 | 93 | |
94 | 94 | |
95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param integer $position Position number (key) of the order product item |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function deleteProduct( $position ); |
|
101 | + public function deleteProduct($position); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
110 | 110 | * @return void |
111 | 111 | */ |
112 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ); |
|
112 | + public function editProduct($position, $quantity, array $configAttributeCodes = []); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function addCoupon( $code ); |
|
122 | + public function addCoupon($code); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
130 | 130 | * @return void |
131 | 131 | */ |
132 | - public function deleteCoupon( $code ); |
|
132 | + public function deleteCoupon($code); |
|
133 | 133 | |
134 | 134 | |
135 | 135 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * if one of the keys is invalid when using an array with key/value pairs |
142 | 142 | * @return void |
143 | 143 | */ |
144 | - public function setAddress( $type, $value ); |
|
144 | + public function setAddress($type, $value); |
|
145 | 145 | |
146 | 146 | |
147 | 147 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * entered by the customer when choosing one of the delivery or payment options |
154 | 154 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
155 | 155 | */ |
156 | - public function addService( $type, $id, array $attributes = [] ); |
|
156 | + public function addService($type, $id, array $attributes = []); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
@@ -161,5 +161,5 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @param string $type Service type code like 'payment' or 'delivery' |
163 | 163 | */ |
164 | - public function deleteService( $type ); |
|
164 | + public function deleteService($type); |
|
165 | 165 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Empties the basket and removing all products, addresses, services, etc. |
64 | - * @return void |
|
64 | + * @return Base |
|
65 | 65 | */ |
66 | 66 | public function clear() |
67 | 67 | { |
@@ -134,11 +134,6 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param string $prodid ID of the base product to add |
136 | 136 | * @param integer $quantity Amount of products that should by added |
137 | - * @param array $options Possible options are: 'stock'=>true|false and 'variant'=>true|false |
|
138 | - * The 'stock'=>false option allows adding products without being in stock. |
|
139 | - * The 'variant'=>false option allows adding the selection product to the basket |
|
140 | - * instead of the specific sub-product if the variant-building attribute IDs |
|
141 | - * doesn't match a specific sub-product or if the attribute IDs are missing. |
|
142 | 137 | * @param array $variantAttributeIds List of variant-building attribute IDs that identify a specific product |
143 | 138 | * in a selection products |
144 | 139 | * @param array $configAttributeIds List of attribute IDs that doesn't identify a specific product in a |
@@ -257,7 +252,7 @@ discard block |
||
257 | 252 | /** |
258 | 253 | * Returns the frontend controller |
259 | 254 | * |
260 | - * @return \Aimeos\Controller\Frontend\Basket\Iface Frontend controller object |
|
255 | + * @return \Aimeos\Controller\Frontend\Iface Frontend controller object |
|
261 | 256 | */ |
262 | 257 | protected function getController() |
263 | 258 | { |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | * @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
32 | 32 | */ |
33 | - public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
33 | + public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context) |
|
34 | 34 | { |
35 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Frontend\\Basket\\Iface', $controller ); |
|
35 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Frontend\\Basket\\Iface', $controller); |
|
36 | 36 | |
37 | 37 | $this->controller = $controller; |
38 | 38 | |
39 | - parent::__construct( $context ); |
|
39 | + parent::__construct($context); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @return mixed Returns the value of the called method |
49 | 49 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
50 | 50 | */ |
51 | - public function __call( $name, array $param ) |
|
51 | + public function __call($name, array $param) |
|
52 | 52 | { |
53 | - return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
53 | + return @call_user_func_array(array($this->controller, $name), $param); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * @param string $type Basket type |
93 | 93 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
94 | 94 | */ |
95 | - public function setType( $type ) |
|
95 | + public function setType($type) |
|
96 | 96 | { |
97 | - $this->controller->setType( $type ); |
|
97 | + $this->controller->setType($type); |
|
98 | 98 | return $this; |
99 | 99 | } |
100 | 100 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * @param boolean $default True to add default criteria (user logged in), false if not |
119 | 119 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
120 | 120 | */ |
121 | - public function load( $id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true ) |
|
121 | + public function load($id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true) |
|
122 | 122 | { |
123 | - return $this->controller->load( $id, $parts, $default ); |
|
123 | + return $this->controller->load($id, $parts, $default); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
146 | 146 | * @return void |
147 | 147 | */ |
148 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
149 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
148 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
149 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
150 | 150 | { |
151 | 151 | $this->controller->addProduct( |
152 | 152 | $prodid, $quantity, $stocktype, $variantAttributeIds, |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param integer $position Position number (key) of the order product item |
162 | 162 | * @return void |
163 | 163 | */ |
164 | - public function deleteProduct( $position ) |
|
164 | + public function deleteProduct($position) |
|
165 | 165 | { |
166 | - $this->controller->deleteProduct( $position ); |
|
166 | + $this->controller->deleteProduct($position); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
176 | 176 | * @return void |
177 | 177 | */ |
178 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ) |
|
178 | + public function editProduct($position, $quantity, array $configAttributeCodes = []) |
|
179 | 179 | { |
180 | - $this->controller->editProduct( $position, $quantity, $configAttributeCodes ); |
|
180 | + $this->controller->editProduct($position, $quantity, $configAttributeCodes); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
189 | 189 | * @return void |
190 | 190 | */ |
191 | - public function addCoupon( $code ) |
|
191 | + public function addCoupon($code) |
|
192 | 192 | { |
193 | - $this->controller->addCoupon( $code ); |
|
193 | + $this->controller->addCoupon($code); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
202 | 202 | * @return void |
203 | 203 | */ |
204 | - public function deleteCoupon( $code ) |
|
204 | + public function deleteCoupon($code) |
|
205 | 205 | { |
206 | - $this->controller->deleteCoupon( $code ); |
|
206 | + $this->controller->deleteCoupon($code); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * if one of the keys is invalid when using an array with key/value pairs |
217 | 217 | * @return void |
218 | 218 | */ |
219 | - public function setAddress( $type, $value ) |
|
219 | + public function setAddress($type, $value) |
|
220 | 220 | { |
221 | - $this->controller->setAddress( $type, $value ); |
|
221 | + $this->controller->setAddress($type, $value); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
233 | 233 | * @return void |
234 | 234 | */ |
235 | - public function addService( $type, $id, array $attributes = [] ) |
|
235 | + public function addService($type, $id, array $attributes = []) |
|
236 | 236 | { |
237 | - $this->controller->addService( $type, $id, $attributes ); |
|
237 | + $this->controller->addService($type, $id, $attributes); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @param string $type Service type code like 'payment' or 'delivery' |
245 | 245 | */ |
246 | - public function deleteService( $type ) |
|
246 | + public function deleteService($type) |
|
247 | 247 | { |
248 | - $this->controller->deleteService( $type ); |
|
248 | + $this->controller->deleteService($type); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 |
@@ -19,219 +19,219 @@ |
||
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | 21 | $this->context = \TestHelperFrontend::getContext(); |
22 | - $this->testItem = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
22 | + $this->testItem = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
23 | 23 | |
24 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
25 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Select( $object, $this->context ); |
|
24 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
25 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Select($object, $this->context); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | protected function tearDown() |
30 | 30 | { |
31 | 31 | $this->object->clear(); |
32 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
32 | + $this->context->getSession()->set('aimeos', []); |
|
33 | 33 | |
34 | - unset( $this->object ); |
|
34 | + unset($this->object); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testAddDeleteProduct() |
39 | 39 | { |
40 | 40 | $basket = $this->object->get(); |
41 | - $this->object->addProduct( $this->testItem->getId(), 2 ); |
|
41 | + $this->object->addProduct($this->testItem->getId(), 2); |
|
42 | 42 | |
43 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
44 | - $this->assertEquals( 2, $basket->getProduct( 0 )->getQuantity() ); |
|
45 | - $this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() ); |
|
43 | + $this->assertEquals(1, count($basket->getProducts())); |
|
44 | + $this->assertEquals(2, $basket->getProduct(0)->getQuantity()); |
|
45 | + $this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode()); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | 49 | public function testAddProductNoSelection() |
50 | 50 | { |
51 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
51 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
52 | 52 | |
53 | - $this->object->addProduct( $item->getId(), 1 ); |
|
53 | + $this->object->addProduct($item->getId(), 1); |
|
54 | 54 | |
55 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
56 | - $this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
57 | - $this->assertEquals( 0, count( $this->object->get()->getProduct( 0 )->getProducts() ) ); |
|
55 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
56 | + $this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode()); |
|
57 | + $this->assertEquals(0, count($this->object->get()->getProduct(0)->getProducts())); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | public function testAddProductVariant() |
62 | 62 | { |
63 | - $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
63 | + $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
64 | 64 | |
65 | 65 | $search = $attributeManager->createSearch(); |
66 | - $search->setConditions( $search->compare( '==', 'attribute.code', array( 'xs', 'white' ) ) ); |
|
66 | + $search->setConditions($search->compare('==', 'attribute.code', array('xs', 'white'))); |
|
67 | 67 | |
68 | - $attributes = $attributeManager->searchItems( $search ); |
|
68 | + $attributes = $attributeManager->searchItems($search); |
|
69 | 69 | |
70 | - if( count( $attributes ) === 0 ) { |
|
71 | - throw new \RuntimeException( 'Attributes not found' ); |
|
70 | + if (count($attributes) === 0) { |
|
71 | + throw new \RuntimeException('Attributes not found'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
75 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
76 | 76 | |
77 | - $this->object->addProduct( $item->getId(), 1, 'default', array_keys( $attributes ), [], [], [] ); |
|
77 | + $this->object->addProduct($item->getId(), 1, 'default', array_keys($attributes), [], [], []); |
|
78 | 78 | |
79 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
80 | - $this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
79 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
80 | + $this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | 84 | public function testAddProductVariantIncomplete() |
85 | 85 | { |
86 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
86 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
87 | 87 | |
88 | 88 | $search = $attributeManager->createSearch(); |
89 | 89 | $expr = array( |
90 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
91 | - $search->compare( '==', 'attribute.code', '30' ), |
|
92 | - $search->compare( '==', 'attribute.type.code', 'length' ), |
|
90 | + $search->compare('==', 'attribute.domain', 'product'), |
|
91 | + $search->compare('==', 'attribute.code', '30'), |
|
92 | + $search->compare('==', 'attribute.type.code', 'length'), |
|
93 | 93 | ); |
94 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
94 | + $search->setConditions($search->combine('&&', $expr)); |
|
95 | 95 | |
96 | - $attributes = $attributeManager->searchItems( $search ); |
|
96 | + $attributes = $attributeManager->searchItems($search); |
|
97 | 97 | |
98 | - if( count( $attributes ) === 0 ) { |
|
99 | - throw new \RuntimeException( 'Attributes not found' ); |
|
98 | + if (count($attributes) === 0) { |
|
99 | + throw new \RuntimeException('Attributes not found'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' ); |
|
103 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST'); |
|
104 | 104 | |
105 | - $this->object->addProduct( $item->getId(), 1, 'default', array_keys( $attributes ) ); |
|
105 | + $this->object->addProduct($item->getId(), 1, 'default', array_keys($attributes)); |
|
106 | 106 | |
107 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
108 | - $this->assertEquals( 'U:TESTSUB02', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
109 | - $this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getAttributes() ) ); |
|
107 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
108 | + $this->assertEquals('U:TESTSUB02', $this->object->get()->getProduct(0)->getProductCode()); |
|
109 | + $this->assertEquals(2, count($this->object->get()->getProduct(0)->getAttributes())); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | 113 | public function testAddProductVariantNonUnique() |
114 | 114 | { |
115 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
115 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
116 | 116 | |
117 | 117 | $search = $attributeManager->createSearch(); |
118 | 118 | $expr = array( |
119 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
120 | - $search->compare( '==', 'attribute.code', '30' ), |
|
121 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
119 | + $search->compare('==', 'attribute.domain', 'product'), |
|
120 | + $search->compare('==', 'attribute.code', '30'), |
|
121 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
122 | 122 | ); |
123 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
123 | + $search->setConditions($search->combine('&&', $expr)); |
|
124 | 124 | |
125 | - $attributes = $attributeManager->searchItems( $search ); |
|
125 | + $attributes = $attributeManager->searchItems($search); |
|
126 | 126 | |
127 | - if( count( $attributes ) === 0 ) { |
|
128 | - throw new \RuntimeException( 'Attributes not found' ); |
|
127 | + if (count($attributes) === 0) { |
|
128 | + throw new \RuntimeException('Attributes not found'); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' ); |
|
132 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST'); |
|
133 | 133 | |
134 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
135 | - $this->object->addProduct( $item->getId(), 1, 'default', array_keys( $attributes ) ); |
|
134 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
135 | + $this->object->addProduct($item->getId(), 1, 'default', array_keys($attributes)); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
139 | 139 | public function testAddProductVariantNotRequired() |
140 | 140 | { |
141 | - $this->context->getConfig()->set( 'controller/frontend/basket/require-variant', false ); |
|
141 | + $this->context->getConfig()->set('controller/frontend/basket/require-variant', false); |
|
142 | 142 | |
143 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
143 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
144 | 144 | |
145 | 145 | $search = $attributeManager->createSearch(); |
146 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) ); |
|
146 | + $search->setConditions($search->compare('==', 'attribute.code', 'xs')); |
|
147 | 147 | |
148 | - $attributes = $attributeManager->searchItems( $search ); |
|
148 | + $attributes = $attributeManager->searchItems($search); |
|
149 | 149 | |
150 | - if( count( $attributes ) === 0 ) { |
|
151 | - throw new \RuntimeException( 'Attribute not found' ); |
|
150 | + if (count($attributes) === 0) { |
|
151 | + throw new \RuntimeException('Attribute not found'); |
|
152 | 152 | } |
153 | 153 | |
154 | - $options = array( 'variant' => false ); |
|
154 | + $options = array('variant' => false); |
|
155 | 155 | |
156 | - $this->object->addProduct( $this->testItem->getId(), 1, 'default', array_keys( $attributes ) ); |
|
156 | + $this->object->addProduct($this->testItem->getId(), 1, 'default', array_keys($attributes)); |
|
157 | 157 | |
158 | - $this->assertEquals( 1, count( $this->object->get()->getProducts() ) ); |
|
159 | - $this->assertEquals( 'U:TESTP', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
158 | + $this->assertEquals(1, count($this->object->get()->getProducts())); |
|
159 | + $this->assertEquals('U:TESTP', $this->object->get()->getProduct(0)->getProductCode()); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | 163 | public function testAddProductEmptySelectionException() |
164 | 164 | { |
165 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:noSel' ); |
|
165 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:noSel'); |
|
166 | 166 | |
167 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
168 | - $this->object->addProduct( $item->getId(), 1 ); |
|
167 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
168 | + $this->object->addProduct($item->getId(), 1); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | 172 | public function testAddProductSelectionWithPricelessItem() |
173 | 173 | { |
174 | - $this->object->addProduct( $this->testItem->getId(), 1 ); |
|
174 | + $this->object->addProduct($this->testItem->getId(), 1); |
|
175 | 175 | |
176 | - $this->assertEquals( 'U:TESTPSUB01', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
176 | + $this->assertEquals('U:TESTPSUB01', $this->object->get()->getProduct(0)->getProductCode()); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
180 | 180 | public function testAddProductConfigAttribute() |
181 | 181 | { |
182 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
182 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
183 | 183 | |
184 | 184 | $search = $attributeManager->createSearch(); |
185 | - $search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) ); |
|
185 | + $search->setConditions($search->compare('==', 'attribute.code', 'xs')); |
|
186 | 186 | |
187 | - $attributes = $attributeManager->searchItems( $search ); |
|
187 | + $attributes = $attributeManager->searchItems($search); |
|
188 | 188 | |
189 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
190 | - throw new \RuntimeException( 'Attribute not found' ); |
|
189 | + if (($attribute = reset($attributes)) === false) { |
|
190 | + throw new \RuntimeException('Attribute not found'); |
|
191 | 191 | } |
192 | 192 | |
193 | - $this->object->addProduct( $this->testItem->getId(), 1, 'default', [], [$attribute->getId() => 1] ); |
|
193 | + $this->object->addProduct($this->testItem->getId(), 1, 'default', [], [$attribute->getId() => 1]); |
|
194 | 194 | $basket = $this->object->get(); |
195 | 195 | |
196 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
197 | - $this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() ); |
|
198 | - $this->assertEquals( 'xs', $basket->getProduct( 0 )->getAttribute( 'size', 'config' ) ); |
|
196 | + $this->assertEquals(1, count($basket->getProducts())); |
|
197 | + $this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode()); |
|
198 | + $this->assertEquals('xs', $basket->getProduct(0)->getAttribute('size', 'config')); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
202 | 202 | public function testAddProductHiddenAttribute() |
203 | 203 | { |
204 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
204 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
205 | 205 | |
206 | 206 | $search = $attributeManager->createSearch(); |
207 | 207 | $expr = array( |
208 | - $search->compare( '==', 'attribute.code', '29' ), |
|
209 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
208 | + $search->compare('==', 'attribute.code', '29'), |
|
209 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
210 | 210 | ); |
211 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
211 | + $search->setConditions($search->combine('&&', $expr)); |
|
212 | 212 | |
213 | - $attributes = $attributeManager->searchItems( $search ); |
|
213 | + $attributes = $attributeManager->searchItems($search); |
|
214 | 214 | |
215 | - if( empty( $attributes ) ) { |
|
216 | - throw new \RuntimeException( 'Attribute not found' ); |
|
215 | + if (empty($attributes)) { |
|
216 | + throw new \RuntimeException('Attribute not found'); |
|
217 | 217 | } |
218 | 218 | |
219 | - $this->object->addProduct( $this->testItem->getId(), 1, 'default', [], [], array_keys( $attributes ) ); |
|
219 | + $this->object->addProduct($this->testItem->getId(), 1, 'default', [], [], array_keys($attributes)); |
|
220 | 220 | |
221 | 221 | $basket = $this->object->get(); |
222 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
222 | + $this->assertEquals(1, count($basket->getProducts())); |
|
223 | 223 | |
224 | - $product = $basket->getProduct( 0 ); |
|
225 | - $this->assertEquals( 'U:TESTPSUB01', $product->getProductCode() ); |
|
224 | + $product = $basket->getProduct(0); |
|
225 | + $this->assertEquals('U:TESTPSUB01', $product->getProductCode()); |
|
226 | 226 | |
227 | 227 | $attributes = $product->getAttributes(); |
228 | - $this->assertEquals( 1, count( $attributes ) ); |
|
228 | + $this->assertEquals(1, count($attributes)); |
|
229 | 229 | |
230 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
231 | - throw new \RuntimeException( 'No attribute' ); |
|
230 | + if (($attribute = reset($attributes)) === false) { |
|
231 | + throw new \RuntimeException('No attribute'); |
|
232 | 232 | } |
233 | 233 | |
234 | - $this->assertEquals( 'hidden', $attribute->getType() ); |
|
235 | - $this->assertEquals( '29', $product->getAttribute( 'width', 'hidden' ) ); |
|
234 | + $this->assertEquals('hidden', $attribute->getType()); |
|
235 | + $this->assertEquals('29', $product->getAttribute('width', 'hidden')); |
|
236 | 236 | } |
237 | 237 | } |
@@ -233,8 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | $this->setAddress( $type, $item->toArray() ); |
235 | 235 | $basket->deleteAddress( $type ); |
236 | - } |
|
237 | - catch( \Exception $e ) |
|
236 | + } catch( \Exception $e ) |
|
238 | 237 | { |
239 | 238 | $logger = $this->getContext()->getLogger(); |
240 | 239 | $errors['address'][$type] = $e->getMessage(); |
@@ -264,8 +263,7 @@ discard block |
||
264 | 263 | { |
265 | 264 | $this->addCoupon( $code ); |
266 | 265 | $basket->deleteCoupon( $code, true ); |
267 | - } |
|
268 | - catch( \Exception $e ) |
|
266 | + } catch( \Exception $e ) |
|
269 | 267 | { |
270 | 268 | $logger = $this->getContext()->getLogger(); |
271 | 269 | $errors['coupon'][$code] = $e->getMessage(); |
@@ -314,8 +312,7 @@ discard block |
||
314 | 312 | ); |
315 | 313 | |
316 | 314 | $basket->deleteProduct( $pos ); |
317 | - } |
|
318 | - catch( \Exception $e ) |
|
315 | + } catch( \Exception $e ) |
|
319 | 316 | { |
320 | 317 | $code = $product->getProductCode(); |
321 | 318 | $logger = $this->getContext()->getLogger(); |
@@ -353,8 +350,7 @@ discard block |
||
353 | 350 | |
354 | 351 | $this->addService( $type, $item->getServiceId(), $attributes ); |
355 | 352 | $basket->deleteService( $type ); |
356 | - } |
|
357 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
353 | + } catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
358 | 354 | } |
359 | 355 | } |
360 | 356 |
@@ -31,52 +31,52 @@ discard block |
||
31 | 31 | * @param integer $quantity New product quantity |
32 | 32 | * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price |
33 | 33 | */ |
34 | - protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity ) |
|
34 | + protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity) |
|
35 | 35 | { |
36 | 36 | $context = $this->getContext(); |
37 | 37 | |
38 | - if( empty( $prices ) ) |
|
38 | + if (empty($prices)) |
|
39 | 39 | { |
40 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
41 | - $prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' ); |
|
40 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
41 | + $prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
46 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
45 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
46 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
47 | 47 | |
48 | 48 | // customers can pay what they would like to pay |
49 | - if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null ) |
|
49 | + if (($attr = $product->getAttributeItem('price', 'custom')) !== null) |
|
50 | 50 | { |
51 | 51 | $amount = $attr->getValue(); |
52 | 52 | |
53 | - if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 ) |
|
53 | + if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01) |
|
54 | 54 | { |
55 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid price value "%1$s"' ); |
|
56 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $amount ) ); |
|
55 | + $msg = $context->getI18n()->dt('controller/frontend', 'Invalid price value "%1$s"'); |
|
56 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $amount)); |
|
57 | 57 | } |
58 | 58 | |
59 | - $price->setValue( $amount ); |
|
59 | + $price->setValue($amount); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $orderAttributes = $product->getAttributes(); |
63 | - $attrItems = $this->getAttributeItems( $orderAttributes ); |
|
63 | + $attrItems = $this->getAttributeItems($orderAttributes); |
|
64 | 64 | |
65 | 65 | // add prices of (optional) attributes |
66 | - foreach( $orderAttributes as $orderAttrItem ) |
|
66 | + foreach ($orderAttributes as $orderAttrItem) |
|
67 | 67 | { |
68 | 68 | $attrId = $orderAttrItem->getAttributeId(); |
69 | 69 | |
70 | - if( isset( $attrItems[$attrId] ) |
|
71 | - && ( $prices = $attrItems[$attrId]->getRefItems( 'price', 'default' ) ) !== [] |
|
70 | + if (isset($attrItems[$attrId]) |
|
71 | + && ($prices = $attrItems[$attrId]->getRefItems('price', 'default')) !== [] |
|
72 | 72 | ) { |
73 | - $attrPrice = $priceManager->getLowestPrice( $prices, $orderAttrItem->getQuantity() ); |
|
74 | - $price->addItem( $attrPrice, $orderAttrItem->getQuantity() ); |
|
73 | + $attrPrice = $priceManager->getLowestPrice($prices, $orderAttrItem->getQuantity()); |
|
74 | + $price->addItem($attrPrice, $orderAttrItem->getQuantity()); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | 78 | // remove product rebate of original price in favor to rebates granted for the order |
79 | - $price->setRebate( '0.00' ); |
|
79 | + $price->setRebate('0.00'); |
|
80 | 80 | |
81 | 81 | return $price; |
82 | 82 | } |
@@ -90,43 +90,43 @@ discard block |
||
90 | 90 | * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values |
91 | 91 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
92 | 92 | */ |
93 | - protected function checkListRef( $prodId, $domain, array $refMap ) |
|
93 | + protected function checkListRef($prodId, $domain, array $refMap) |
|
94 | 94 | { |
95 | - if( empty( $refMap ) ) { |
|
95 | + if (empty($refMap)) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $context = $this->getContext(); |
100 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
101 | - $search = $productManager->createSearch( true ); |
|
100 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
101 | + $search = $productManager->createSearch(true); |
|
102 | 102 | |
103 | 103 | $expr = array( |
104 | - $search->compare( '==', 'product.id', $prodId ), |
|
104 | + $search->compare('==', 'product.id', $prodId), |
|
105 | 105 | $search->getConditions(), |
106 | 106 | ); |
107 | 107 | |
108 | - foreach( $refMap as $listType => $refIds ) |
|
108 | + foreach ($refMap as $listType => $refIds) |
|
109 | 109 | { |
110 | - if( empty( $refIds ) ) { |
|
110 | + if (empty($refIds)) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | - foreach( $refIds as $key => $refId ) { |
|
114 | + foreach ($refIds as $key => $refId) { |
|
115 | 115 | $refIds[$key] = (string) $refId; |
116 | 116 | } |
117 | 117 | |
118 | - $param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds ); |
|
119 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
118 | + $param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds); |
|
119 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
120 | 120 | |
121 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
121 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
122 | 122 | } |
123 | 123 | |
124 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
124 | + $search->setConditions($search->combine('&&', $expr)); |
|
125 | 125 | |
126 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
126 | + if (count($productManager->searchItems($search, [])) === 0) |
|
127 | 127 | { |
128 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid "%1$s" references for product with ID %2$s' ); |
|
129 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, json_encode( $prodId ) ) ); |
|
128 | + $msg = $context->getI18n()->dt('controller/frontend', 'Invalid "%1$s" references for product with ID %2$s'); |
|
129 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, json_encode($prodId))); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
@@ -137,40 +137,40 @@ discard block |
||
137 | 137 | * @param \Aimeos\MShop\Locale\Item\Iface $locale Locale object from current basket |
138 | 138 | * @param string $type Basket type |
139 | 139 | */ |
140 | - protected function checkLocale( \Aimeos\MShop\Locale\Item\Iface $locale, $type ) |
|
140 | + protected function checkLocale(\Aimeos\MShop\Locale\Item\Iface $locale, $type) |
|
141 | 141 | { |
142 | 142 | $errors = []; |
143 | 143 | $context = $this->getContext(); |
144 | 144 | $session = $context->getSession(); |
145 | 145 | |
146 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
146 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
147 | 147 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
148 | 148 | |
149 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
149 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
150 | 150 | { |
151 | - $locParts = explode( '|', $localeStr ); |
|
152 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
153 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
154 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
151 | + $locParts = explode('|', $localeStr); |
|
152 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
153 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
154 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
155 | 155 | |
156 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
157 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
156 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
157 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
158 | 158 | |
159 | 159 | $context = clone $context; |
160 | - $context->setLocale( $locale ); |
|
160 | + $context->setLocale($locale); |
|
161 | 161 | |
162 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
163 | - $basket = $manager->getSession( $type ); |
|
162 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
163 | + $basket = $manager->getSession($type); |
|
164 | 164 | |
165 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
166 | - $this->copyServices( $basket, $errors ); |
|
167 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
168 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
165 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
166 | + $this->copyServices($basket, $errors); |
|
167 | + $this->copyProducts($basket, $errors, $localeKey); |
|
168 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
169 | 169 | |
170 | - $manager->setSession( $basket, $type ); |
|
170 | + $manager->setSession($basket, $type); |
|
171 | 171 | } |
172 | 172 | |
173 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
173 | + $session->set('aimeos/basket/locale', $localeKey); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -182,22 +182,22 @@ discard block |
||
182 | 182 | * @param string $localeKey Unique identifier of the site, language and currency |
183 | 183 | * @return array Associative list of errors occured |
184 | 184 | */ |
185 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
185 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
186 | 186 | { |
187 | - foreach( $basket->getAddresses() as $type => $item ) |
|
187 | + foreach ($basket->getAddresses() as $type => $item) |
|
188 | 188 | { |
189 | 189 | try |
190 | 190 | { |
191 | - $this->setAddress( $type, $item->toArray() ); |
|
192 | - $basket->deleteAddress( $type ); |
|
191 | + $this->setAddress($type, $item->toArray()); |
|
192 | + $basket->deleteAddress($type); |
|
193 | 193 | } |
194 | - catch( \Exception $e ) |
|
194 | + catch (\Exception $e) |
|
195 | 195 | { |
196 | 196 | $logger = $this->getContext()->getLogger(); |
197 | 197 | $errors['address'][$type] = $e->getMessage(); |
198 | 198 | |
199 | 199 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
200 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
200 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
@@ -213,22 +213,22 @@ discard block |
||
213 | 213 | * @param string $localeKey Unique identifier of the site, language and currency |
214 | 214 | * @return array Associative list of errors occured |
215 | 215 | */ |
216 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
216 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
217 | 217 | { |
218 | - foreach( $basket->getCoupons() as $code => $list ) |
|
218 | + foreach ($basket->getCoupons() as $code => $list) |
|
219 | 219 | { |
220 | 220 | try |
221 | 221 | { |
222 | - $this->addCoupon( $code ); |
|
223 | - $basket->deleteCoupon( $code, true ); |
|
222 | + $this->addCoupon($code); |
|
223 | + $basket->deleteCoupon($code, true); |
|
224 | 224 | } |
225 | - catch( \Exception $e ) |
|
225 | + catch (\Exception $e) |
|
226 | 226 | { |
227 | 227 | $logger = $this->getContext()->getLogger(); |
228 | 228 | $errors['coupon'][$code] = $e->getMessage(); |
229 | 229 | |
230 | 230 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
231 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
231 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @param string $localeKey Unique identifier of the site, language and currency |
245 | 245 | * @return array Associative list of errors occured |
246 | 246 | */ |
247 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
247 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
248 | 248 | { |
249 | - foreach( $basket->getProducts() as $pos => $product ) |
|
249 | + foreach ($basket->getProducts() as $pos => $product) |
|
250 | 250 | { |
251 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
251 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
252 | 252 | continue; |
253 | 253 | } |
254 | 254 | |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | { |
257 | 257 | $variantIds = $configIds = $customIds = []; |
258 | 258 | |
259 | - foreach( $product->getAttributeItems() as $attrItem ) |
|
259 | + foreach ($product->getAttributeItems() as $attrItem) |
|
260 | 260 | { |
261 | - switch( $attrItem->getType() ) |
|
261 | + switch ($attrItem->getType()) |
|
262 | 262 | { |
263 | 263 | case 'variant': $variantIds[] = $attrItem->getAttributeId(); break; |
264 | 264 | case 'config': $configIds[$attrItem->getAttributeId()] = $attrItem->getQuantity(); break; |
@@ -271,16 +271,16 @@ discard block |
||
271 | 271 | $variantIds, $configIds, [], $customIds |
272 | 272 | ); |
273 | 273 | |
274 | - $basket->deleteProduct( $pos ); |
|
274 | + $basket->deleteProduct($pos); |
|
275 | 275 | } |
276 | - catch( \Exception $e ) |
|
276 | + catch (\Exception $e) |
|
277 | 277 | { |
278 | 278 | $code = $product->getProductCode(); |
279 | 279 | $logger = $this->getContext()->getLogger(); |
280 | 280 | $errors['product'][$pos] = $e->getMessage(); |
281 | 281 | |
282 | 282 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
283 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
283 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
@@ -295,24 +295,24 @@ discard block |
||
295 | 295 | * @param array $errors Associative list of previous errors |
296 | 296 | * @return array Associative list of errors occured |
297 | 297 | */ |
298 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
298 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
299 | 299 | { |
300 | - foreach( $basket->getServices() as $type => $list ) |
|
300 | + foreach ($basket->getServices() as $type => $list) |
|
301 | 301 | { |
302 | - foreach( $list as $item ) |
|
302 | + foreach ($list as $item) |
|
303 | 303 | { |
304 | 304 | try |
305 | 305 | { |
306 | 306 | $attributes = []; |
307 | 307 | |
308 | - foreach( $item->getAttributes() as $attrItem ) { |
|
308 | + foreach ($item->getAttributes() as $attrItem) { |
|
309 | 309 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
310 | 310 | } |
311 | 311 | |
312 | - $this->addService( $type, $item->getServiceId(), $attributes ); |
|
313 | - $basket->deleteService( $type ); |
|
312 | + $this->addService($type, $item->getServiceId(), $attributes); |
|
313 | + $basket->deleteService($type); |
|
314 | 314 | } |
315 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
315 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
@@ -325,28 +325,28 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object |
327 | 327 | */ |
328 | - protected function createSubscriptions( \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
328 | + protected function createSubscriptions(\Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
329 | 329 | { |
330 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'subscription' ); |
|
330 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'subscription'); |
|
331 | 331 | |
332 | - foreach( $basket->getProducts() as $orderProduct ) |
|
332 | + foreach ($basket->getProducts() as $orderProduct) |
|
333 | 333 | { |
334 | - if( ( $interval = $orderProduct->getAttribute( 'interval', 'config' ) ) !== null ) |
|
334 | + if (($interval = $orderProduct->getAttribute('interval', 'config')) !== null) |
|
335 | 335 | { |
336 | 336 | $item = $manager->createItem(); |
337 | - $item->setOrderBaseId( $basket->getId() ); |
|
338 | - $item->setOrderProductId( $orderProduct->getId() ); |
|
339 | - $item->setInterval( $interval ); |
|
340 | - $item->setStatus( 1 ); |
|
341 | - |
|
342 | - if( ( $end = $orderProduct->getAttribute( 'intervalend', 'custom' ) ) !== null |
|
343 | - || ( $end = $orderProduct->getAttribute( 'intervalend', 'config' ) ) !== null |
|
344 | - || ( $end = $orderProduct->getAttribute( 'intervalend', 'hidden' ) ) !== null |
|
337 | + $item->setOrderBaseId($basket->getId()); |
|
338 | + $item->setOrderProductId($orderProduct->getId()); |
|
339 | + $item->setInterval($interval); |
|
340 | + $item->setStatus(1); |
|
341 | + |
|
342 | + if (($end = $orderProduct->getAttribute('intervalend', 'custom')) !== null |
|
343 | + || ($end = $orderProduct->getAttribute('intervalend', 'config')) !== null |
|
344 | + || ($end = $orderProduct->getAttribute('intervalend', 'hidden')) !== null |
|
345 | 345 | ) { |
346 | - $item->setDateEnd( $end ); |
|
346 | + $item->setDateEnd($end); |
|
347 | 347 | } |
348 | 348 | |
349 | - $manager->saveItem( $item, false ); |
|
349 | + $manager->saveItem($item, false); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | } |
@@ -360,32 +360,32 @@ discard block |
||
360 | 360 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
361 | 361 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
362 | 362 | */ |
363 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
363 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
364 | 364 | { |
365 | - if( empty( $attributeIds ) ) { |
|
365 | + if (empty($attributeIds)) { |
|
366 | 366 | return []; |
367 | 367 | } |
368 | 368 | |
369 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
369 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
370 | 370 | |
371 | - $search = $attributeManager->createSearch( true ); |
|
371 | + $search = $attributeManager->createSearch(true); |
|
372 | 372 | $expr = array( |
373 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
373 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
374 | 374 | $search->getConditions(), |
375 | 375 | ); |
376 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
377 | - $search->setSlice( 0, 0x7fffffff ); |
|
376 | + $search->setConditions($search->combine('&&', $expr)); |
|
377 | + $search->setSlice(0, 0x7fffffff); |
|
378 | 378 | |
379 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
379 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
380 | 380 | |
381 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
381 | + if (count($attrItems) !== count($attributeIds)) |
|
382 | 382 | { |
383 | 383 | $i18n = $this->getContext()->getI18n(); |
384 | - $expected = implode( ',', $attributeIds ); |
|
385 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
386 | - $msg = $i18n->dt( 'controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"' ); |
|
384 | + $expected = implode(',', $attributeIds); |
|
385 | + $actual = implode(',', array_keys($attrItems)); |
|
386 | + $msg = $i18n->dt('controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"'); |
|
387 | 387 | |
388 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $actual, $expected ) ); |
|
388 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $actual, $expected)); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | return $attrItems; |
@@ -398,31 +398,31 @@ discard block |
||
398 | 398 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
399 | 399 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
400 | 400 | */ |
401 | - protected function getAttributeItems( array $orderAttributes ) |
|
401 | + protected function getAttributeItems(array $orderAttributes) |
|
402 | 402 | { |
403 | - if( empty( $orderAttributes ) ) { |
|
403 | + if (empty($orderAttributes)) { |
|
404 | 404 | return []; |
405 | 405 | } |
406 | 406 | |
407 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
408 | - $search = $attributeManager->createSearch( true ); |
|
407 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
408 | + $search = $attributeManager->createSearch(true); |
|
409 | 409 | $expr = []; |
410 | 410 | |
411 | - foreach( $orderAttributes as $item ) |
|
411 | + foreach ($orderAttributes as $item) |
|
412 | 412 | { |
413 | 413 | $tmp = array( |
414 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
415 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
416 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
417 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
418 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
414 | + $search->compare('==', 'attribute.domain', 'product'), |
|
415 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
416 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
417 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
418 | + $search->compare('>', 'attribute.type.status', 0), |
|
419 | 419 | $search->getConditions(), |
420 | 420 | ); |
421 | - $expr[] = $search->combine( '&&', $tmp ); |
|
421 | + $expr[] = $search->combine('&&', $tmp); |
|
422 | 422 | } |
423 | 423 | |
424 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
425 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
424 | + $search->setConditions($search->combine('||', $expr)); |
|
425 | + return $attributeManager->searchItems($search, array('price')); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -435,24 +435,24 @@ discard block |
||
435 | 435 | * @param array $quantities Associative list of attribute IDs as keys and their quantities as values |
436 | 436 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
437 | 437 | */ |
438 | - protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] ) |
|
438 | + protected function getOrderProductAttributes($type, array $ids, array $values = [], array $quantities = []) |
|
439 | 439 | { |
440 | - if( empty( $ids ) ) { |
|
440 | + if (empty($ids)) { |
|
441 | 441 | return []; |
442 | 442 | } |
443 | 443 | |
444 | 444 | $list = []; |
445 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
445 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
446 | 446 | |
447 | - foreach( $this->getAttributes( $ids ) as $id => $attrItem ) |
|
447 | + foreach ($this->getAttributes($ids) as $id => $attrItem) |
|
448 | 448 | { |
449 | 449 | $item = $manager->createItem(); |
450 | - $item->copyFrom( $attrItem ); |
|
451 | - $item->setType( $type ); |
|
452 | - $item->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 ); |
|
450 | + $item->copyFrom($attrItem); |
|
451 | + $item->setType($type); |
|
452 | + $item->setQuantity(isset($quantities[$id]) ? $quantities[$id] : 1); |
|
453 | 453 | |
454 | - if( isset( $values[$id] ) ) { |
|
455 | - $item->setValue( $values[$id] ); |
|
454 | + if (isset($values[$id])) { |
|
455 | + $item->setValue($values[$id]); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | $list[] = $item; |
@@ -469,23 +469,23 @@ discard block |
||
469 | 469 | * @param string $code Code of the list type |
470 | 470 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
471 | 471 | */ |
472 | - protected function getProductListTypeItem( $domain, $code ) |
|
472 | + protected function getProductListTypeItem($domain, $code) |
|
473 | 473 | { |
474 | 474 | $context = $this->getContext(); |
475 | 475 | |
476 | - if( empty( $this->listTypeItems ) ) |
|
476 | + if (empty($this->listTypeItems)) |
|
477 | 477 | { |
478 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
478 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
479 | 479 | |
480 | - foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) { |
|
481 | - $this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item; |
|
480 | + foreach ($manager->searchItems($manager->createSearch(true)) as $item) { |
|
481 | + $this->listTypeItems[$item->getDomain()][$item->getCode()] = $item; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | - if( !isset( $this->listTypeItems[$domain][$code] ) ) |
|
485 | + if (!isset($this->listTypeItems[$domain][$code])) |
|
486 | 486 | { |
487 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found' ); |
|
488 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, $code ) ); |
|
487 | + $msg = $context->getI18n()->dt('controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found'); |
|
488 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, $code)); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | return $this->listTypeItems[$domain][$code]; |
@@ -500,43 +500,43 @@ discard block |
||
500 | 500 | * @param array $domains Names of the domain items that should be fetched too |
501 | 501 | * @return array List of products matching the given attributes |
502 | 502 | */ |
503 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
504 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
503 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
504 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
505 | 505 | { |
506 | 506 | $subProductIds = []; |
507 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
507 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
508 | 508 | $subProductIds[] = $item->getId(); |
509 | 509 | } |
510 | 510 | |
511 | - if( count( $subProductIds ) === 0 ) { |
|
511 | + if (count($subProductIds) === 0) { |
|
512 | 512 | return []; |
513 | 513 | } |
514 | 514 | |
515 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
516 | - $search = $productManager->createSearch( true ); |
|
515 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
516 | + $search = $productManager->createSearch(true); |
|
517 | 517 | |
518 | 518 | $expr = array( |
519 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
519 | + $search->compare('==', 'product.id', $subProductIds), |
|
520 | 520 | $search->getConditions(), |
521 | 521 | ); |
522 | 522 | |
523 | - if( count( $variantAttributeIds ) > 0 ) |
|
523 | + if (count($variantAttributeIds) > 0) |
|
524 | 524 | { |
525 | - foreach( $variantAttributeIds as $key => $id ) { |
|
525 | + foreach ($variantAttributeIds as $key => $id) { |
|
526 | 526 | $variantAttributeIds[$key] = (string) $id; |
527 | 527 | } |
528 | 528 | |
529 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
529 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
530 | 530 | |
531 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
532 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
531 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
532 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
533 | 533 | |
534 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
534 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
535 | 535 | } |
536 | 536 | |
537 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
537 | + $search->setConditions($search->combine('&&', $expr)); |
|
538 | 538 | |
539 | - return $productManager->searchItems( $search, $domains ); |
|
539 | + return $productManager->searchItems($search, $domains); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
@@ -548,9 +548,9 @@ discard block |
||
548 | 548 | * @param mixed $default Default value if no value is available for the given name |
549 | 549 | * @return mixed Value from the array or default value |
550 | 550 | */ |
551 | - protected function getValue( array $values, $name, $default = null ) |
|
551 | + protected function getValue(array $values, $name, $default = null) |
|
552 | 552 | { |
553 | - if( isset( $values[$name] ) ) { |
|
553 | + if (isset($values[$name])) { |
|
554 | 554 | return $values[$name]; |
555 | 555 | } |
556 | 556 |
@@ -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\Factory::createManager( $context, 'order' ); |
|
36 | + $manager = \Aimeos\MShop\Factory::createManager($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\Factory::createManager( $this->getContext(), 'order' )->createSearch( true ); |
|
82 | + return \Aimeos\MShop\Factory::createManager($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\Factory::createManager( $context, 'order' ); |
|
96 | + $manager = \Aimeos\MShop\Factory::createManager($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\Factory::createManager( $this->getContext(), 'order' ); |
|
129 | - return $manager->saveItem( $item ); |
|
128 | + $manager = \Aimeos\MShop\Factory::createManager($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\Factory::createManager( $context, 'order' ); |
|
143 | + $manager = \Aimeos\MShop\Factory::createManager($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 | } |
@@ -18,165 +18,165 @@ |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - \Aimeos\MShop\Factory::setCache( true ); |
|
21 | + \Aimeos\MShop\Factory::setCache(true); |
|
22 | 22 | |
23 | 23 | $this->context = \TestHelperFrontend::getContext(); |
24 | - $this->object = new \Aimeos\Controller\Frontend\Order\Standard( $this->context ); |
|
24 | + $this->object = new \Aimeos\Controller\Frontend\Order\Standard($this->context); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | protected function tearDown() |
29 | 29 | { |
30 | - unset( $this->object, $this->context ); |
|
30 | + unset($this->object, $this->context); |
|
31 | 31 | |
32 | - \Aimeos\MShop\Factory::setCache( false ); |
|
32 | + \Aimeos\MShop\Factory::setCache(false); |
|
33 | 33 | \Aimeos\MShop\Factory::clear(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | |
37 | 37 | public function testAddItem() |
38 | 38 | { |
39 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
|
40 | - ->setConstructorArgs( [$this->context] ) |
|
41 | - ->setMethods( ['saveItem'] ) |
|
39 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard') |
|
40 | + ->setConstructorArgs([$this->context]) |
|
41 | + ->setMethods(['saveItem']) |
|
42 | 42 | ->getMock(); |
43 | 43 | |
44 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order', $manager ); |
|
44 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order', $manager); |
|
45 | 45 | |
46 | - $manager->expects( $this->once() )->method( 'saveItem' ) |
|
47 | - ->will( $this->returnValue( $manager->createItem() ) ); |
|
46 | + $manager->expects($this->once())->method('saveItem') |
|
47 | + ->will($this->returnValue($manager->createItem())); |
|
48 | 48 | |
49 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $this->object->addItem( -1, 'test' ) ); |
|
49 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Iface', $this->object->addItem( -1, 'test' )); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testAddItemLimit() |
54 | 54 | { |
55 | - $this->context->getConfig()->set( 'controller/frontend/order/limit-seconds', 86400 * 365 ); |
|
55 | + $this->context->getConfig()->set('controller/frontend/order/limit-seconds', 86400 * 365); |
|
56 | 56 | |
57 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base' ); |
|
58 | - $result = $manager->searchItems( $manager->createSearch()->setSlice( 0, 1 ) ); |
|
57 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base'); |
|
58 | + $result = $manager->searchItems($manager->createSearch()->setSlice(0, 1)); |
|
59 | 59 | |
60 | - if( ( $item = reset( $result ) ) === false ) { |
|
61 | - throw new \RuntimeException( 'No order item found' ); |
|
60 | + if (($item = reset($result)) === false) { |
|
61 | + throw new \RuntimeException('No order item found'); |
|
62 | 62 | } |
63 | 63 | |
64 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Order\Exception' ); |
|
65 | - $this->object->addItem( $item->getId(), 'test' ); |
|
64 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Order\Exception'); |
|
65 | + $this->object->addItem($item->getId(), 'test'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | public function testCreateFilter() |
70 | 70 | { |
71 | - $this->assertInstanceOf( '\Aimeos\MW\Criteria\Iface', $this->object->createFilter() ); |
|
71 | + $this->assertInstanceOf('\Aimeos\MW\Criteria\Iface', $this->object->createFilter()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | 75 | public function testGetItem() |
76 | 76 | { |
77 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
78 | - $customerItem = $manager->findItem( 'UTC001' ); |
|
77 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
78 | + $customerItem = $manager->findItem('UTC001'); |
|
79 | 79 | |
80 | - $this->context->setEditor( 'core:unittest' ); |
|
80 | + $this->context->setEditor('core:unittest'); |
|
81 | 81 | |
82 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'order' ); |
|
83 | - $search = $manager->createSearch()->setSlice( 0, 1 ); |
|
84 | - $search->setConditions( $search->compare( '==', 'order.base.customerid', $customerItem->getId() ) ); |
|
85 | - $result = $manager->searchItems( $search ); |
|
82 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'order'); |
|
83 | + $search = $manager->createSearch()->setSlice(0, 1); |
|
84 | + $search->setConditions($search->compare('==', 'order.base.customerid', $customerItem->getId())); |
|
85 | + $result = $manager->searchItems($search); |
|
86 | 86 | |
87 | - if( ( $item = reset( $result ) ) === false ) { |
|
88 | - throw new \RuntimeException( 'No order item found' ); |
|
87 | + if (($item = reset($result)) === false) { |
|
88 | + throw new \RuntimeException('No order item found'); |
|
89 | 89 | } |
90 | 90 | |
91 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $this->object->getItem( $item->getId() ) ); |
|
91 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Iface', $this->object->getItem($item->getId())); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
95 | 95 | public function testGetItemException() |
96 | 96 | { |
97 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Order\Exception' ); |
|
97 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Order\Exception'); |
|
98 | 98 | $this->object->getItem( -1 ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | public function testSaveItem() |
103 | 103 | { |
104 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
|
105 | - ->setConstructorArgs( [$this->context] ) |
|
106 | - ->setMethods( ['saveItem'] ) |
|
104 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Order\\Manager\\Standard') |
|
105 | + ->setConstructorArgs([$this->context]) |
|
106 | + ->setMethods(['saveItem']) |
|
107 | 107 | ->getMock(); |
108 | 108 | |
109 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order', $manager ); |
|
109 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order', $manager); |
|
110 | 110 | |
111 | - $manager->expects( $this->once() )->method( 'saveItem' ) |
|
112 | - ->will( $this->returnValue( $manager->createItem() ) ); |
|
111 | + $manager->expects($this->once())->method('saveItem') |
|
112 | + ->will($this->returnValue($manager->createItem())); |
|
113 | 113 | |
114 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $this->object->saveItem( $manager->createItem() ) ); |
|
114 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Iface', $this->object->saveItem($manager->createItem())); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | 118 | public function testSearchItems() |
119 | 119 | { |
120 | - $this->assertGreaterThan( 1, $this->object->searchItems( $this->object->createFilter() ) ); |
|
120 | + $this->assertGreaterThan(1, $this->object->searchItems($this->object->createFilter())); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
124 | 124 | public function testBlock() |
125 | 125 | { |
126 | 126 | $name = 'ControllerFrontendOrderBlock'; |
127 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
127 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
128 | 128 | |
129 | 129 | |
130 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
131 | - ->setMethods( array( 'block' ) ) |
|
132 | - ->setConstructorArgs( array( $this->context ) ) |
|
130 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
131 | + ->setMethods(array('block')) |
|
132 | + ->setConstructorArgs(array($this->context)) |
|
133 | 133 | ->getMock(); |
134 | 134 | |
135 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
135 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
136 | 136 | |
137 | - $orderCntlStub->expects( $this->once() )->method( 'block' ); |
|
137 | + $orderCntlStub->expects($this->once())->method('block'); |
|
138 | 138 | |
139 | 139 | |
140 | - $this->object->block( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
140 | + $this->object->block(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
144 | 144 | public function testUnblock() |
145 | 145 | { |
146 | 146 | $name = 'ControllerFrontendOrderUnblock'; |
147 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
147 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
148 | 148 | |
149 | 149 | |
150 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
151 | - ->setMethods( array( 'unblock' ) ) |
|
152 | - ->setConstructorArgs( array( $this->context ) ) |
|
150 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
151 | + ->setMethods(array('unblock')) |
|
152 | + ->setConstructorArgs(array($this->context)) |
|
153 | 153 | ->getMock(); |
154 | 154 | |
155 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
155 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
156 | 156 | |
157 | - $orderCntlStub->expects( $this->once() )->method( 'unblock' ); |
|
157 | + $orderCntlStub->expects($this->once())->method('unblock'); |
|
158 | 158 | |
159 | 159 | |
160 | - $this->object->unblock( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
160 | + $this->object->unblock(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
164 | 164 | public function testUpdate() |
165 | 165 | { |
166 | 166 | $name = 'ControllerFrontendOrderUpdate'; |
167 | - $this->context->getConfig()->set( 'controller/common/order/name', $name ); |
|
167 | + $this->context->getConfig()->set('controller/common/order/name', $name); |
|
168 | 168 | |
169 | 169 | |
170 | - $orderCntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Order\\Standard' ) |
|
171 | - ->setMethods( array( 'update' ) ) |
|
172 | - ->setConstructorArgs( array( $this->context ) ) |
|
170 | + $orderCntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Order\\Standard') |
|
171 | + ->setMethods(array('update')) |
|
172 | + ->setConstructorArgs(array($this->context)) |
|
173 | 173 | ->getMock(); |
174 | 174 | |
175 | - \Aimeos\Controller\Common\Order\Factory::injectController( '\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub ); |
|
175 | + \Aimeos\Controller\Common\Order\Factory::injectController('\\Aimeos\\Controller\\Common\\Order\\' . $name, $orderCntlStub); |
|
176 | 176 | |
177 | - $orderCntlStub->expects( $this->once() )->method( 'update' ); |
|
177 | + $orderCntlStub->expects($this->once())->method('update'); |
|
178 | 178 | |
179 | 179 | |
180 | - $this->object->update( \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem() ); |
|
180 | + $this->object->update(\Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem()); |
|
181 | 181 | } |
182 | 182 | } |