@@ -21,46 +21,46 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | protected function tearDown() |
| 23 | 23 | { |
| 24 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
| 24 | + $this->context->getSession()->set('aimeos', []); |
|
| 25 | 25 | |
| 26 | - unset( $this->context ); |
|
| 26 | + unset($this->context); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | public function testCheckLocale() |
| 31 | 31 | { |
| 32 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 33 | - ->setConstructorArgs( [$this->context] ) |
|
| 34 | - ->setMethods( null ) |
|
| 32 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 33 | + ->setConstructorArgs([$this->context]) |
|
| 34 | + ->setMethods(null) |
|
| 35 | 35 | ->getMock(); |
| 36 | 36 | |
| 37 | - $this->context->getSession()->set( 'aimeos/basket/locale', 'unittest|en|EUR' ); |
|
| 38 | - $this->access( 'checkLocale' )->invokeArgs( $object, ['unittest'] ); |
|
| 37 | + $this->context->getSession()->set('aimeos/basket/locale', 'unittest|en|EUR'); |
|
| 38 | + $this->access('checkLocale')->invokeArgs($object, ['unittest']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | public function testCopyAddresses() |
| 43 | 43 | { |
| 44 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 44 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 45 | 45 | $ordBaseItem = $manager->createItem(); |
| 46 | 46 | |
| 47 | - $address = $this->getAddress( 'Example company' ); |
|
| 48 | - $ordBaseItem->setAddress( $address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 47 | + $address = $this->getAddress('Example company'); |
|
| 48 | + $ordBaseItem->setAddress($address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 52 | - ->setConstructorArgs( [$this->context] ) |
|
| 53 | - ->setMethods( null ) |
|
| 51 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 52 | + ->setConstructorArgs([$this->context]) |
|
| 53 | + ->setMethods(null) |
|
| 54 | 54 | ->getMock(); |
| 55 | 55 | |
| 56 | - $result = $this->access( 'copyAddresses' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
| 56 | + $result = $this->access('copyAddresses')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - $this->assertEquals( ['test'], $result ); |
|
| 60 | - $this->assertEquals( 1, count( $object->get()->getAddresses() ) ); |
|
| 59 | + $this->assertEquals(['test'], $result); |
|
| 60 | + $this->assertEquals(1, count($object->get()->getAddresses())); |
|
| 61 | 61 | |
| 62 | - $addr = $object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 63 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Address\Iface', $addr ); |
|
| 62 | + $addr = $object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 63 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Address\Iface', $addr); |
|
| 64 | 64 | |
| 65 | 65 | $object->clear(); |
| 66 | 66 | } |
@@ -68,54 +68,54 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function testCopyAddressesException() |
| 70 | 70 | { |
| 71 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 71 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 72 | 72 | $ordBaseItem = $manager->createItem(); |
| 73 | 73 | |
| 74 | - $address = $this->getAddress( 'Example company' ); |
|
| 75 | - $ordBaseItem->setAddress( $address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 74 | + $address = $this->getAddress('Example company'); |
|
| 75 | + $ordBaseItem->setAddress($address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 79 | - ->setConstructorArgs( [$this->context] ) |
|
| 80 | - ->setMethods( ['setAddress'] ) |
|
| 78 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 79 | + ->setConstructorArgs([$this->context]) |
|
| 80 | + ->setMethods(['setAddress']) |
|
| 81 | 81 | ->getMock(); |
| 82 | 82 | |
| 83 | - $object->expects( $this->once() )->method( 'setAddress' )->will( $this->throwException( new \Exception() ) ); |
|
| 83 | + $object->expects($this->once())->method('setAddress')->will($this->throwException(new \Exception())); |
|
| 84 | 84 | |
| 85 | - $result = $this->access( 'copyAddresses' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
| 85 | + $result = $this->access('copyAddresses')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
| 86 | 86 | |
| 87 | - $this->assertEquals( 1, count( $result ) ); |
|
| 88 | - $this->assertArrayHasKey( 'address', $result ); |
|
| 87 | + $this->assertEquals(1, count($result)); |
|
| 88 | + $this->assertArrayHasKey('address', $result); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | public function testCopyCoupon() |
| 93 | 93 | { |
| 94 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 94 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 95 | 95 | $ordBaseItem = $manager->createItem(); |
| 96 | 96 | |
| 97 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC', ['price'] ); |
|
| 98 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
| 99 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
| 97 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC', ['price']); |
|
| 98 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
| 99 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
| 100 | 100 | |
| 101 | - $priceItems = $product->getRefItems( 'price' ); |
|
| 102 | - $ordProdItem->setPrice( reset( $priceItems ) ); |
|
| 101 | + $priceItems = $product->getRefItems('price'); |
|
| 102 | + $ordProdItem->setPrice(reset($priceItems)); |
|
| 103 | 103 | |
| 104 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
| 105 | - $ordBaseItem->addCoupon( 'OPQR', [] ); |
|
| 104 | + $ordBaseItem->addProduct($ordProdItem); |
|
| 105 | + $ordBaseItem->addCoupon('OPQR', []); |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 109 | - ->setConstructorArgs( [$this->context] ) |
|
| 110 | - ->setMethods( null ) |
|
| 108 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 109 | + ->setConstructorArgs([$this->context]) |
|
| 110 | + ->setMethods(null) |
|
| 111 | 111 | ->getMock(); |
| 112 | 112 | |
| 113 | - $object->addProduct( $product->getId() ); |
|
| 113 | + $object->addProduct($product->getId()); |
|
| 114 | 114 | |
| 115 | - $result = $this->access( 'copyCoupons' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
| 115 | + $result = $this->access('copyCoupons')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | - $this->assertEquals( ['test'], $result ); |
|
| 118 | + $this->assertEquals(['test'], $result); |
|
| 119 | 119 | |
| 120 | 120 | $object->clear(); |
| 121 | 121 | } |
@@ -123,48 +123,48 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | public function testCopyCouponException() |
| 125 | 125 | { |
| 126 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 126 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 127 | 127 | $ordBaseItem = $manager->createItem(); |
| 128 | 128 | |
| 129 | - $ordBaseItem->addCoupon( '90AB', [] ); |
|
| 129 | + $ordBaseItem->addCoupon('90AB', []); |
|
| 130 | 130 | |
| 131 | 131 | |
| 132 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 133 | - ->setConstructorArgs( [$this->context] ) |
|
| 134 | - ->setMethods( ['addCoupon'] ) |
|
| 132 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 133 | + ->setConstructorArgs([$this->context]) |
|
| 134 | + ->setMethods(['addCoupon']) |
|
| 135 | 135 | ->getMock(); |
| 136 | 136 | |
| 137 | - $object->expects( $this->once() )->method( 'addCoupon' )->will( $this->throwException( new \Exception() ) ); |
|
| 137 | + $object->expects($this->once())->method('addCoupon')->will($this->throwException(new \Exception())); |
|
| 138 | 138 | |
| 139 | - $result = $this->access( 'copyCoupons' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
| 139 | + $result = $this->access('copyCoupons')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
| 140 | 140 | |
| 141 | - $this->assertEquals( 1, count( $result ) ); |
|
| 142 | - $this->assertArrayHasKey( 'coupon', $result ); |
|
| 141 | + $this->assertEquals(1, count($result)); |
|
| 142 | + $this->assertArrayHasKey('coupon', $result); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | public function testCopyProduct() |
| 147 | 147 | { |
| 148 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 148 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 149 | 149 | $ordBaseItem = $manager->createItem(); |
| 150 | 150 | |
| 151 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 152 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
| 153 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
| 154 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
| 151 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 152 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
| 153 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
| 154 | + $ordBaseItem->addProduct($ordProdItem); |
|
| 155 | 155 | |
| 156 | 156 | |
| 157 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 158 | - ->setConstructorArgs( [$this->context] ) |
|
| 159 | - ->setMethods( null ) |
|
| 157 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 158 | + ->setConstructorArgs([$this->context]) |
|
| 159 | + ->setMethods(null) |
|
| 160 | 160 | ->getMock(); |
| 161 | 161 | |
| 162 | - $result = $this->access( 'copyProducts' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
| 162 | + $result = $this->access('copyProducts')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
| 163 | 163 | |
| 164 | 164 | |
| 165 | - $this->assertEquals( ['test'], $result ); |
|
| 166 | - $this->assertEquals( 1, count( $object->get()->getProducts() ) ); |
|
| 167 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Product\Iface', $object->get()->getProduct( 0 ) ); |
|
| 165 | + $this->assertEquals(['test'], $result); |
|
| 166 | + $this->assertEquals(1, count($object->get()->getProducts())); |
|
| 167 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Product\Iface', $object->get()->getProduct(0)); |
|
| 168 | 168 | |
| 169 | 169 | $object->clear(); |
| 170 | 170 | } |
@@ -172,58 +172,58 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | public function testCopyProductException() |
| 174 | 174 | { |
| 175 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 175 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 176 | 176 | $ordBaseItem = $manager->createItem(); |
| 177 | 177 | |
| 178 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 179 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
| 180 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
| 181 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
| 178 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 179 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
| 180 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
| 181 | + $ordBaseItem->addProduct($ordProdItem); |
|
| 182 | 182 | |
| 183 | 183 | |
| 184 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 185 | - ->setConstructorArgs( [$this->context] ) |
|
| 186 | - ->setMethods( ['addProduct'] ) |
|
| 184 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 185 | + ->setConstructorArgs([$this->context]) |
|
| 186 | + ->setMethods(['addProduct']) |
|
| 187 | 187 | ->getMock(); |
| 188 | 188 | |
| 189 | - $object->expects( $this->once() )->method( 'addProduct' )->will( $this->throwException( new \Exception() ) ); |
|
| 189 | + $object->expects($this->once())->method('addProduct')->will($this->throwException(new \Exception())); |
|
| 190 | 190 | |
| 191 | - $result = $this->access( 'copyProducts' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
| 191 | + $result = $this->access('copyProducts')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
| 192 | 192 | |
| 193 | - $this->assertEquals( 1, count( $result ) ); |
|
| 194 | - $this->assertArrayHasKey( 'product', $result ); |
|
| 193 | + $this->assertEquals(1, count($result)); |
|
| 194 | + $this->assertArrayHasKey('product', $result); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | |
| 198 | 198 | public function testCopyServices() |
| 199 | 199 | { |
| 200 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 200 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 201 | 201 | $ordBaseItem = $manager->createItem(); |
| 202 | 202 | |
| 203 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 204 | - $ordServManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/service' ); |
|
| 203 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 204 | + $ordServManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service'); |
|
| 205 | 205 | |
| 206 | - $serviceItem = $serviceManager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 207 | - $ordServItem = $ordServManager->createItem()->copyFrom( $serviceItem ); |
|
| 206 | + $serviceItem = $serviceManager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 207 | + $ordServItem = $ordServManager->createItem()->copyFrom($serviceItem); |
|
| 208 | 208 | |
| 209 | - $ordBaseItem->addService( $ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
| 209 | + $ordBaseItem->addService($ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
| 210 | 210 | |
| 211 | 211 | |
| 212 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 213 | - ->setConstructorArgs( [$this->context] ) |
|
| 214 | - ->setMethods( null ) |
|
| 212 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 213 | + ->setConstructorArgs([$this->context]) |
|
| 214 | + ->setMethods(null) |
|
| 215 | 215 | ->getMock(); |
| 216 | 216 | |
| 217 | - $result = $this->access( 'copyServices' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
| 217 | + $result = $this->access('copyServices')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | - $this->assertEquals( ['test'], $result ); |
|
| 221 | - $this->assertEquals( 1, count( $object->get()->getServices() ) ); |
|
| 220 | + $this->assertEquals(['test'], $result); |
|
| 221 | + $this->assertEquals(1, count($object->get()->getServices())); |
|
| 222 | 222 | |
| 223 | - $services = $object->get()->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
| 223 | + $services = $object->get()->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
| 224 | 224 | |
| 225 | - foreach( $services as $service ) { |
|
| 226 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Service\Iface', $service ); |
|
| 225 | + foreach ($services as $service) { |
|
| 226 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Service\Iface', $service); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | $object->clear(); |
@@ -232,75 +232,75 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | public function testCopyServicesException() |
| 234 | 234 | { |
| 235 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
| 235 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
| 236 | 236 | $ordBaseItem = $manager->createItem(); |
| 237 | 237 | |
| 238 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 239 | - $ordServManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/service' ); |
|
| 238 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 239 | + $ordServManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service'); |
|
| 240 | 240 | |
| 241 | - $serviceItem = $serviceManager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 242 | - $ordServItem = $ordServManager->createItem()->copyFrom( $serviceItem ); |
|
| 241 | + $serviceItem = $serviceManager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 242 | + $ordServItem = $ordServManager->createItem()->copyFrom($serviceItem); |
|
| 243 | 243 | |
| 244 | - $ordBaseItem->addService( $ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
| 244 | + $ordBaseItem->addService($ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
| 245 | 245 | |
| 246 | 246 | |
| 247 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 248 | - ->setConstructorArgs( [$this->context] ) |
|
| 249 | - ->setMethods( ['addService'] ) |
|
| 247 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 248 | + ->setConstructorArgs([$this->context]) |
|
| 249 | + ->setMethods(['addService']) |
|
| 250 | 250 | ->getMock(); |
| 251 | 251 | |
| 252 | - $object->expects( $this->once() )->method( 'addService' )->will( $this->throwException( new \Exception() ) ); |
|
| 252 | + $object->expects($this->once())->method('addService')->will($this->throwException(new \Exception())); |
|
| 253 | 253 | |
| 254 | - $result = $this->access( 'copyServices' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
| 254 | + $result = $this->access('copyServices')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
| 255 | 255 | |
| 256 | - $this->assertEquals( 0, count( $result ) ); |
|
| 256 | + $this->assertEquals(0, count($result)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | |
| 260 | 260 | public function testGetOrderProductAttributes() |
| 261 | 261 | { |
| 262 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
| 263 | - ->setConstructorArgs( [$this->context] ) |
|
| 264 | - ->setMethods( ['getAttributes'] ) |
|
| 262 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
| 263 | + ->setConstructorArgs([$this->context]) |
|
| 264 | + ->setMethods(['getAttributes']) |
|
| 265 | 265 | ->getMock(); |
| 266 | 266 | |
| 267 | - $list = [1 => new \Aimeos\MShop\Attribute\Item\Standard( ['attribute.code' => 'special_instructions'] )]; |
|
| 268 | - $object->expects( $this->once() )->method( 'getAttributes' )->will( $this->returnValue( $list ) ); |
|
| 267 | + $list = [1 => new \Aimeos\MShop\Attribute\Item\Standard(['attribute.code' => 'special_instructions'])]; |
|
| 268 | + $object->expects($this->once())->method('getAttributes')->will($this->returnValue($list)); |
|
| 269 | 269 | |
| 270 | - $result = $this->access( 'getOrderProductAttributes' )->invokeArgs( $object, ['test', ['1'], ['1' => 'test']] ); |
|
| 270 | + $result = $this->access('getOrderProductAttributes')->invokeArgs($object, ['test', ['1'], ['1' => 'test']]); |
|
| 271 | 271 | |
| 272 | - $this->assertEquals( 1, count( $result ) ); |
|
| 273 | - $this->assertEquals( 'test', $result[0]->getValue() ); |
|
| 272 | + $this->assertEquals(1, count($result)); |
|
| 273 | + $this->assertEquals('test', $result[0]->getValue()); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * @param string $company |
| 279 | 279 | */ |
| 280 | - protected function getAddress( $company ) |
|
| 280 | + protected function getAddress($company) |
|
| 281 | 281 | { |
| 282 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'customer/address' ); |
|
| 282 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'customer/address'); |
|
| 283 | 283 | |
| 284 | 284 | $search = $manager->createSearch(); |
| 285 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
| 286 | - $items = $manager->searchItems( $search ); |
|
| 285 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
| 286 | + $items = $manager->searchItems($search); |
|
| 287 | 287 | |
| 288 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 289 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
| 288 | + if (($item = reset($items)) === false) { |
|
| 289 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $ordAddrManager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base/address' ); |
|
| 293 | - $ordAddrItem = $ordAddrManager->createItem()->copyFrom( $item ); |
|
| 292 | + $ordAddrManager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base/address'); |
|
| 293 | + $ordAddrItem = $ordAddrManager->createItem()->copyFrom($item); |
|
| 294 | 294 | |
| 295 | 295 | return $ordAddrItem; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
| 299 | - protected function access( $name ) |
|
| 299 | + protected function access($name) |
|
| 300 | 300 | { |
| 301 | - $class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Basket\Base' ); |
|
| 302 | - $method = $class->getMethod( $name ); |
|
| 303 | - $method->setAccessible( true ); |
|
| 301 | + $class = new \ReflectionClass('\Aimeos\Controller\Frontend\Basket\Base'); |
|
| 302 | + $method = $class->getMethod($name); |
|
| 303 | + $method->setAccessible(true); |
|
| 304 | 304 | |
| 305 | 305 | return $method; |
| 306 | 306 | } |
@@ -19,112 +19,112 @@ discard block |
||
| 19 | 19 | public static function setUpBeforeClass() |
| 20 | 20 | { |
| 21 | 21 | $context = \TestHelperFrontend::getContext(); |
| 22 | - self::$testItem = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'U:TESTP' ); |
|
| 22 | + self::$testItem = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('U:TESTP'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | protected function setUp() |
| 27 | 27 | { |
| 28 | - \Aimeos\MShop\Factory::setCache( true ); |
|
| 28 | + \Aimeos\MShop\Factory::setCache(true); |
|
| 29 | 29 | |
| 30 | 30 | $this->context = \TestHelperFrontend::getContext(); |
| 31 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 31 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | protected function tearDown() |
| 36 | 36 | { |
| 37 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 37 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 38 | 38 | \Aimeos\MShop\Factory::clear(); |
| 39 | 39 | |
| 40 | 40 | $this->object->clear(); |
| 41 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
| 41 | + $this->context->getSession()->set('aimeos', []); |
|
| 42 | 42 | |
| 43 | - unset( $this->context, $this->object ); |
|
| 43 | + unset($this->context, $this->object); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | public function testClear() |
| 48 | 48 | { |
| 49 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 49 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 50 | 50 | $this->object->clear(); |
| 51 | 51 | |
| 52 | - $this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
| 52 | + $this->assertEquals(0, count($this->object->get()->getProducts())); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | public function testGet() |
| 57 | 57 | { |
| 58 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() ); |
|
| 58 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get()); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | public function testSave() |
| 63 | 63 | { |
| 64 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 65 | - ->setConstructorArgs( [$this->context] ) |
|
| 66 | - ->setMethods( ['setSession'] ) |
|
| 64 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 65 | + ->setConstructorArgs([$this->context]) |
|
| 66 | + ->setMethods(['setSession']) |
|
| 67 | 67 | ->getMock(); |
| 68 | 68 | |
| 69 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 69 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 70 | 70 | |
| 71 | - $stub->expects( $this->exactly( 2 ) )->method( 'setSession' ); |
|
| 71 | + $stub->expects($this->exactly(2))->method('setSession'); |
|
| 72 | 72 | |
| 73 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 74 | - $object->addProduct( self::$testItem->getId(), 2 ); |
|
| 73 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 74 | + $object->addProduct(self::$testItem->getId(), 2); |
|
| 75 | 75 | $object->save(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | public function testSetType() |
| 80 | 80 | { |
| 81 | - $this->assertInstanceOf( '\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType( 'test' ) ); |
|
| 81 | + $this->assertInstanceOf('\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType('test')); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | public function testStore() |
| 86 | 86 | { |
| 87 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 88 | - ->setConstructorArgs( [$this->context] ) |
|
| 89 | - ->setMethods( ['store'] ) |
|
| 87 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 88 | + ->setConstructorArgs([$this->context]) |
|
| 89 | + ->setMethods(['store']) |
|
| 90 | 90 | ->getMock(); |
| 91 | 91 | |
| 92 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 92 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 93 | 93 | |
| 94 | - $stub->expects( $this->once() )->method( 'store' ); |
|
| 94 | + $stub->expects($this->once())->method('store'); |
|
| 95 | 95 | |
| 96 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 96 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 97 | 97 | $object->store(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | public function testStoreLimit() |
| 102 | 102 | { |
| 103 | - $this->context->setEditor( 'core:unittest' ); |
|
| 103 | + $this->context->setEditor('core:unittest'); |
|
| 104 | 104 | $config = $this->context->getConfig(); |
| 105 | - $config->set( 'controller/frontend/basket/limit-count', 0 ); |
|
| 106 | - $config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 ); |
|
| 105 | + $config->set('controller/frontend/basket/limit-count', 0); |
|
| 106 | + $config->set('controller/frontend/basket/limit-seconds', 86400 * 365); |
|
| 107 | 107 | |
| 108 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 108 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 109 | 109 | |
| 110 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
| 110 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
| 111 | 111 | $object->store(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | public function testLoad() |
| 116 | 116 | { |
| 117 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
| 118 | - ->setConstructorArgs( [$this->context] ) |
|
| 119 | - ->setMethods( ['load'] ) |
|
| 117 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
| 118 | + ->setConstructorArgs([$this->context]) |
|
| 119 | + ->setMethods(['load']) |
|
| 120 | 120 | ->getMock(); |
| 121 | 121 | |
| 122 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
| 122 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
| 123 | 123 | |
| 124 | - $stub->expects( $this->once() )->method( 'load' ) |
|
| 125 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
| 124 | + $stub->expects($this->once())->method('load') |
|
| 125 | + ->will($this->returnValue($stub->createItem())); |
|
| 126 | 126 | |
| 127 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 127 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 128 | 128 | $object->load( -1 ); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,338 +132,338 @@ discard block |
||
| 132 | 132 | public function testAddDeleteProduct() |
| 133 | 133 | { |
| 134 | 134 | $basket = $this->object->get(); |
| 135 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
| 135 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
| 136 | 136 | |
| 137 | - $this->object->addProduct( $item->getId(), 2, 'default', [], [], [], [] ); |
|
| 138 | - $item2 = $this->object->get()->getProduct( 0 ); |
|
| 139 | - $this->object->deleteProduct( 0 ); |
|
| 137 | + $this->object->addProduct($item->getId(), 2, 'default', [], [], [], []); |
|
| 138 | + $item2 = $this->object->get()->getProduct(0); |
|
| 139 | + $this->object->deleteProduct(0); |
|
| 140 | 140 | |
| 141 | - $this->assertEquals( 0, count( $basket->getProducts() ) ); |
|
| 142 | - $this->assertEquals( 'CNC', $item2->getProductCode() ); |
|
| 141 | + $this->assertEquals(0, count($basket->getProducts())); |
|
| 142 | + $this->assertEquals('CNC', $item2->getProductCode()); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | public function testAddProductCustomAttribute() |
| 147 | 147 | { |
| 148 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 148 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 149 | 149 | |
| 150 | 150 | $search = $attributeManager->createSearch(); |
| 151 | 151 | $expr = array( |
| 152 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 153 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
| 152 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 153 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
| 154 | 154 | ); |
| 155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 155 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 156 | 156 | |
| 157 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 157 | + $attributes = $attributeManager->searchItems($search); |
|
| 158 | 158 | |
| 159 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 160 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 159 | + if (($attrItem = reset($attributes)) === false) { |
|
| 160 | + throw new \RuntimeException('Attribute not found'); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
| 163 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
| 164 | 164 | |
| 165 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues ); |
|
| 165 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues); |
|
| 166 | 166 | $basket = $this->object->get(); |
| 167 | 167 | |
| 168 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 169 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
| 168 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 169 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | public function testAddProductCustomPrice() |
| 174 | 174 | { |
| 175 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 175 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 176 | 176 | |
| 177 | 177 | $search = $attributeManager->createSearch(); |
| 178 | 178 | $expr = array( |
| 179 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 180 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
| 179 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 180 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
| 181 | 181 | ); |
| 182 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 182 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 183 | 183 | |
| 184 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 184 | + $attributes = $attributeManager->searchItems($search); |
|
| 185 | 185 | |
| 186 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 187 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 186 | + if (($attrItem = reset($attributes)) === false) { |
|
| 187 | + throw new \RuntimeException('Attribute not found'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $attrValues = array( $attrItem->getId() => '0.01' ); |
|
| 190 | + $attrValues = array($attrItem->getId() => '0.01'); |
|
| 191 | 191 | |
| 192 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues ); |
|
| 192 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues); |
|
| 193 | 193 | $basket = $this->object->get(); |
| 194 | 194 | |
| 195 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
| 196 | - $this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() ); |
|
| 195 | + $this->assertEquals(1, count($basket->getProducts())); |
|
| 196 | + $this->assertEquals('0.01', $basket->getProduct(0)->getPrice()->getValue()); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
| 200 | 200 | public function testAddProductCustomPriceException() |
| 201 | 201 | { |
| 202 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 202 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 203 | 203 | |
| 204 | 204 | $search = $attributeManager->createSearch(); |
| 205 | 205 | $expr = array( |
| 206 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
| 207 | - $search->compare( '==', 'attribute.type.code', 'price' ), |
|
| 206 | + $search->compare('==', 'attribute.code', 'custom'), |
|
| 207 | + $search->compare('==', 'attribute.type.code', 'price'), |
|
| 208 | 208 | ); |
| 209 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 209 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 210 | 210 | |
| 211 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 211 | + $attributes = $attributeManager->searchItems($search); |
|
| 212 | 212 | |
| 213 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
| 214 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 213 | + if (($attrItem = reset($attributes)) === false) { |
|
| 214 | + throw new \RuntimeException('Attribute not found'); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - $attrValues = array( $attrItem->getId() => ',' ); |
|
| 217 | + $attrValues = array($attrItem->getId() => ','); |
|
| 218 | 218 | |
| 219 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
| 220 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues ); |
|
| 219 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
| 220 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | public function testAddProductAttributePrice() |
| 225 | 225 | { |
| 226 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 226 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 227 | 227 | |
| 228 | 228 | $search = $attributeManager->createSearch(); |
| 229 | 229 | $expr = array( |
| 230 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
| 231 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
| 230 | + $search->compare('==', 'attribute.code', 'xs'), |
|
| 231 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
| 232 | 232 | ); |
| 233 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 233 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 234 | 234 | |
| 235 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 235 | + $attributes = $attributeManager->searchItems($search); |
|
| 236 | 236 | |
| 237 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
| 238 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 237 | + if (($attribute = reset($attributes)) === false) { |
|
| 238 | + throw new \RuntimeException('Attribute not found'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [$attribute->getId() => 2] ); |
|
| 241 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [$attribute->getId() => 2]); |
|
| 242 | 242 | |
| 243 | - $this->assertEquals( '43.90', $this->object->get()->getPrice()->getValue() ); |
|
| 243 | + $this->assertEquals('43.90', $this->object->get()->getPrice()->getValue()); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | public function testAddProductAttributeNotAssigned() |
| 248 | 248 | { |
| 249 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 249 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 250 | 250 | |
| 251 | 251 | $search = $attributeManager->createSearch(); |
| 252 | 252 | $expr = array( |
| 253 | - $search->compare( '==', 'attribute.code', '30' ), |
|
| 254 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
| 253 | + $search->compare('==', 'attribute.code', '30'), |
|
| 254 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
| 255 | 255 | ); |
| 256 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 256 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 257 | 257 | |
| 258 | - $attribute = $attributeManager->searchItems( $search ); |
|
| 258 | + $attribute = $attributeManager->searchItems($search); |
|
| 259 | 259 | |
| 260 | - if( empty( $attribute ) ) { |
|
| 261 | - throw new \RuntimeException( 'Attribute not found' ); |
|
| 260 | + if (empty($attribute)) { |
|
| 261 | + throw new \RuntimeException('Attribute not found'); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - $hiddenAttrIds = array_keys( $attribute ); |
|
| 265 | - $configAttrIds = array_keys( $attribute ); |
|
| 264 | + $hiddenAttrIds = array_keys($attribute); |
|
| 265 | + $configAttrIds = array_keys($attribute); |
|
| 266 | 266 | |
| 267 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 268 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], $configAttrIds, $hiddenAttrIds ); |
|
| 267 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 268 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], $configAttrIds, $hiddenAttrIds); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | |
| 272 | 272 | public function testAddProductNegativeQuantityException() |
| 273 | 273 | { |
| 274 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
| 275 | - $this->object->addProduct( self::$testItem->getId(), -1 ); |
|
| 274 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
| 275 | + $this->object->addProduct(self::$testItem->getId(), -1); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
| 279 | 279 | public function testAddProductNoPriceException() |
| 280 | 280 | { |
| 281 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
| 281 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
| 282 | 282 | |
| 283 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
| 284 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 283 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
| 284 | + $this->object->addProduct($item->getId(), 1); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | |
| 288 | 288 | public function testAddProductConfigAttributeException() |
| 289 | 289 | { |
| 290 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 291 | - $this->object->addProduct( self::$testItem->getId(), 1, 'default', [], array( -1 ) ); |
|
| 290 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 291 | + $this->object->addProduct(self::$testItem->getId(), 1, 'default', [], array( -1 )); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | |
| 295 | 295 | public function testAddProductLowQuantityPriceException() |
| 296 | 296 | { |
| 297 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
| 297 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
| 298 | 298 | |
| 299 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
| 300 | - $this->object->addProduct( $item->getId(), 1 ); |
|
| 299 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
| 300 | + $this->object->addProduct($item->getId(), 1); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | public function testAddProductHigherQuantities() |
| 305 | 305 | { |
| 306 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
| 306 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
| 307 | 307 | |
| 308 | - $this->object->addProduct( $item->getId(), 2, 'default', [], [], [], [], 'unit_type3' ); |
|
| 308 | + $this->object->addProduct($item->getId(), 2, 'default', [], [], [], [], 'unit_type3'); |
|
| 309 | 309 | |
| 310 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
| 311 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
| 310 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
| 311 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
| 315 | 315 | public function testDeleteProductFlagError() |
| 316 | 316 | { |
| 317 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 317 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 318 | 318 | |
| 319 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 320 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
| 319 | + $item = $this->object->get()->getProduct(0); |
|
| 320 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
| 321 | 321 | |
| 322 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 323 | - $this->object->deleteProduct( 0 ); |
|
| 322 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 323 | + $this->object->deleteProduct(0); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | 327 | public function testEditProduct() |
| 328 | 328 | { |
| 329 | - $this->object->addProduct( self::$testItem->getId(), 1 ); |
|
| 329 | + $this->object->addProduct(self::$testItem->getId(), 1); |
|
| 330 | 330 | |
| 331 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 332 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
| 331 | + $item = $this->object->get()->getProduct(0); |
|
| 332 | + $this->assertEquals(1, $item->getQuantity()); |
|
| 333 | 333 | |
| 334 | - $this->object->editProduct( 0, 4 ); |
|
| 334 | + $this->object->editProduct(0, 4); |
|
| 335 | 335 | |
| 336 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 337 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
| 338 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
| 336 | + $item = $this->object->get()->getProduct(0); |
|
| 337 | + $this->assertEquals(4, $item->getQuantity()); |
|
| 338 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | |
| 342 | 342 | public function testEditProductAttributes() |
| 343 | 343 | { |
| 344 | 344 | $configAttrIds = []; |
| 345 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
| 345 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
| 346 | 346 | |
| 347 | 347 | $search = $attributeManager->createSearch(); |
| 348 | 348 | $conditions = array( |
| 349 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 350 | - $search->combine( '||', array( |
|
| 351 | - $search->combine( '&&', array( |
|
| 352 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
| 353 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
| 354 | - ) ), |
|
| 355 | - $search->combine( '&&', array( |
|
| 356 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
| 357 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
| 358 | - ) ), |
|
| 359 | - ) ) |
|
| 349 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 350 | + $search->combine('||', array( |
|
| 351 | + $search->combine('&&', array( |
|
| 352 | + $search->compare('==', 'attribute.code', 'xs'), |
|
| 353 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
| 354 | + )), |
|
| 355 | + $search->combine('&&', array( |
|
| 356 | + $search->compare('==', 'attribute.code', 'white'), |
|
| 357 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
| 358 | + )), |
|
| 359 | + )) |
|
| 360 | 360 | ); |
| 361 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
| 362 | - $attributes = $attributeManager->searchItems( $search ); |
|
| 361 | + $search->setConditions($search->combine('&&', $conditions)); |
|
| 362 | + $attributes = $attributeManager->searchItems($search); |
|
| 363 | 363 | |
| 364 | - if( empty( $attributes ) ) { |
|
| 365 | - throw new \RuntimeException( 'No attributes available' ); |
|
| 364 | + if (empty($attributes)) { |
|
| 365 | + throw new \RuntimeException('No attributes available'); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - foreach( $attributes as $id => $attribute ) { |
|
| 368 | + foreach ($attributes as $id => $attribute) { |
|
| 369 | 369 | $configAttrIds[$id] = 1; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
| 372 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
| 373 | 373 | |
| 374 | - $this->object->addProduct( $item->getId(), 1, 'default', [], $configAttrIds ); |
|
| 375 | - $this->object->editProduct( 0, 4 ); |
|
| 374 | + $this->object->addProduct($item->getId(), 1, 'default', [], $configAttrIds); |
|
| 375 | + $this->object->editProduct(0, 4); |
|
| 376 | 376 | |
| 377 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 378 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
| 379 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
| 377 | + $item = $this->object->get()->getProduct(0); |
|
| 378 | + $this->assertEquals(2, count($item->getAttributes())); |
|
| 379 | + $this->assertEquals(4, $item->getQuantity()); |
|
| 380 | 380 | |
| 381 | 381 | |
| 382 | - $this->object->editProduct( 0, 3, array( reset( $attributes )->getType() ) ); |
|
| 382 | + $this->object->editProduct(0, 3, array(reset($attributes)->getType())); |
|
| 383 | 383 | |
| 384 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 385 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
| 386 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
| 387 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
| 384 | + $item = $this->object->get()->getProduct(0); |
|
| 385 | + $this->assertEquals(3, $item->getQuantity()); |
|
| 386 | + $this->assertEquals(1, count($item->getAttributes())); |
|
| 387 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | |
| 391 | 391 | public function testEditProductFlagError() |
| 392 | 392 | { |
| 393 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 393 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 394 | 394 | |
| 395 | - $item = $this->object->get()->getProduct( 0 ); |
|
| 396 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
| 395 | + $item = $this->object->get()->getProduct(0); |
|
| 396 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
| 397 | 397 | |
| 398 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 399 | - $this->object->editProduct( 0, 4 ); |
|
| 398 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 399 | + $this->object->editProduct(0, 4); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | |
| 403 | 403 | public function testAddCoupon() |
| 404 | 404 | { |
| 405 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 406 | - $this->object->addCoupon( 'GHIJ' ); |
|
| 405 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 406 | + $this->object->addCoupon('GHIJ'); |
|
| 407 | 407 | |
| 408 | 408 | $basket = $this->object->get(); |
| 409 | 409 | |
| 410 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
| 410 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | |
| 414 | 414 | public function testAddCouponExceedCount() |
| 415 | 415 | { |
| 416 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 417 | - $this->object->addCoupon( 'GHIJ' ); |
|
| 416 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 417 | + $this->object->addCoupon('GHIJ'); |
|
| 418 | 418 | |
| 419 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 420 | - $this->object->addCoupon( 'GHIJ' ); |
|
| 419 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 420 | + $this->object->addCoupon('GHIJ'); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | |
| 424 | 424 | public function testAddCouponInvalidCode() |
| 425 | 425 | { |
| 426 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 427 | - $this->object->addCoupon( 'invalid' ); |
|
| 426 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 427 | + $this->object->addCoupon('invalid'); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | |
| 431 | 431 | public function testAddCouponMissingRequirements() |
| 432 | 432 | { |
| 433 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 434 | - $this->object->addCoupon( 'OPQR' ); |
|
| 433 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 434 | + $this->object->addCoupon('OPQR'); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | public function testDeleteCoupon() |
| 439 | 439 | { |
| 440 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 441 | - $this->object->addCoupon( '90AB' ); |
|
| 442 | - $this->object->deleteCoupon( '90AB' ); |
|
| 440 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 441 | + $this->object->addCoupon('90AB'); |
|
| 442 | + $this->object->deleteCoupon('90AB'); |
|
| 443 | 443 | |
| 444 | 444 | $basket = $this->object->get(); |
| 445 | 445 | |
| 446 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
| 446 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | |
| 450 | 450 | public function testSetAddressDelete() |
| 451 | 451 | { |
| 452 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
| 452 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
| 453 | 453 | |
| 454 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
| 455 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 454 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
| 455 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | |
| 459 | 459 | public function testSetBillingAddressByItem() |
| 460 | 460 | { |
| 461 | - $item = $this->getAddress( 'Example company' ); |
|
| 461 | + $item = $this->getAddress('Example company'); |
|
| 462 | 462 | |
| 463 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
| 463 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
| 464 | 464 | |
| 465 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 466 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 465 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 466 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | |
@@ -491,37 +491,37 @@ discard block |
||
| 491 | 491 | 'order.base.address.flag' => 0, |
| 492 | 492 | ); |
| 493 | 493 | |
| 494 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
| 494 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
| 495 | 495 | |
| 496 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 497 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 498 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
| 499 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
| 496 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 497 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 498 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
| 499 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | |
| 503 | 503 | public function testSetBillingAddressByArrayError() |
| 504 | 504 | { |
| 505 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 506 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
| 505 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 506 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | |
| 510 | 510 | public function testSetBillingAddressParameterError() |
| 511 | 511 | { |
| 512 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 513 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
| 512 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 513 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | |
| 517 | 517 | public function testSetDeliveryAddressByItem() |
| 518 | 518 | { |
| 519 | - $item = $this->getAddress( 'Example company' ); |
|
| 519 | + $item = $this->getAddress('Example company'); |
|
| 520 | 520 | |
| 521 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
| 521 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
| 522 | 522 | |
| 523 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 524 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 523 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 524 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | |
@@ -548,121 +548,121 @@ discard block |
||
| 548 | 548 | 'order.base.address.website' => 'www.example.com', |
| 549 | 549 | 'order.base.address.flag' => 0, |
| 550 | 550 | ); |
| 551 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
| 551 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
| 552 | 552 | |
| 553 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 554 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
| 555 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
| 556 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
| 553 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 554 | + $this->assertEquals('Example company', $address->getCompany()); |
|
| 555 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
| 556 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | |
| 560 | 560 | public function testSetDeliveryAddressByArrayError() |
| 561 | 561 | { |
| 562 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 563 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
| 562 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 563 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | |
| 567 | 567 | public function testSetDeliveryAddressTypeError() |
| 568 | 568 | { |
| 569 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 570 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
| 569 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 570 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | |
| 574 | 574 | public function testSetServicePayment() |
| 575 | 575 | { |
| 576 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 577 | - $service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
| 576 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 577 | + $service = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
| 578 | 578 | |
| 579 | - $this->object->addService( 'payment', $service->getId(), [] ); |
|
| 580 | - $item = $this->object->get()->getService( 'payment', 'unitpaymentcode' )->getCode(); |
|
| 581 | - $this->assertEquals( 'unitpaymentcode', $item ); |
|
| 579 | + $this->object->addService('payment', $service->getId(), []); |
|
| 580 | + $item = $this->object->get()->getService('payment', 'unitpaymentcode')->getCode(); |
|
| 581 | + $this->assertEquals('unitpaymentcode', $item); |
|
| 582 | 582 | |
| 583 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 584 | - $this->object->addService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
| 583 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 584 | + $this->object->addService('payment', $service->getId(), array('prepay' => true)); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | |
| 588 | 588 | public function testSetDeliveryOption() |
| 589 | 589 | { |
| 590 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 591 | - $service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 590 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 591 | + $service = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 592 | 592 | |
| 593 | - $this->object->addService( 'delivery', $service->getId(), [] ); |
|
| 594 | - $item = $this->object->get()->getService( 'delivery', 'unitcode' ); |
|
| 595 | - $this->assertEquals( 'unitcode', $item->getCode() ); |
|
| 593 | + $this->object->addService('delivery', $service->getId(), []); |
|
| 594 | + $item = $this->object->get()->getService('delivery', 'unitcode'); |
|
| 595 | + $this->assertEquals('unitcode', $item->getCode()); |
|
| 596 | 596 | |
| 597 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
| 598 | - $this->object->addService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
| 597 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
| 598 | + $this->object->addService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | |
| 602 | 602 | public function testCheckLocale() |
| 603 | 603 | { |
| 604 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
| 605 | - $payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
| 606 | - $delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
| 604 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
| 605 | + $payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
| 606 | + $delivery = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
| 607 | 607 | |
| 608 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
| 609 | - $this->object->addCoupon( 'OPQR' ); |
|
| 608 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
| 609 | + $this->object->addCoupon('OPQR'); |
|
| 610 | 610 | |
| 611 | - $this->object->addService( 'payment', $payment->getId() ); |
|
| 612 | - $this->object->addService( 'delivery', $delivery->getId() ); |
|
| 611 | + $this->object->addService('payment', $payment->getId()); |
|
| 612 | + $this->object->addService('delivery', $delivery->getId()); |
|
| 613 | 613 | |
| 614 | 614 | $basket = $this->object->get(); |
| 615 | 615 | $price = $basket->getPrice(); |
| 616 | 616 | |
| 617 | - foreach( $basket->getProducts() as $product ) |
|
| 617 | + foreach ($basket->getProducts() as $product) |
|
| 618 | 618 | { |
| 619 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
| 620 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
| 619 | + $this->assertEquals(2, $product->getQuantity()); |
|
| 620 | + $product->getPrice()->setCurrencyId('CHF'); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - $basket->getService( 'delivery', 'unitcode' )->getPrice()->setCurrencyId( 'CHF' ); |
|
| 624 | - $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->setCurrencyId( 'CHF' ); |
|
| 625 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
| 626 | - $price->setCurrencyId( 'CHF' ); |
|
| 623 | + $basket->getService('delivery', 'unitcode')->getPrice()->setCurrencyId('CHF'); |
|
| 624 | + $basket->getService('payment', 'unitpaymentcode')->getPrice()->setCurrencyId('CHF'); |
|
| 625 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
| 626 | + $price->setCurrencyId('CHF'); |
|
| 627 | 627 | |
| 628 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
| 629 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
| 628 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
| 629 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
| 630 | 630 | |
| 631 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
| 632 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
| 631 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
| 632 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
| 633 | 633 | |
| 634 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
| 634 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
| 635 | 635 | |
| 636 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
| 636 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
| 637 | 637 | $basket = $object->get(); |
| 638 | 638 | |
| 639 | - foreach( $basket->getProducts() as $product ) |
|
| 639 | + foreach ($basket->getProducts() as $product) |
|
| 640 | 640 | { |
| 641 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
| 642 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
| 641 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
| 642 | + $this->assertEquals(2, $product->getQuantity()); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - $this->assertEquals( 'EUR', $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->getCurrencyId() ); |
|
| 646 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery', 'unitcode' )->getPrice()->getCurrencyId() ); |
|
| 647 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
| 648 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
| 645 | + $this->assertEquals('EUR', $basket->getService('payment', 'unitpaymentcode')->getPrice()->getCurrencyId()); |
|
| 646 | + $this->assertEquals('EUR', $basket->getService('delivery', 'unitcode')->getPrice()->getCurrencyId()); |
|
| 647 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
| 648 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | |
| 652 | 652 | /** |
| 653 | 653 | * @param string $company |
| 654 | 654 | */ |
| 655 | - protected function getAddress( $company ) |
|
| 655 | + protected function getAddress($company) |
|
| 656 | 656 | { |
| 657 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
| 658 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
| 657 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
| 658 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
| 659 | 659 | |
| 660 | 660 | $search = $addressManager->createSearch(); |
| 661 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
| 662 | - $items = $addressManager->searchItems( $search ); |
|
| 661 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
| 662 | + $items = $addressManager->searchItems($search); |
|
| 663 | 663 | |
| 664 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 665 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
| 664 | + if (($item = reset($items)) === false) { |
|
| 665 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | return $item; |
@@ -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 | } |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 38 | 38 | */ |
| 39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
| 39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
| 41 | 41 | { |
| 42 | 42 | $context = $this->getContext(); |
| 43 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 43 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 44 | 44 | |
| 45 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'bundle' ) |
|
| 45 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'bundle') |
|
| 46 | 46 | { |
| 47 | 47 | return $this->getController()->addProduct( |
| 48 | 48 | $prodid, $quantity, $stocktype, $variantAttributeIds, |
@@ -51,29 +51,29 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $attributeMap = [ |
| 54 | - 'custom' => array_keys( $customAttributeValues ), |
|
| 55 | - 'config' => array_keys( $configAttributeIds ), |
|
| 54 | + 'custom' => array_keys($customAttributeValues), |
|
| 55 | + 'config' => array_keys($configAttributeIds), |
|
| 56 | 56 | 'hidden' => $hiddenAttributeIds, |
| 57 | 57 | ]; |
| 58 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
| 58 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
| 62 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 61 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
| 62 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 63 | 63 | |
| 64 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
| 65 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
| 64 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
| 65 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
| 66 | 66 | |
| 67 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
| 67 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
| 68 | 68 | |
| 69 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
| 70 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) ); |
|
| 71 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
| 69 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
| 70 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds)); |
|
| 71 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
| 72 | 72 | |
| 73 | - $orderBaseProductItem->setAttributes( $attr ); |
|
| 74 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
| 73 | + $orderBaseProductItem->setAttributes($attr); |
|
| 74 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
| 75 | 75 | |
| 76 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
| 76 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
| 77 | 77 | $this->getController()->save(); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -86,43 +86,43 @@ discard block |
||
| 86 | 86 | * @param array $variantAttributeIds List of product variant attribute IDs |
| 87 | 87 | * @param string $stocktype |
| 88 | 88 | */ |
| 89 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 90 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
| 89 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 90 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
| 91 | 91 | { |
| 92 | 92 | $quantity = $orderBaseProductItem->getQuantity(); |
| 93 | 93 | $products = $subProductIds = $orderProducts = []; |
| 94 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
| 94 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
| 95 | 95 | |
| 96 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
| 96 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
| 97 | 97 | $subProductIds[] = $item->getId(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if( count( $subProductIds ) > 0 ) |
|
| 100 | + if (count($subProductIds) > 0) |
|
| 101 | 101 | { |
| 102 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 102 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 103 | 103 | |
| 104 | - $search = $productManager->createSearch( true ); |
|
| 104 | + $search = $productManager->createSearch(true); |
|
| 105 | 105 | $expr = array( |
| 106 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 106 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 107 | 107 | $search->getConditions(), |
| 108 | 108 | ); |
| 109 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 109 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 110 | 110 | |
| 111 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
| 111 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - foreach( $products as $product ) |
|
| 114 | + foreach ($products as $product) |
|
| 115 | 115 | { |
| 116 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
| 116 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
| 117 | 117 | |
| 118 | 118 | $orderProduct = $orderProductManager->createItem(); |
| 119 | - $orderProduct->copyFrom( $product ); |
|
| 120 | - $orderProduct->setStockType( $stocktype ); |
|
| 121 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
| 119 | + $orderProduct->copyFrom($product); |
|
| 120 | + $orderProduct->setStockType($stocktype); |
|
| 121 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
| 122 | 122 | |
| 123 | 123 | $orderProducts[] = $orderProduct; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
| 126 | + $orderBaseProductItem->setProducts($orderProducts); |
|
| 127 | 127 | } |
| 128 | 128 | } |
@@ -36,26 +36,26 @@ |
||
| 36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 38 | 38 | */ |
| 39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
| 39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
| 41 | 41 | { |
| 42 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
| 42 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
| 43 | 43 | |
| 44 | - $search = $catalogListManager->createSearch( true ); |
|
| 44 | + $search = $catalogListManager->createSearch(true); |
|
| 45 | 45 | $expr = array( |
| 46 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
| 47 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
| 46 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
| 47 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
| 48 | 48 | $search->getConditions() |
| 49 | 49 | ); |
| 50 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 51 | - $search->setSlice( 0, 1 ); |
|
| 50 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 51 | + $search->setSlice(0, 1); |
|
| 52 | 52 | |
| 53 | - $result = $catalogListManager->searchItems( $search ); |
|
| 53 | + $result = $catalogListManager->searchItems($search); |
|
| 54 | 54 | |
| 55 | - if( reset( $result ) === false ) |
|
| 55 | + if (reset($result) === false) |
|
| 56 | 56 | { |
| 57 | - $msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid ); |
|
| 58 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 57 | + $msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid); |
|
| 58 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $this->getController()->addProduct( |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | * @param string $stocktype Unique code of the stock type to deliver the products from |
| 37 | 37 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
| 38 | 38 | */ |
| 39 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
| 39 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
| 40 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
| 41 | 41 | { |
| 42 | 42 | $context = $this->getContext(); |
| 43 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 44 | - $productItem = $productManager->getItem( $prodid, [], true ); |
|
| 43 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 44 | + $productItem = $productManager->getItem($prodid, [], true); |
|
| 45 | 45 | |
| 46 | - if( $productManager->getItem( $prodid, [], true )->getType() !== 'select' ) |
|
| 46 | + if ($productManager->getItem($prodid, [], true)->getType() !== 'select') |
|
| 47 | 47 | { |
| 48 | 48 | return $this->getController()->addProduct( |
| 49 | 49 | $prodid, $quantity, $stocktype, $variantAttributeIds, |
@@ -51,29 +51,29 @@ discard block |
||
| 51 | 51 | ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
| 55 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 54 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
| 55 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 56 | 56 | |
| 57 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
| 58 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
| 57 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
| 58 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
| 59 | 59 | |
| 60 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds ); |
|
| 60 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds); |
|
| 61 | 61 | |
| 62 | 62 | $attributeMap = [ |
| 63 | - 'custom' => array_keys( $customAttributeValues ), |
|
| 64 | - 'config' => array_keys( $configAttributeIds ), |
|
| 63 | + 'custom' => array_keys($customAttributeValues), |
|
| 64 | + 'config' => array_keys($configAttributeIds), |
|
| 65 | 65 | 'hidden' => $hiddenAttributeIds, |
| 66 | 66 | ]; |
| 67 | - $this->checkListRef( array( $prodid, $productItem->getId() ), 'attribute', $attributeMap ); |
|
| 67 | + $this->checkListRef(array($prodid, $productItem->getId()), 'attribute', $attributeMap); |
|
| 68 | 68 | |
| 69 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ) ); |
|
| 70 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) ); |
|
| 71 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
| 69 | + $attr = array_merge($attr, $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues)); |
|
| 70 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds)); |
|
| 71 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
| 72 | 72 | |
| 73 | - $orderBaseProductItem->setAttributes( $attr ); |
|
| 74 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
| 73 | + $orderBaseProductItem->setAttributes($attr); |
|
| 74 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
| 75 | 75 | |
| 76 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
| 76 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
| 77 | 77 | $this->getController()->save(); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
| 89 | 89 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
| 90 | 90 | */ |
| 91 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 92 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds ) |
|
| 91 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
| 92 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds) |
|
| 93 | 93 | { |
| 94 | 94 | $attr = []; |
| 95 | 95 | $context = $this->getContext(); |
| 96 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
| 96 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
| 97 | 97 | |
| 98 | 98 | /** controller/frontend/basket/require-variant |
| 99 | 99 | * A variant of a selection product must be chosen |
@@ -114,47 +114,47 @@ discard block |
||
| 114 | 114 | * @category Developer |
| 115 | 115 | * @category User |
| 116 | 116 | */ |
| 117 | - $requireVariant = $context->getConfig()->get( 'controller/frontend/basket/require-variant', true ); |
|
| 117 | + $requireVariant = $context->getConfig()->get('controller/frontend/basket/require-variant', true); |
|
| 118 | 118 | |
| 119 | 119 | |
| 120 | - if( count( $productItems ) > 1 ) |
|
| 120 | + if (count($productItems) > 1) |
|
| 121 | 121 | { |
| 122 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
| 123 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 122 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
| 123 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 124 | 124 | } |
| 125 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
| 125 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
| 126 | 126 | { |
| 127 | 127 | $productItem = $result; |
| 128 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
| 128 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
| 129 | 129 | |
| 130 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
| 130 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
| 131 | 131 | |
| 132 | - if( !empty( $subprices ) ) { |
|
| 132 | + if (!empty($subprices)) { |
|
| 133 | 133 | $prices = $subprices; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $submedia = $productItem->getRefItems( 'media', 'default', 'default' ); |
|
| 136 | + $submedia = $productItem->getRefItems('media', 'default', 'default'); |
|
| 137 | 137 | |
| 138 | - if( ( $mediaItem = reset( $submedia ) ) !== false ) { |
|
| 139 | - $orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() ); |
|
| 138 | + if (($mediaItem = reset($submedia)) !== false) { |
|
| 139 | + $orderBaseProductItem->setMediaUrl($mediaItem->getPreview()); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
| 143 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
| 142 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
| 143 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
| 144 | 144 | |
| 145 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
| 145 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
| 146 | 146 | { |
| 147 | 147 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
| 148 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
| 149 | - $orderAttributeItem->setType( 'variant' ); |
|
| 148 | + $orderAttributeItem->copyFrom($attrItem); |
|
| 149 | + $orderAttributeItem->setType('variant'); |
|
| 150 | 150 | |
| 151 | 151 | $attr[] = $orderAttributeItem; |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | - else if( $requireVariant != false ) // count == 0 |
|
| 154 | + else if ($requireVariant != false) // count == 0 |
|
| 155 | 155 | { |
| 156 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
| 157 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
| 156 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
| 157 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | return $attr; |
@@ -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 | |
@@ -136,41 +136,41 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @param string $type Basket type |
| 138 | 138 | */ |
| 139 | - protected function checkLocale( $type ) |
|
| 139 | + protected function checkLocale($type) |
|
| 140 | 140 | { |
| 141 | 141 | $errors = []; |
| 142 | 142 | $context = $this->getContext(); |
| 143 | 143 | $session = $context->getSession(); |
| 144 | 144 | $locale = $this->get()->getLocale(); |
| 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\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
| 163 | - $basket = $manager->getSession( $type ); |
|
| 162 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('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,7 +256,7 @@ discard block |
||
| 256 | 256 | { |
| 257 | 257 | $attrIds = []; |
| 258 | 258 | |
| 259 | - foreach( $product->getAttributes() as $attrItem ) { |
|
| 259 | + foreach ($product->getAttributes() as $attrItem) { |
|
| 260 | 260 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -264,22 +264,22 @@ discard block |
||
| 264 | 264 | $product->getProductId(), |
| 265 | 265 | $product->getQuantity(), |
| 266 | 266 | $product->getStockType(), |
| 267 | - $this->getValue( $attrIds, 'variant', [] ), |
|
| 268 | - $this->getValue( $attrIds, 'config', [] ), |
|
| 269 | - $this->getValue( $attrIds, 'hidden', [] ), |
|
| 270 | - $this->getValue( $attrIds, 'custom', [] ) |
|
| 267 | + $this->getValue($attrIds, 'variant', []), |
|
| 268 | + $this->getValue($attrIds, 'config', []), |
|
| 269 | + $this->getValue($attrIds, 'hidden', []), |
|
| 270 | + $this->getValue($attrIds, 'custom', []) |
|
| 271 | 271 | ); |
| 272 | 272 | |
| 273 | - $basket->deleteProduct( $pos ); |
|
| 273 | + $basket->deleteProduct($pos); |
|
| 274 | 274 | } |
| 275 | - catch( \Exception $e ) |
|
| 275 | + catch (\Exception $e) |
|
| 276 | 276 | { |
| 277 | 277 | $code = $product->getProductCode(); |
| 278 | 278 | $logger = $this->getContext()->getLogger(); |
| 279 | 279 | $errors['product'][$pos] = $e->getMessage(); |
| 280 | 280 | |
| 281 | 281 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
| 282 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
| 282 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
@@ -294,24 +294,24 @@ discard block |
||
| 294 | 294 | * @param array $errors Associative list of previous errors |
| 295 | 295 | * @return array Associative list of errors occured |
| 296 | 296 | */ |
| 297 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
| 297 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
| 298 | 298 | { |
| 299 | - foreach( $basket->getServices() as $type => $list ) |
|
| 299 | + foreach ($basket->getServices() as $type => $list) |
|
| 300 | 300 | { |
| 301 | - foreach( $list as $item ) |
|
| 301 | + foreach ($list as $item) |
|
| 302 | 302 | { |
| 303 | 303 | try |
| 304 | 304 | { |
| 305 | 305 | $attributes = []; |
| 306 | 306 | |
| 307 | - foreach( $item->getAttributes() as $attrItem ) { |
|
| 307 | + foreach ($item->getAttributes() as $attrItem) { |
|
| 308 | 308 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - $this->addService( $type, $item->getServiceId(), $attributes ); |
|
| 312 | - $basket->deleteService( $type ); |
|
| 311 | + $this->addService($type, $item->getServiceId(), $attributes); |
|
| 312 | + $basket->deleteService($type); |
|
| 313 | 313 | } |
| 314 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
| 314 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
@@ -327,32 +327,32 @@ discard block |
||
| 327 | 327 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
| 328 | 328 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
| 329 | 329 | */ |
| 330 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
| 330 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
| 331 | 331 | { |
| 332 | - if( empty( $attributeIds ) ) { |
|
| 332 | + if (empty($attributeIds)) { |
|
| 333 | 333 | return []; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 336 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 337 | 337 | |
| 338 | - $search = $attributeManager->createSearch( true ); |
|
| 338 | + $search = $attributeManager->createSearch(true); |
|
| 339 | 339 | $expr = array( |
| 340 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
| 340 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
| 341 | 341 | $search->getConditions(), |
| 342 | 342 | ); |
| 343 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 344 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 343 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 344 | + $search->setSlice(0, 0x7fffffff); |
|
| 345 | 345 | |
| 346 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
| 346 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
| 347 | 347 | |
| 348 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
| 348 | + if (count($attrItems) !== count($attributeIds)) |
|
| 349 | 349 | { |
| 350 | 350 | $i18n = $this->getContext()->getI18n(); |
| 351 | - $expected = implode( ',', $attributeIds ); |
|
| 352 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
| 353 | - $msg = $i18n->dt( 'controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"' ); |
|
| 351 | + $expected = implode(',', $attributeIds); |
|
| 352 | + $actual = implode(',', array_keys($attrItems)); |
|
| 353 | + $msg = $i18n->dt('controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"'); |
|
| 354 | 354 | |
| 355 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $actual, $expected ) ); |
|
| 355 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $actual, $expected)); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | return $attrItems; |
@@ -365,31 +365,31 @@ discard block |
||
| 365 | 365 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
| 366 | 366 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
| 367 | 367 | */ |
| 368 | - protected function getAttributeItems( array $orderAttributes ) |
|
| 368 | + protected function getAttributeItems(array $orderAttributes) |
|
| 369 | 369 | { |
| 370 | - if( empty( $orderAttributes ) ) { |
|
| 370 | + if (empty($orderAttributes)) { |
|
| 371 | 371 | return []; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
| 375 | - $search = $attributeManager->createSearch( true ); |
|
| 374 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
| 375 | + $search = $attributeManager->createSearch(true); |
|
| 376 | 376 | $expr = []; |
| 377 | 377 | |
| 378 | - foreach( $orderAttributes as $item ) |
|
| 378 | + foreach ($orderAttributes as $item) |
|
| 379 | 379 | { |
| 380 | 380 | $tmp = array( |
| 381 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
| 382 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
| 383 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
| 384 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
| 385 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
| 381 | + $search->compare('==', 'attribute.domain', 'product'), |
|
| 382 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
| 383 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
| 384 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
| 385 | + $search->compare('>', 'attribute.type.status', 0), |
|
| 386 | 386 | $search->getConditions(), |
| 387 | 387 | ); |
| 388 | - $expr[] = $search->combine( '&&', $tmp ); |
|
| 388 | + $expr[] = $search->combine('&&', $tmp); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
| 392 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
| 391 | + $search->setConditions($search->combine('||', $expr)); |
|
| 392 | + return $attributeManager->searchItems($search, array('price')); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -402,24 +402,24 @@ discard block |
||
| 402 | 402 | * @param array $quantities Associative list of attribute IDs as keys and their quantities as values |
| 403 | 403 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
| 404 | 404 | */ |
| 405 | - protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] ) |
|
| 405 | + protected function getOrderProductAttributes($type, array $ids, array $values = [], array $quantities = []) |
|
| 406 | 406 | { |
| 407 | - if( empty( $ids ) ) { |
|
| 407 | + if (empty($ids)) { |
|
| 408 | 408 | return []; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | $list = []; |
| 412 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
| 412 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
| 413 | 413 | |
| 414 | - foreach( $this->getAttributes( $ids ) as $id => $attrItem ) |
|
| 414 | + foreach ($this->getAttributes($ids) as $id => $attrItem) |
|
| 415 | 415 | { |
| 416 | 416 | $item = $manager->createItem(); |
| 417 | - $item->copyFrom( $attrItem ); |
|
| 418 | - $item->setType( $type ); |
|
| 419 | - $item->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 ); |
|
| 417 | + $item->copyFrom($attrItem); |
|
| 418 | + $item->setType($type); |
|
| 419 | + $item->setQuantity(isset($quantities[$id]) ? $quantities[$id] : 1); |
|
| 420 | 420 | |
| 421 | - if( isset( $values[$id] ) ) { |
|
| 422 | - $item->setValue( $values[$id] ); |
|
| 421 | + if (isset($values[$id])) { |
|
| 422 | + $item->setValue($values[$id]); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | $list[] = $item; |
@@ -436,23 +436,23 @@ discard block |
||
| 436 | 436 | * @param string $code Code of the list type |
| 437 | 437 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
| 438 | 438 | */ |
| 439 | - protected function getProductListTypeItem( $domain, $code ) |
|
| 439 | + protected function getProductListTypeItem($domain, $code) |
|
| 440 | 440 | { |
| 441 | 441 | $context = $this->getContext(); |
| 442 | 442 | |
| 443 | - if( empty( $this->listTypeItems ) ) |
|
| 443 | + if (empty($this->listTypeItems)) |
|
| 444 | 444 | { |
| 445 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' ); |
|
| 445 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type'); |
|
| 446 | 446 | |
| 447 | - foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) { |
|
| 448 | - $this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item; |
|
| 447 | + foreach ($manager->searchItems($manager->createSearch(true)) as $item) { |
|
| 448 | + $this->listTypeItems[$item->getDomain()][$item->getCode()] = $item; |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - if( !isset( $this->listTypeItems[$domain][$code] ) ) |
|
| 452 | + if (!isset($this->listTypeItems[$domain][$code])) |
|
| 453 | 453 | { |
| 454 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found' ); |
|
| 455 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, $code ) ); |
|
| 454 | + $msg = $context->getI18n()->dt('controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found'); |
|
| 455 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, $code)); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | return $this->listTypeItems[$domain][$code]; |
@@ -467,43 +467,43 @@ discard block |
||
| 467 | 467 | * @param array $domains Names of the domain items that should be fetched too |
| 468 | 468 | * @return array List of products matching the given attributes |
| 469 | 469 | */ |
| 470 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 471 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
| 470 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
| 471 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
| 472 | 472 | { |
| 473 | 473 | $subProductIds = []; |
| 474 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
| 474 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
| 475 | 475 | $subProductIds[] = $item->getId(); |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - if( count( $subProductIds ) === 0 ) { |
|
| 478 | + if (count($subProductIds) === 0) { |
|
| 479 | 479 | return []; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
| 483 | - $search = $productManager->createSearch( true ); |
|
| 482 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
| 483 | + $search = $productManager->createSearch(true); |
|
| 484 | 484 | |
| 485 | 485 | $expr = array( |
| 486 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
| 486 | + $search->compare('==', 'product.id', $subProductIds), |
|
| 487 | 487 | $search->getConditions(), |
| 488 | 488 | ); |
| 489 | 489 | |
| 490 | - if( count( $variantAttributeIds ) > 0 ) |
|
| 490 | + if (count($variantAttributeIds) > 0) |
|
| 491 | 491 | { |
| 492 | - foreach( $variantAttributeIds as $key => $id ) { |
|
| 492 | + foreach ($variantAttributeIds as $key => $id) { |
|
| 493 | 493 | $variantAttributeIds[$key] = (string) $id; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
| 496 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
| 497 | 497 | |
| 498 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
| 499 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
| 498 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
| 499 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
| 500 | 500 | |
| 501 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
| 501 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 504 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 505 | 505 | |
| 506 | - return $productManager->searchItems( $search, $domains ); |
|
| 506 | + return $productManager->searchItems($search, $domains); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | * @param mixed $default Default value if no value is available for the given name |
| 516 | 516 | * @return mixed Value from the array or default value |
| 517 | 517 | */ |
| 518 | - protected function getValue( array $values, $name, $default = null ) |
|
| 518 | + protected function getValue(array $values, $name, $default = null) |
|
| 519 | 519 | { |
| 520 | - if( isset( $values[$name] ) ) { |
|
| 520 | + if (isset($values[$name])) { |
|
| 521 | 521 | return $values[$name]; |
| 522 | 522 | } |
| 523 | 523 | |
@@ -28,33 +28,33 @@ discard block |
||
| 28 | 28 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
| 29 | 29 | * @since 2017.04 |
| 30 | 30 | */ |
| 31 | - public function addItem( array $values ) |
|
| 31 | + public function addItem(array $values) |
|
| 32 | 32 | { |
| 33 | 33 | $list = []; |
| 34 | 34 | $context = $this->getContext(); |
| 35 | 35 | $config = $context->getConfig(); |
| 36 | 36 | |
| 37 | 37 | // Show only generated passwords in account creation e-mails |
| 38 | - $pass = ( isset( $values['customer.password'] ) ? false : true ); |
|
| 38 | + $pass = (isset($values['customer.password']) ? false : true); |
|
| 39 | 39 | |
| 40 | - foreach( $values as $key => $val ) { |
|
| 41 | - $list[str_replace( 'order.base.address', 'customer', $key )] = $val; |
|
| 40 | + foreach ($values as $key => $val) { |
|
| 41 | + $list[str_replace('order.base.address', 'customer', $key)] = $val; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 45 | - $list = $this->addItemDefaults( $list ); |
|
| 44 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 45 | + $list = $this->addItemDefaults($list); |
|
| 46 | 46 | |
| 47 | 47 | try |
| 48 | 48 | { |
| 49 | - $item = $manager->findItem( $list['customer.code'] ); |
|
| 49 | + $item = $manager->findItem($list['customer.code']); |
|
| 50 | 50 | } |
| 51 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 51 | + catch (\Aimeos\MShop\Exception $e) |
|
| 52 | 52 | { |
| 53 | - $this->checkLimit( $list ); |
|
| 53 | + $this->checkLimit($list); |
|
| 54 | 54 | |
| 55 | 55 | $item = $manager->createItem(); |
| 56 | - $item->fromArray( $list ); |
|
| 57 | - $item->setId( null ); |
|
| 56 | + $item->fromArray($list); |
|
| 57 | + $item->setId(null); |
|
| 58 | 58 | |
| 59 | 59 | /** controller/frontend/customer/groupids |
| 60 | 60 | * List of groups new customers should be assigned to |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | * @category User |
| 69 | 69 | * @category Developer |
| 70 | 70 | */ |
| 71 | - $item->setGroups( (array) $config->get( 'controller/frontend/customer/groupids', [] ) ); |
|
| 71 | + $item->setGroups((array) $config->get('controller/frontend/customer/groupids', [])); |
|
| 72 | 72 | |
| 73 | - $item = $manager->saveItem( $item ); |
|
| 73 | + $item = $manager->saveItem($item); |
|
| 74 | 74 | |
| 75 | 75 | $msg = $item->toArray(); |
| 76 | - $msg['customer.password'] = ( $pass ? $list['customer.password'] : null ); |
|
| 77 | - $context->getMessageQueue( 'mq-email', 'customer/email/account' )->add( json_encode( $msg ) ); |
|
| 76 | + $msg['customer.password'] = ($pass ? $list['customer.password'] : null); |
|
| 77 | + $context->getMessageQueue('mq-email', 'customer/email/account')->add(json_encode($msg)); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | return $item; |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
| 88 | 88 | */ |
| 89 | - public function createItem( array $values = [] ) |
|
| 89 | + public function createItem(array $values = []) |
|
| 90 | 90 | { |
| 91 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
| 91 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
| 92 | 92 | |
| 93 | 93 | $item = $manager->createItem(); |
| 94 | - $item->fromArray( $values ); |
|
| 95 | - $item->setId( null ); |
|
| 96 | - $item->setStatus( 1 ); |
|
| 94 | + $item->fromArray($values); |
|
| 95 | + $item->setId(null); |
|
| 96 | + $item->setStatus(1); |
|
| 97 | 97 | |
| 98 | 98 | return $item; |
| 99 | 99 | } |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | * @param string $id Unique customer ID |
| 106 | 106 | * @since 2017.04 |
| 107 | 107 | */ |
| 108 | - public function deleteItem( $id ) |
|
| 108 | + public function deleteItem($id) |
|
| 109 | 109 | { |
| 110 | - $this->checkUser( $id ); |
|
| 110 | + $this->checkUser($id); |
|
| 111 | 111 | |
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
| 113 | - $manager->deleteItem( $id ); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
| 113 | + $manager->deleteItem($id); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
| 123 | 123 | * @since 2017.04 |
| 124 | 124 | */ |
| 125 | - public function editItem( $id, array $values ) |
|
| 125 | + public function editItem($id, array $values) |
|
| 126 | 126 | { |
| 127 | - $this->checkUser( $id ); |
|
| 127 | + $this->checkUser($id); |
|
| 128 | 128 | |
| 129 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
| 130 | - $item = $manager->getItem( $id, ['customer/group'], true ); |
|
| 129 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
| 130 | + $item = $manager->getItem($id, ['customer/group'], true); |
|
| 131 | 131 | |
| 132 | - unset( $values['customer.id'] ); |
|
| 133 | - $item->fromArray( $values ); |
|
| 132 | + unset($values['customer.id']); |
|
| 133 | + $item->fromArray($values); |
|
| 134 | 134 | |
| 135 | - return $manager->saveItem( $item ); |
|
| 135 | + return $manager->saveItem($item); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -144,17 +144,17 @@ discard block |
||
| 144 | 144 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
| 145 | 145 | * @since 2017.04 |
| 146 | 146 | */ |
| 147 | - public function getItem( $id = null, array $domains = [] ) |
|
| 147 | + public function getItem($id = null, array $domains = []) |
|
| 148 | 148 | { |
| 149 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
| 149 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
| 150 | 150 | |
| 151 | - if( $id == null ) { |
|
| 152 | - return $manager->getItem( $this->getContext()->getUserId(), $domains, true ); |
|
| 151 | + if ($id == null) { |
|
| 152 | + return $manager->getItem($this->getContext()->getUserId(), $domains, true); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - $this->checkUser( $id ); |
|
| 155 | + $this->checkUser($id); |
|
| 156 | 156 | |
| 157 | - return $manager->getItem( $id, $domains, true ); |
|
| 157 | + return $manager->getItem($id, $domains, true); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
| 169 | 169 | * @since 2017.04 |
| 170 | 170 | */ |
| 171 | - public function findItem( $code, array $domains = [] ) |
|
| 171 | + public function findItem($code, array $domains = []) |
|
| 172 | 172 | { |
| 173 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->findItem( $code, $domains ); |
|
| 173 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->findItem($code, $domains); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item |
| 181 | 181 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID |
| 182 | 182 | */ |
| 183 | - public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ) |
|
| 183 | + public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item) |
|
| 184 | 184 | { |
| 185 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->saveItem( $item ); |
|
| 185 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->saveItem($item); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -193,17 +193,17 @@ discard block |
||
| 193 | 193 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 194 | 194 | * @since 2017.04 |
| 195 | 195 | */ |
| 196 | - public function addAddressItem( array $values ) |
|
| 196 | + public function addAddressItem(array $values) |
|
| 197 | 197 | { |
| 198 | 198 | $context = $this->getContext(); |
| 199 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
| 199 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
| 200 | 200 | |
| 201 | 201 | $item = $manager->createItem(); |
| 202 | - $item->fromArray( $values ); |
|
| 203 | - $item->setId( null ); |
|
| 204 | - $item->setParentId( $context->getUserId() ); |
|
| 202 | + $item->fromArray($values); |
|
| 203 | + $item->setId(null); |
|
| 204 | + $item->setParentId($context->getUserId()); |
|
| 205 | 205 | |
| 206 | - return $manager->saveItem( $item ); |
|
| 206 | + return $manager->saveItem($item); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | |
@@ -212,16 +212,16 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 214 | 214 | */ |
| 215 | - public function createAddressItem( array $values = [] ) |
|
| 215 | + public function createAddressItem(array $values = []) |
|
| 216 | 216 | { |
| 217 | 217 | $context = $this->getContext(); |
| 218 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
| 218 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
| 219 | 219 | |
| 220 | 220 | $item = $manager->createItem(); |
| 221 | - $item->fromArray( $values ); |
|
| 222 | - $item->setId( null ); |
|
| 221 | + $item->fromArray($values); |
|
| 222 | + $item->setId(null); |
|
| 223 | 223 | |
| 224 | - $item->setParentId( $context->getUserId() ); |
|
| 224 | + $item->setParentId($context->getUserId()); |
|
| 225 | 225 | |
| 226 | 226 | return $item; |
| 227 | 227 | } |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | * @param string $id Unique customer address ID |
| 234 | 234 | * @since 2017.04 |
| 235 | 235 | */ |
| 236 | - public function deleteAddressItem( $id ) |
|
| 236 | + public function deleteAddressItem($id) |
|
| 237 | 237 | { |
| 238 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
| 238 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
| 239 | 239 | |
| 240 | - $this->checkUser( $manager->getItem( $id, [], true )->getParentId() ); |
|
| 240 | + $this->checkUser($manager->getItem($id, [], true)->getParentId()); |
|
| 241 | 241 | |
| 242 | - $manager->deleteItem( $id ); |
|
| 242 | + $manager->deleteItem($id); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 252 | 252 | * @since 2017.04 |
| 253 | 253 | */ |
| 254 | - public function editAddressItem( $id, array $values ) |
|
| 254 | + public function editAddressItem($id, array $values) |
|
| 255 | 255 | { |
| 256 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
| 256 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
| 257 | 257 | |
| 258 | - $item = $manager->getItem( $id, [], true ); |
|
| 259 | - $this->checkUser( $item->getParentId() ); |
|
| 258 | + $item = $manager->getItem($id, [], true); |
|
| 259 | + $this->checkUser($item->getParentId()); |
|
| 260 | 260 | |
| 261 | - unset( $values['customer.address.id'] ); |
|
| 262 | - $item->fromArray( $values ); |
|
| 261 | + unset($values['customer.address.id']); |
|
| 262 | + $item->fromArray($values); |
|
| 263 | 263 | |
| 264 | - return $manager->saveItem( $item ); |
|
| 264 | + return $manager->saveItem($item); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 273 | 273 | * @since 2017.04 |
| 274 | 274 | */ |
| 275 | - public function getAddressItem( $id ) |
|
| 275 | + public function getAddressItem($id) |
|
| 276 | 276 | { |
| 277 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
| 277 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
| 278 | 278 | |
| 279 | - $item = $manager->getItem( $id ); |
|
| 280 | - $this->checkUser( $item->getParentId() ); |
|
| 279 | + $item = $manager->getItem($id); |
|
| 280 | + $this->checkUser($item->getParentId()); |
|
| 281 | 281 | |
| 282 | 282 | return $item; |
| 283 | 283 | } |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | * @param \Aimeos\MShop\Customer\Item\Address\Iface $item Customer address item |
| 290 | 290 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID |
| 291 | 291 | */ |
| 292 | - public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ) |
|
| 292 | + public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item) |
|
| 293 | 293 | { |
| 294 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' )->saveItem( $item ); |
|
| 294 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address')->saveItem($item); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | |
@@ -302,32 +302,32 @@ discard block |
||
| 302 | 302 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
| 303 | 303 | * @since 2017.06 |
| 304 | 304 | */ |
| 305 | - public function addListItem( array $values ) |
|
| 305 | + public function addListItem(array $values) |
|
| 306 | 306 | { |
| 307 | 307 | $context = $this->getContext(); |
| 308 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 308 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
| 309 | 309 | |
| 310 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
| 310 | + if (!isset($values['customer.lists.typeid'])) |
|
| 311 | 311 | { |
| 312 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
| 313 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
| 312 | + if (!isset($values['customer.lists.type'])) { |
|
| 313 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
| 317 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
| 316 | + if (!isset($values['customer.lists.domain'])) { |
|
| 317 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' ); |
|
| 321 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
| 320 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type'); |
|
| 321 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
| 322 | 322 | $values['customer.lists.typeid'] = $typeItem->getId(); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | $item = $manager->createItem(); |
| 326 | - $item->fromArray( $values ); |
|
| 327 | - $item->setId( null ); |
|
| 328 | - $item->setParentId( $context->getUserId() ); |
|
| 326 | + $item->fromArray($values); |
|
| 327 | + $item->setId(null); |
|
| 328 | + $item->setParentId($context->getUserId()); |
|
| 329 | 329 | |
| 330 | - return $manager->saveItem( $item ); |
|
| 330 | + return $manager->saveItem($item); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | |
@@ -340,10 +340,10 @@ discard block |
||
| 340 | 340 | public function createListsFilter() |
| 341 | 341 | { |
| 342 | 342 | $context = $this->getContext(); |
| 343 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 343 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
| 344 | 344 | |
| 345 | 345 | $filter = $manager->createSearch(); |
| 346 | - $filter->setConditions( $filter->compare( '==', 'customer.lists.parentid', $context->getUserId() ) ); |
|
| 346 | + $filter->setConditions($filter->compare('==', 'customer.lists.parentid', $context->getUserId())); |
|
| 347 | 347 | |
| 348 | 348 | return $filter; |
| 349 | 349 | } |
@@ -355,13 +355,13 @@ discard block |
||
| 355 | 355 | * @param string $id Unique customer address ID |
| 356 | 356 | * @since 2017.06 |
| 357 | 357 | */ |
| 358 | - public function deleteListItem( $id ) |
|
| 358 | + public function deleteListItem($id) |
|
| 359 | 359 | { |
| 360 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
| 360 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
| 361 | 361 | |
| 362 | - $this->checkUser( $manager->getItem( $id )->getParentId() ); |
|
| 362 | + $this->checkUser($manager->getItem($id)->getParentId()); |
|
| 363 | 363 | |
| 364 | - $manager->deleteItem( $id ); |
|
| 364 | + $manager->deleteItem($id); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | |
@@ -373,33 +373,33 @@ discard block |
||
| 373 | 373 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
| 374 | 374 | * @since 2017.06 |
| 375 | 375 | */ |
| 376 | - public function editListItem( $id, array $values ) |
|
| 376 | + public function editListItem($id, array $values) |
|
| 377 | 377 | { |
| 378 | 378 | $context = $this->getContext(); |
| 379 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 379 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
| 380 | 380 | |
| 381 | - $item = $manager->getItem( $id, [], true ); |
|
| 382 | - $this->checkUser( $item->getParentId() ); |
|
| 381 | + $item = $manager->getItem($id, [], true); |
|
| 382 | + $this->checkUser($item->getParentId()); |
|
| 383 | 383 | |
| 384 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
| 384 | + if (!isset($values['customer.lists.typeid'])) |
|
| 385 | 385 | { |
| 386 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
| 387 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
| 386 | + if (!isset($values['customer.lists.type'])) { |
|
| 387 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
| 391 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
| 390 | + if (!isset($values['customer.lists.domain'])) { |
|
| 391 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' ); |
|
| 395 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
| 394 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type'); |
|
| 395 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
| 396 | 396 | $values['customer.lists.typeid'] = $typeItem->getId(); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - unset( $values['customer.lists.id'] ); |
|
| 400 | - $item->fromArray( $values ); |
|
| 399 | + unset($values['customer.lists.id']); |
|
| 400 | + $item->fromArray($values); |
|
| 401 | 401 | |
| 402 | - return $manager->saveItem( $item ); |
|
| 402 | + return $manager->saveItem($item); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
@@ -410,12 +410,12 @@ discard block |
||
| 410 | 410 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
| 411 | 411 | * @since 2017.06 |
| 412 | 412 | */ |
| 413 | - public function getListItem( $id ) |
|
| 413 | + public function getListItem($id) |
|
| 414 | 414 | { |
| 415 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
| 416 | - $item = $manager->getItem( $id ); |
|
| 415 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
| 416 | + $item = $manager->getItem($id); |
|
| 417 | 417 | |
| 418 | - $this->checkUser( $item->getParentId() ); |
|
| 418 | + $this->checkUser($item->getParentId()); |
|
| 419 | 419 | |
| 420 | 420 | return $item; |
| 421 | 421 | } |
@@ -429,11 +429,11 @@ discard block |
||
| 429 | 429 | * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items |
| 430 | 430 | * @since 2017.06 |
| 431 | 431 | */ |
| 432 | - public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
| 432 | + public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
| 433 | 433 | { |
| 434 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
| 434 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
| 435 | 435 | |
| 436 | - return $manager->searchItems( $filter, [], $total ); |
|
| 436 | + return $manager->searchItems($filter, [], $total); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | |
@@ -443,37 +443,37 @@ discard block |
||
| 443 | 443 | * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values |
| 444 | 444 | * @return string[] Associative list of customer key/value pairs with default values set |
| 445 | 445 | */ |
| 446 | - protected function addItemDefaults( array $values ) |
|
| 446 | + protected function addItemDefaults(array $values) |
|
| 447 | 447 | { |
| 448 | - if( !isset( $values['customer.label'] ) || $values['customer.label'] == '' ) |
|
| 448 | + if (!isset($values['customer.label']) || $values['customer.label'] == '') |
|
| 449 | 449 | { |
| 450 | 450 | $label = ''; |
| 451 | 451 | |
| 452 | - if( isset( $values['customer.lastname'] ) ) { |
|
| 452 | + if (isset($values['customer.lastname'])) { |
|
| 453 | 453 | $label = $values['customer.lastname']; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if( isset( $values['customer.firstname'] ) && $values['customer.firstname'] != '' ) { |
|
| 456 | + if (isset($values['customer.firstname']) && $values['customer.firstname'] != '') { |
|
| 457 | 457 | $label = $values['customer.firstname'] . ' ' . $label; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if( isset( $values['customer.company'] ) && $values['customer.company'] != '' ) { |
|
| 460 | + if (isset($values['customer.company']) && $values['customer.company'] != '') { |
|
| 461 | 461 | $label .= ' (' . $values['customer.company'] . ')'; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | $values['customer.label'] = $label; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - if( !isset( $values['customer.code'] ) && isset( $values['customer.email'] ) ) { |
|
| 467 | + if (!isset($values['customer.code']) && isset($values['customer.email'])) { |
|
| 468 | 468 | $values['customer.code'] = $values['customer.email']; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - if( !isset( $values['customer.status'] ) ) { |
|
| 471 | + if (!isset($values['customer.status'])) { |
|
| 472 | 472 | $values['customer.status'] = 1; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if( !isset( $values['customer.password'] ) ) { |
|
| 476 | - $values['customer.password'] = substr( md5( microtime( true ) . getmypid() . rand() ), -8 ); |
|
| 475 | + if (!isset($values['customer.password'])) { |
|
| 476 | + $values['customer.password'] = substr(md5(microtime(true) . getmypid() . rand()), -8); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | return $values; |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values |
| 487 | 487 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
| 488 | 488 | */ |
| 489 | - protected function checkLimit( array $values ) |
|
| 489 | + protected function checkLimit(array $values) |
|
| 490 | 490 | { |
| 491 | 491 | $total = 0; |
| 492 | 492 | $context = $this->getContext(); |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @category Developer |
| 508 | 508 | * @see controller/frontend/customer/limit-seconds |
| 509 | 509 | */ |
| 510 | - $count = $config->get( 'controller/frontend/customer/limit-count', 5 ); |
|
| 510 | + $count = $config->get('controller/frontend/customer/limit-count', 5); |
|
| 511 | 511 | |
| 512 | 512 | /** controller/frontend/customer/limit-seconds |
| 513 | 513 | * Customer account limitation time frame in seconds |
@@ -525,22 +525,22 @@ discard block |
||
| 525 | 525 | * @category Developer |
| 526 | 526 | * @see controller/frontend/customer/limit-count |
| 527 | 527 | */ |
| 528 | - $seconds = $config->get( 'controller/frontend/customer/limit-seconds', 300 ); |
|
| 528 | + $seconds = $config->get('controller/frontend/customer/limit-seconds', 300); |
|
| 529 | 529 | |
| 530 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 530 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 531 | 531 | |
| 532 | 532 | $search = $manager->createSearch(); |
| 533 | 533 | $expr = [ |
| 534 | - $search->compare( '==', 'customer.editor', $context->getEditor() ), |
|
| 535 | - $search->compare( '>=', 'customer.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
| 534 | + $search->compare('==', 'customer.editor', $context->getEditor()), |
|
| 535 | + $search->compare('>=', 'customer.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
| 536 | 536 | ]; |
| 537 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 538 | - $search->setSlice( 0, 0 ); |
|
| 537 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 538 | + $search->setSlice(0, 0); |
|
| 539 | 539 | |
| 540 | - $manager->searchItems( $search, [], $total ); |
|
| 540 | + $manager->searchItems($search, [], $total); |
|
| 541 | 541 | |
| 542 | - if( $total > $count ) { |
|
| 543 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Temporary limit reached' ) ); |
|
| 542 | + if ($total > $count) { |
|
| 543 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Temporary limit reached')); |
|
| 544 | 544 | } |
| 545 | 545 | } |
| 546 | 546 | |
@@ -551,12 +551,12 @@ discard block |
||
| 551 | 551 | * @param string $id Unique customer ID |
| 552 | 552 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
| 553 | 553 | */ |
| 554 | - protected function checkUser( $id ) |
|
| 554 | + protected function checkUser($id) |
|
| 555 | 555 | { |
| 556 | - if( $id != $this->getContext()->getUserId() ) |
|
| 556 | + if ($id != $this->getContext()->getUserId()) |
|
| 557 | 557 | { |
| 558 | - $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); |
|
| 559 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); |
|
| 558 | + $msg = sprintf('Not allowed to access customer data for ID "%1$s"', $id); |
|
| 559 | + throw new \Aimeos\Controller\Frontend\Customer\Exception($msg); |
|
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | } |
@@ -31,42 +31,42 @@ 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( !empty( $attrIds ) ) |
|
| 36 | + if (!empty($attrIds)) |
|
| 37 | 37 | { |
| 38 | - $attrIds = $this->validateIds( $attrIds ); |
|
| 38 | + $attrIds = $this->validateIds($attrIds); |
|
| 39 | 39 | |
| 40 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) ); |
|
| 40 | + $func = $filter->createFunction('index.attributeaggregate', array($attrIds)); |
|
| 41 | 41 | $expr = array( |
| 42 | - $filter->compare( '==', $func, count( $attrIds ) ), |
|
| 42 | + $filter->compare('==', $func, count($attrIds)), |
|
| 43 | 43 | $filter->getConditions(), |
| 44 | 44 | ); |
| 45 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 45 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if( !empty( $optIds ) ) |
|
| 48 | + if (!empty($optIds)) |
|
| 49 | 49 | { |
| 50 | - $optIds = $this->validateIds( $optIds ); |
|
| 50 | + $optIds = $this->validateIds($optIds); |
|
| 51 | 51 | |
| 52 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) ); |
|
| 52 | + $func = $filter->createFunction('index.attributeaggregate', array($optIds)); |
|
| 53 | 53 | $expr = array( |
| 54 | - $filter->compare( '>', $func, 0 ), |
|
| 54 | + $filter->compare('>', $func, 0), |
|
| 55 | 55 | $filter->getConditions(), |
| 56 | 56 | ); |
| 57 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 57 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - foreach( $oneIds as $type => $list ) |
|
| 60 | + foreach ($oneIds as $type => $list) |
|
| 61 | 61 | { |
| 62 | - if( ( $list = $this->validateIds( (array) $list ) ) !== [] ) |
|
| 62 | + if (($list = $this->validateIds((array) $list)) !== []) |
|
| 63 | 63 | { |
| 64 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $list ) ); |
|
| 64 | + $func = $filter->createFunction('index.attributeaggregate', array($list)); |
|
| 65 | 65 | $expr = array( |
| 66 | - $filter->compare( '>', $func, 0 ), |
|
| 66 | + $filter->compare('>', $func, 0), |
|
| 67 | 67 | $filter->getConditions(), |
| 68 | 68 | ); |
| 69 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 69 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -86,38 +86,38 @@ discard block |
||
| 86 | 86 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 87 | 87 | * @since 2017.03 |
| 88 | 88 | */ |
| 89 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
| 90 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ) |
|
| 89 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
| 90 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default') |
|
| 91 | 91 | { |
| 92 | - $catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId ); |
|
| 92 | + $catIds = (!is_array($catId) ? explode(',', $catId) : $catId); |
|
| 93 | 93 | |
| 94 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
| 94 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
| 95 | 95 | { |
| 96 | 96 | $list = []; |
| 97 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
| 97 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
| 98 | 98 | |
| 99 | - foreach( $catIds as $catId ) |
|
| 99 | + foreach ($catIds as $catId) |
|
| 100 | 100 | { |
| 101 | - $tree = $cntl->getTree( $catId, [], $level ); |
|
| 102 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
| 101 | + $tree = $cntl->getTree($catId, [], $level); |
|
| 102 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $catIds = $list; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) ); |
|
| 108 | + $expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds))); |
|
| 109 | 109 | $expr[] = $filter->getConditions(); |
| 110 | 110 | |
| 111 | - if( $sort === 'relevance' ) |
|
| 111 | + if ($sort === 'relevance') |
|
| 112 | 112 | { |
| 113 | - $cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) ); |
|
| 114 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
| 113 | + $cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds)); |
|
| 114 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
| 115 | 115 | |
| 116 | - $sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) ); |
|
| 117 | - $filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) ); |
|
| 116 | + $sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds)); |
|
| 117 | + $filter->setSortations(array($filter->sort($direction, $sortfunc))); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 120 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
| 121 | 121 | |
| 122 | 122 | return $filter; |
| 123 | 123 | } |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 135 | 135 | * @since 2017.03 |
| 136 | 136 | */ |
| 137 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ) |
|
| 137 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default') |
|
| 138 | 138 | { |
| 139 | 139 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
| 140 | - $cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ); |
|
| 141 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
| 140 | + $cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input)); |
|
| 141 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
| 142 | 142 | |
| 143 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
| 143 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | * @return array Associative list of key values as key and the product count for this key as value |
| 153 | 153 | * @since 2017.03 |
| 154 | 154 | */ |
| 155 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
| 155 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
| 156 | 156 | { |
| 157 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
| 157 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
| 170 | 170 | * @since 2017.03 |
| 171 | 171 | */ |
| 172 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
| 172 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
| 173 | 173 | { |
| 174 | 174 | $sortations = []; |
| 175 | 175 | $context = $this->getContext(); |
| 176 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); |
|
| 176 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'index'); |
|
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | /** controller/frontend/product/ignore-dates |
@@ -188,55 +188,55 @@ discard block |
||
| 188 | 188 | * @since 2017.10 |
| 189 | 189 | * @category Developer |
| 190 | 190 | */ |
| 191 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
| 191 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
| 192 | 192 | { |
| 193 | 193 | $search = $manager->createSearch(); |
| 194 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
| 194 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
| 195 | 195 | } |
| 196 | 196 | else |
| 197 | 197 | { |
| 198 | - $search = $manager->createSearch( true ); |
|
| 198 | + $search = $manager->createSearch(true); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
| 202 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
| 202 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
| 203 | 203 | |
| 204 | - switch( $sort ) |
|
| 204 | + switch ($sort) |
|
| 205 | 205 | { |
| 206 | 206 | case 'code': |
| 207 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
| 207 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
| 208 | 208 | break; |
| 209 | 209 | |
| 210 | 210 | case 'ctime': |
| 211 | - $sortations[] = $search->sort( $direction, 'product.ctime' ); |
|
| 211 | + $sortations[] = $search->sort($direction, 'product.ctime'); |
|
| 212 | 212 | break; |
| 213 | 213 | |
| 214 | 214 | case 'name': |
| 215 | 215 | $langid = $context->getLocale()->getLanguageId(); |
| 216 | 216 | |
| 217 | - $cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) ); |
|
| 218 | - $expr[] = $search->compare( '>=', $cmpfunc, '' ); |
|
| 217 | + $cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product')); |
|
| 218 | + $expr[] = $search->compare('>=', $cmpfunc, ''); |
|
| 219 | 219 | |
| 220 | - $sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) ); |
|
| 221 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
| 220 | + $sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name')); |
|
| 221 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
| 222 | 222 | break; |
| 223 | 223 | |
| 224 | 224 | case 'price': |
| 225 | 225 | $currencyid = $context->getLocale()->getCurrencyId(); |
| 226 | 226 | |
| 227 | - $cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
| 228 | - $expr[] = $search->compare( '>=', $cmpfunc, '0.00' ); |
|
| 227 | + $cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default')); |
|
| 228 | + $expr[] = $search->compare('>=', $cmpfunc, '0.00'); |
|
| 229 | 229 | |
| 230 | - $sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
| 231 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
| 230 | + $sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default')); |
|
| 231 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
| 232 | 232 | break; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | $expr[] = $search->getConditions(); |
| 236 | 236 | |
| 237 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 238 | - $search->setSortations( $sortations ); |
|
| 239 | - $search->setSlice( $start, $size ); |
|
| 237 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 238 | + $search->setSortations($sortations); |
|
| 239 | + $search->setSlice($start, $size); |
|
| 240 | 240 | |
| 241 | 241 | return $search; |
| 242 | 242 | } |
@@ -250,15 +250,15 @@ discard block |
||
| 250 | 250 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
| 251 | 251 | * @since 2017.03 |
| 252 | 252 | */ |
| 253 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
| 253 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
| 254 | 254 | { |
| 255 | - $items = $this->getItems( [$productId], $domains ); |
|
| 255 | + $items = $this->getItems([$productId], $domains); |
|
| 256 | 256 | |
| 257 | - if( ( $item = reset( $items ) ) !== false ) { |
|
| 257 | + if (($item = reset($items)) !== false) { |
|
| 258 | 258 | return $item; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) ); |
|
| 261 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId)); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | |
@@ -270,10 +270,10 @@ discard block |
||
| 270 | 270 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
| 271 | 271 | * @since 2017.03 |
| 272 | 272 | */ |
| 273 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
| 273 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
| 274 | 274 | { |
| 275 | 275 | $context = $this->getContext(); |
| 276 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 276 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 277 | 277 | |
| 278 | 278 | /** controller/frontend/order/ignore-dates |
| 279 | 279 | * Ignore start and end dates of products |
@@ -287,24 +287,24 @@ discard block |
||
| 287 | 287 | * @since 2017.08 |
| 288 | 288 | * @category Developer |
| 289 | 289 | */ |
| 290 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
| 290 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
| 291 | 291 | { |
| 292 | 292 | $search = $manager->createSearch(); |
| 293 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
| 293 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
| 294 | 294 | } |
| 295 | 295 | else |
| 296 | 296 | { |
| 297 | - $search = $manager->createSearch( true ); |
|
| 297 | + $search = $manager->createSearch(true); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | $expr = array( |
| 301 | - $search->compare( '==', 'product.id', $productIds ), |
|
| 301 | + $search->compare('==', 'product.id', $productIds), |
|
| 302 | 302 | $search->getConditions(), |
| 303 | 303 | ); |
| 304 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 305 | - $search->setSlice( 0, count( $productIds ) ); |
|
| 304 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 305 | + $search->setSlice(0, count($productIds)); |
|
| 306 | 306 | |
| 307 | - return $manager->searchItems( $search, $domains ); |
|
| 307 | + return $manager->searchItems($search, $domains); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | |
@@ -317,9 +317,9 @@ discard block |
||
| 317 | 317 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
| 318 | 318 | * @since 2017.03 |
| 319 | 319 | */ |
| 320 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
| 320 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
| 321 | 321 | { |
| 322 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
| 322 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -329,12 +329,12 @@ discard block |
||
| 329 | 329 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
| 330 | 330 | * @return array List of catalog IDs |
| 331 | 331 | */ |
| 332 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
| 332 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
| 333 | 333 | { |
| 334 | - $list = array( $item->getId() ); |
|
| 334 | + $list = array($item->getId()); |
|
| 335 | 335 | |
| 336 | - foreach( $item->getChildren() as $child ) { |
|
| 337 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
| 336 | + foreach ($item->getChildren() as $child) { |
|
| 337 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | return $list; |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | * @param array $ids List of IDs to validate |
| 348 | 348 | * @return array List of validated IDs |
| 349 | 349 | */ |
| 350 | - protected function validateIds( array $ids ) |
|
| 350 | + protected function validateIds(array $ids) |
|
| 351 | 351 | { |
| 352 | 352 | $list = []; |
| 353 | 353 | |
| 354 | - foreach( $ids as $id ) |
|
| 354 | + foreach ($ids as $id) |
|
| 355 | 355 | { |
| 356 | - if( $id != '' ) { |
|
| 356 | + if ($id != '') { |
|
| 357 | 357 | $list[] = (int) $id; |
| 358 | 358 | } |
| 359 | 359 | } |