@@ -1,12 +1,12 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>, |
|
4 | -<?php elseif( isset( $this->data ) ) : ?> |
|
5 | - "data": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>, |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>, |
|
4 | +<?php elseif (isset($this->data)) : ?> |
|
5 | + "data": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>, |
|
6 | 6 | <?php endif; ?> |
7 | 7 | |
8 | 8 | "meta": { |
9 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
9 | + "total": <?php echo $this->get('total', 0); ?> |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJadm::getContext(); |
17 | 17 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
18 | 18 | |
19 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
19 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
20 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJadm::getContext(); |
27 | 27 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
28 | 28 | |
29 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
30 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
29 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
30 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJadm::getContext(); |
37 | 37 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
38 | 38 | |
39 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '' ); |
|
40 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
39 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, ''); |
|
40 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | $context = \TestHelperJadm::getContext(); |
47 | 47 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
48 | 48 | |
49 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
50 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '%^' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
50 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '%^'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -56,68 +56,68 @@ discard block |
||
56 | 56 | $context = \TestHelperJadm::getContext(); |
57 | 57 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
58 | 58 | |
59 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
60 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '', '%^' ); |
|
59 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
60 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '', '%^'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function testClear() |
65 | 65 | { |
66 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
66 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
67 | 67 | |
68 | 68 | $context = \TestHelperJadm::getContext(); |
69 | 69 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
70 | 70 | |
71 | - $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
71 | + $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
72 | 72 | \Aimeos\Admin\JsonAdm\Factory::clear(); |
73 | - $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
73 | + $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
74 | 74 | |
75 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
75 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
76 | 76 | |
77 | - $this->assertNotSame( $client1, $client2 ); |
|
77 | + $this->assertNotSame($client1, $client2); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testClearSite() |
82 | 82 | { |
83 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
83 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
84 | 84 | |
85 | 85 | $context = \TestHelperJadm::getContext(); |
86 | 86 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
87 | 87 | |
88 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
89 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
90 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context ); |
|
88 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
89 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
90 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context); |
|
91 | 91 | |
92 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
93 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
92 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
93 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
94 | 94 | |
95 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
95 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
96 | 96 | |
97 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
98 | - $this->assertNotSame( $cntlB1, $cntlB2 ); |
|
97 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
98 | + $this->assertNotSame($cntlB1, $cntlB2); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | public function testClearSpecific() |
103 | 103 | { |
104 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
104 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
105 | 105 | |
106 | 106 | $context = \TestHelperJadm::getContext(); |
107 | 107 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
108 | 108 | |
109 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
110 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
109 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
110 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
111 | 111 | |
112 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context, 'order' ); |
|
112 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context, 'order'); |
|
113 | 113 | |
114 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
115 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
114 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
115 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
116 | 116 | |
117 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
117 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
118 | 118 | |
119 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
120 | - $this->assertSame( $cntlB1, $cntlB2 ); |
|
119 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
120 | + $this->assertSame($cntlB1, $cntlB2); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | } |
124 | 124 | \ No newline at end of file |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
34 | 34 | * @param string $path Path describing the client to clear, e.g. "product/lists/type" |
35 | 35 | */ |
36 | - static public function clear( $id = null, $path = null ) |
|
36 | + static public function clear($id = null, $path = null) |
|
37 | 37 | { |
38 | - if( $id !== null ) |
|
38 | + if ($id !== null) |
|
39 | 39 | { |
40 | - if( $path !== null ) { |
|
40 | + if ($path !== null) { |
|
41 | 41 | self::$clients[$id][$path] = null; |
42 | 42 | } else { |
43 | 43 | self::$clients[$id] = array(); |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
66 | 66 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
67 | 67 | */ |
68 | - static public function createClient( \Aimeos\MShop\Context\Item\Iface $context, |
|
69 | - array $templatePaths, $path, $name = null ) |
|
68 | + static public function createClient(\Aimeos\MShop\Context\Item\Iface $context, |
|
69 | + array $templatePaths, $path, $name = null) |
|
70 | 70 | { |
71 | - $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); |
|
71 | + $path = strtolower(trim($path, "/ \n\t\r\0\x0B")); |
|
72 | 72 | |
73 | - if( empty( $path ) ) { |
|
74 | - return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name ); |
|
73 | + if (empty($path)) { |
|
74 | + return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $id = (string) $context; |
78 | 78 | |
79 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) { |
|
80 | - self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name ); |
|
79 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) { |
|
80 | + self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return self::$clients[$id][$path]; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param boolean $value True to enable caching, false to disable it. |
91 | 91 | * @return boolean Previous cache setting |
92 | 92 | */ |
93 | - static public function setCache( $value ) |
|
93 | + static public function setCache($value) |
|
94 | 94 | { |
95 | 95 | $old = self::$cache; |
96 | 96 | self::$cache = (boolean) $value; |
@@ -109,37 +109,37 @@ discard block |
||
109 | 109 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
110 | 110 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
111 | 111 | */ |
112 | - protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context, |
|
113 | - array $templatePaths, $path, $name ) |
|
112 | + protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context, |
|
113 | + array $templatePaths, $path, $name) |
|
114 | 114 | { |
115 | - $parts = explode( '/', $path ); |
|
115 | + $parts = explode('/', $path); |
|
116 | 116 | |
117 | - foreach( $parts as $key => $part ) |
|
117 | + foreach ($parts as $key => $part) |
|
118 | 118 | { |
119 | - if( ctype_alnum( $part ) === false ) |
|
119 | + if (ctype_alnum($part) === false) |
|
120 | 120 | { |
121 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
122 | - throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 ); |
|
121 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
122 | + throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400); |
|
123 | 123 | } |
124 | 124 | |
125 | - $parts[$key] = ucwords( $part ); |
|
125 | + $parts[$key] = ucwords($part); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
129 | 129 | $view = $context->getView(); |
130 | - $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\Factory'; |
|
130 | + $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\Factory'; |
|
131 | 131 | |
132 | - if( class_exists( $factory ) === true ) |
|
132 | + if (class_exists($factory) === true) |
|
133 | 133 | { |
134 | - $args = array( $context, $view, $templatePaths, $path, $name ); |
|
134 | + $args = array($context, $view, $templatePaths, $path, $name); |
|
135 | 135 | |
136 | - if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
|
137 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
|
136 | + if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) { |
|
137 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid factory "%1$s"', $factory), 400); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
142 | - $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
|
142 | + $client = self::createClientRoot($context, $view, $templatePaths, $path, $name); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $client; |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
158 | 158 | * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created |
159 | 159 | */ |
160 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
161 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null ) |
|
160 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
161 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) |
|
162 | 162 | { |
163 | 163 | /** admin/jsonadm/name |
164 | 164 | * Class name of the used JSON API client implementation |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | * @since 2015.12 |
194 | 194 | * @category Developer |
195 | 195 | */ |
196 | - if( $name === null ) { |
|
197 | - $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
|
196 | + if ($name === null) { |
|
197 | + $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); |
|
198 | 198 | } |
199 | 199 | |
200 | - if( ctype_alnum( $name ) === false ) |
|
200 | + if (ctype_alnum($name) === false) |
|
201 | 201 | { |
202 | - $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
203 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
202 | + $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
203 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
207 | 207 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
208 | 208 | |
209 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
209 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
210 | 210 | |
211 | 211 | /** admin/jsonadm/decorators/excludes |
212 | 212 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -286,6 +286,6 @@ discard block |
||
286 | 286 | * @see admin/jsonadm/decorators/global |
287 | 287 | */ |
288 | 288 | |
289 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
289 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
290 | 290 | } |
291 | 291 | } |
@@ -136,8 +136,7 @@ |
||
136 | 136 | if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
137 | 137 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
138 | 138 | } |
139 | - } |
|
140 | - else |
|
139 | + } else |
|
141 | 140 | { |
142 | 141 | $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
143 | 142 | } |
@@ -19,77 +19,77 @@ discard block |
||
19 | 19 | $this->context = \TestHelperJadm::getContext(); |
20 | 20 | $config = $this->context->getConfig(); |
21 | 21 | |
22 | - $config->set( 'admin/jsonadm/common/decorators/default', array() ); |
|
23 | - $config->set( 'admin/jsonadm/decorators/global', array() ); |
|
24 | - $config->set( 'admin/jsonadm/decorators/local', array() ); |
|
22 | + $config->set('admin/jsonadm/common/decorators/default', array()); |
|
23 | + $config->set('admin/jsonadm/decorators/global', array()); |
|
24 | + $config->set('admin/jsonadm/decorators/local', array()); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testInjectClient() |
30 | 30 | { |
31 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
32 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
31 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
32 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
33 | 33 | |
34 | - $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
34 | + $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
35 | 35 | |
36 | - $this->assertSame( $cntl, $iCntl ); |
|
36 | + $this->assertSame($cntl, $iCntl); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testInjectClientReset() |
41 | 41 | { |
42 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
43 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
44 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', null ); |
|
42 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
43 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
44 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', null); |
|
45 | 45 | |
46 | - $new = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
46 | + $new = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
47 | 47 | |
48 | - $this->assertNotSame( $cntl, $new ); |
|
48 | + $this->assertNotSame($cntl, $new); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | public function testAddDecoratorsInvalidName() |
53 | 53 | { |
54 | - $decorators = array( '$' ); |
|
54 | + $decorators = array('$'); |
|
55 | 55 | $view = $this->context->getView(); |
56 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
56 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
57 | 57 | |
58 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
59 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute' ); |
|
58 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
59 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | 63 | public function testAddDecoratorsInvalidClass() |
64 | 64 | { |
65 | - $decorators = array( 'Test' ); |
|
65 | + $decorators = array('Test'); |
|
66 | 66 | $view = $this->context->getView(); |
67 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
67 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
68 | 68 | |
69 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
70 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute' ); |
|
69 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
70 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testAddDecoratorsInvalidInterface() |
75 | 75 | { |
76 | - $decorators = array( 'Test' ); |
|
76 | + $decorators = array('Test'); |
|
77 | 77 | $view = $this->context->getView(); |
78 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
78 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
79 | 79 | |
80 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
81 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, |
|
82 | - '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute' ); |
|
80 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
81 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, |
|
82 | + '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testAddClientDecoratorsExcludes() |
87 | 87 | { |
88 | - $this->context->getConfig()->set( 'admin/jsonadm/decorators/excludes', array( 'TestDecorator' ) ); |
|
89 | - $this->context->getConfig()->set( 'admin/jsonadm/common/decorators/default', array( 'TestDecorator' ) ); |
|
88 | + $this->context->getConfig()->set('admin/jsonadm/decorators/excludes', array('TestDecorator')); |
|
89 | + $this->context->getConfig()->set('admin/jsonadm/common/decorators/default', array('TestDecorator')); |
|
90 | 90 | |
91 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
92 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
91 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
92 | + \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @param string $classprefix |
102 | 102 | * @param string $path |
103 | 103 | */ |
104 | - public static function addDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
105 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
104 | + public static function addDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
105 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
106 | 106 | { |
107 | - self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
|
107 | + self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); |
|
108 | 108 | } |
109 | 109 | |
110 | - public static function addClientDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, |
|
111 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
110 | + public static function addClientDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, |
|
111 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
112 | 112 | { |
113 | - self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
113 | + self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Product\Standard( $this->context, $this->view, $templatePaths, 'product' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Product\Standard($this->context, $this->view, $templatePaths, 'product'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,34 +30,34 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'product.code' => 'CNE' ) |
|
33 | + '==' => array('product.code' => 'CNE') |
|
34 | 34 | ), |
35 | 35 | 'include' => 'text,product,product/property,product/stock' |
36 | 36 | ); |
37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
38 | - $this->view->addHelper( 'param', $helper ); |
|
37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
38 | + $this->view->addHelper('param', $helper); |
|
39 | 39 | |
40 | 40 | $header = array(); |
41 | 41 | $status = 500; |
42 | 42 | |
43 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
44 | - |
|
45 | - $this->assertEquals( 200, $status ); |
|
46 | - $this->assertEquals( 1, count( $header ) ); |
|
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) ); |
|
51 | - $this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['text'][0]['data']['links'] ); |
|
52 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['product'] ) ); |
|
53 | - $this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['product'][0]['data']['links'] ); |
|
54 | - $this->assertEquals( 4, count( $result['data'][0]['relationships']['product/property'] ) ); |
|
55 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['product/stock'] ) ); |
|
56 | - $this->assertEquals( 15, count( $result['included'] ) ); |
|
57 | - $this->assertEquals( 'product/property', $result['included'][0]['type'] ); |
|
58 | - $this->assertArrayHaskey( 'self', $result['included'][0]['links'] ); |
|
59 | - $this->assertArrayHaskey( 'related', $result['included'][0]['links'] ); |
|
60 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
43 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
44 | + |
|
45 | + $this->assertEquals(200, $status); |
|
46 | + $this->assertEquals(1, count($header)); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(6, count($result['data'][0]['relationships']['text'])); |
|
51 | + $this->assertArrayHaskey('self', $result['data'][0]['relationships']['text'][0]['data']['links']); |
|
52 | + $this->assertEquals(5, count($result['data'][0]['relationships']['product'])); |
|
53 | + $this->assertArrayHaskey('self', $result['data'][0]['relationships']['product'][0]['data']['links']); |
|
54 | + $this->assertEquals(4, count($result['data'][0]['relationships']['product/property'])); |
|
55 | + $this->assertEquals(1, count($result['data'][0]['relationships']['product/stock'])); |
|
56 | + $this->assertEquals(15, count($result['included'])); |
|
57 | + $this->assertEquals('product/property', $result['included'][0]['type']); |
|
58 | + $this->assertArrayHaskey('self', $result['included'][0]['links']); |
|
59 | + $this->assertArrayHaskey('related', $result['included'][0]['links']); |
|
60 | + $this->assertArrayNotHasKey('errors', $result); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -70,22 +70,22 @@ discard block |
||
70 | 70 | 'sort' => 'product.id', |
71 | 71 | 'include' => 'product,product/stock' |
72 | 72 | ); |
73 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
74 | - $this->view->addHelper( 'param', $helper ); |
|
73 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
74 | + $this->view->addHelper('param', $helper); |
|
75 | 75 | |
76 | 76 | $header = array(); |
77 | 77 | $status = 500; |
78 | 78 | |
79 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
80 | - |
|
81 | - $this->assertEquals( 200, $status ); |
|
82 | - $this->assertEquals( 1, count( $header ) ); |
|
83 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
84 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
85 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
86 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
87 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['product'] ) ); |
|
88 | - $this->assertEquals( 27, count( $result['included'] ) ); |
|
89 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
79 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
80 | + |
|
81 | + $this->assertEquals(200, $status); |
|
82 | + $this->assertEquals(1, count($header)); |
|
83 | + $this->assertEquals(28, $result['meta']['total']); |
|
84 | + $this->assertEquals(25, count($result['data'])); |
|
85 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
86 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
87 | + $this->assertEquals(5, count($result['data'][0]['relationships']['product'])); |
|
88 | + $this->assertEquals(27, count($result['included'])); |
|
89 | + $this->assertArrayNotHasKey('errors', $result); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,42 +34,42 @@ discard block |
||
34 | 34 | |
35 | 35 | public function testDelete() |
36 | 36 | { |
37 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ); |
|
37 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem'); |
|
38 | 38 | |
39 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
40 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
41 | - $this->view->addHelper( 'param', $helper ); |
|
39 | + $params = array('id' => $this->getProductItem()->getId()); |
|
40 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
41 | + $this->view->addHelper('param', $helper); |
|
42 | 42 | |
43 | 43 | $header = array(); |
44 | 44 | $status = 500; |
45 | 45 | |
46 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
46 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
47 | 47 | |
48 | - $this->assertEquals( 200, $status ); |
|
49 | - $this->assertEquals( 1, count( $header ) ); |
|
50 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
51 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
52 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
48 | + $this->assertEquals(200, $status); |
|
49 | + $this->assertEquals(1, count($header)); |
|
50 | + $this->assertEquals(1, $result['meta']['total']); |
|
51 | + $this->assertArrayNotHasKey('included', $result); |
|
52 | + $this->assertArrayNotHasKey('data', $result); |
|
53 | + $this->assertArrayNotHasKey('errors', $result); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | public function testDeleteBulk() |
58 | 58 | { |
59 | - $this->getProductMock( array( 'deleteItems' ) )->expects( $this->once() )->method( 'deleteItems' ); |
|
59 | + $this->getProductMock(array('deleteItems'))->expects($this->once())->method('deleteItems'); |
|
60 | 60 | |
61 | 61 | $body = '{"data":[{"type": "product", "id": "-1"},{"type": "product", "id": "-2"}]}'; |
62 | 62 | $header = array(); |
63 | 63 | $status = 500; |
64 | 64 | |
65 | - $result = json_decode( $this->object->delete( $body, $header, $status ), true ); |
|
65 | + $result = json_decode($this->object->delete($body, $header, $status), true); |
|
66 | 66 | |
67 | - $this->assertEquals( 200, $status ); |
|
68 | - $this->assertEquals( 1, count( $header ) ); |
|
69 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
70 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
71 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
72 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
67 | + $this->assertEquals(200, $status); |
|
68 | + $this->assertEquals(1, count($header)); |
|
69 | + $this->assertEquals(2, $result['meta']['total']); |
|
70 | + $this->assertArrayNotHasKey('included', $result); |
|
71 | + $this->assertArrayNotHasKey('data', $result); |
|
72 | + $this->assertArrayNotHasKey('errors', $result); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -79,52 +79,52 @@ discard block |
||
79 | 79 | $header = array(); |
80 | 80 | $status = 500; |
81 | 81 | |
82 | - $result = json_decode( $this->object->delete( $body, $header, $status ), true ); |
|
82 | + $result = json_decode($this->object->delete($body, $header, $status), true); |
|
83 | 83 | |
84 | - $this->assertEquals( 400, $status ); |
|
85 | - $this->assertEquals( 1, count( $header ) ); |
|
86 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
87 | - $this->assertArrayHasKey( 'errors', $result ); |
|
88 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
89 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
84 | + $this->assertEquals(400, $status); |
|
85 | + $this->assertEquals(1, count($header)); |
|
86 | + $this->assertEquals(0, $result['meta']['total']); |
|
87 | + $this->assertArrayHasKey('errors', $result); |
|
88 | + $this->assertArrayNotHasKey('included', $result); |
|
89 | + $this->assertArrayNotHasKey('data', $result); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | public function testDeleteException() |
94 | 94 | { |
95 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
96 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
95 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
96 | + ->will($this->throwException(new \Exception('test exception'))); |
|
97 | 97 | |
98 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
99 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
100 | - $this->view->addHelper( 'param', $helper ); |
|
98 | + $params = array('id' => $this->getProductItem()->getId()); |
|
99 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
100 | + $this->view->addHelper('param', $helper); |
|
101 | 101 | |
102 | 102 | $header = array(); |
103 | 103 | $status = 500; |
104 | 104 | |
105 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
105 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
106 | 106 | |
107 | - $this->assertEquals( 500, $status ); |
|
108 | - $this->assertArrayHasKey( 'errors', $result ); |
|
107 | + $this->assertEquals(500, $status); |
|
108 | + $this->assertArrayHasKey('errors', $result); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | 112 | public function testDeleteMShopException() |
113 | 113 | { |
114 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
115 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
114 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
115 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
116 | 116 | |
117 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
118 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
119 | - $this->view->addHelper( 'param', $helper ); |
|
117 | + $params = array('id' => $this->getProductItem()->getId()); |
|
118 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
119 | + $this->view->addHelper('param', $helper); |
|
120 | 120 | |
121 | 121 | $header = array(); |
122 | 122 | $status = 500; |
123 | 123 | |
124 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
124 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
125 | 125 | |
126 | - $this->assertEquals( 404, $status ); |
|
127 | - $this->assertArrayHasKey( 'errors', $result ); |
|
126 | + $this->assertEquals(404, $status); |
|
127 | + $this->assertArrayHasKey('errors', $result); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | $header = array(); |
134 | 134 | $status = 500; |
135 | 135 | |
136 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
136 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
137 | 137 | |
138 | - $this->assertEquals( 200, $status ); |
|
139 | - $this->assertEquals( 1, count( $header ) ); |
|
140 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
141 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
142 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
143 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
144 | - $this->assertArrayHasKey( 'next', $result['links'] ); |
|
145 | - $this->assertArrayHasKey( 'last', $result['links'] ); |
|
146 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
147 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
138 | + $this->assertEquals(200, $status); |
|
139 | + $this->assertEquals(1, count($header)); |
|
140 | + $this->assertEquals(28, $result['meta']['total']); |
|
141 | + $this->assertEquals(25, count($result['data'])); |
|
142 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
143 | + $this->assertEquals(0, count($result['included'])); |
|
144 | + $this->assertArrayHasKey('next', $result['links']); |
|
145 | + $this->assertArrayHasKey('last', $result['links']); |
|
146 | + $this->assertArrayHasKey('self', $result['links']); |
|
147 | + $this->assertArrayNotHasKey('errors', $result); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | $status = 500; |
155 | 155 | |
156 | 156 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
157 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product/stock/warehouse' ); |
|
157 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product/stock/warehouse'); |
|
158 | 158 | |
159 | - $result = json_decode( $object->get( '', $header, $status ), true ); |
|
159 | + $result = json_decode($object->get('', $header, $status), true); |
|
160 | 160 | |
161 | - $this->assertEquals( 200, $status ); |
|
162 | - $this->assertEquals( 1, count( $header ) ); |
|
163 | - $this->assertEquals( 6, $result['meta']['total'] ); |
|
164 | - $this->assertEquals( 6, count( $result['data'] ) ); |
|
165 | - $this->assertEquals( 'product/stock/warehouse', $result['data'][0]['type'] ); |
|
166 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
167 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
161 | + $this->assertEquals(200, $status); |
|
162 | + $this->assertEquals(1, count($header)); |
|
163 | + $this->assertEquals(6, $result['meta']['total']); |
|
164 | + $this->assertEquals(6, count($result['data'])); |
|
165 | + $this->assertEquals('product/stock/warehouse', $result['data'][0]['type']); |
|
166 | + $this->assertEquals(0, count($result['included'])); |
|
167 | + $this->assertArrayNotHasKey('errors', $result); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -174,55 +174,55 @@ discard block |
||
174 | 174 | $status = 500; |
175 | 175 | |
176 | 176 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
177 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'invalid' ); |
|
177 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'invalid'); |
|
178 | 178 | |
179 | - $result = json_decode( $object->get( '', $header, $status ), true ); |
|
179 | + $result = json_decode($object->get('', $header, $status), true); |
|
180 | 180 | |
181 | - $this->assertEquals( 404, $status ); |
|
182 | - $this->assertEquals( 1, count( $header ) ); |
|
183 | - $this->assertEquals( 1, count( $result['errors'] ) ); |
|
184 | - $this->assertArrayHasKey( 'title', $result['errors'][0] ); |
|
185 | - $this->assertArrayHasKey( 'detail', $result['errors'][0] ); |
|
186 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
187 | - $this->assertArrayNotHasKey( 'indluded', $result ); |
|
181 | + $this->assertEquals(404, $status); |
|
182 | + $this->assertEquals(1, count($header)); |
|
183 | + $this->assertEquals(1, count($result['errors'])); |
|
184 | + $this->assertArrayHasKey('title', $result['errors'][0]); |
|
185 | + $this->assertArrayHasKey('detail', $result['errors'][0]); |
|
186 | + $this->assertArrayNotHasKey('data', $result); |
|
187 | + $this->assertArrayNotHasKey('indluded', $result); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
191 | 191 | public function testGetException() |
192 | 192 | { |
193 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
194 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
193 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
194 | + ->will($this->throwException(new \Exception('test exception'))); |
|
195 | 195 | |
196 | - $params = array( 'id' => -1 ); |
|
197 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
198 | - $this->view->addHelper( 'param', $helper ); |
|
196 | + $params = array('id' => -1); |
|
197 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
198 | + $this->view->addHelper('param', $helper); |
|
199 | 199 | |
200 | 200 | $header = array(); |
201 | 201 | $status = 500; |
202 | 202 | |
203 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
203 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
204 | 204 | |
205 | - $this->assertEquals( 500, $status ); |
|
206 | - $this->assertArrayHasKey( 'errors', $result ); |
|
205 | + $this->assertEquals(500, $status); |
|
206 | + $this->assertArrayHasKey('errors', $result); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
210 | 210 | public function testGetMShopException() |
211 | 211 | { |
212 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
213 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
212 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
213 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
214 | 214 | |
215 | - $params = array( 'id' => -1 ); |
|
216 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
217 | - $this->view->addHelper( 'param', $helper ); |
|
215 | + $params = array('id' => -1); |
|
216 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
217 | + $this->view->addHelper('param', $helper); |
|
218 | 218 | |
219 | 219 | $header = array(); |
220 | 220 | $status = 500; |
221 | 221 | |
222 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
222 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
223 | 223 | |
224 | - $this->assertEquals( 404, $status ); |
|
225 | - $this->assertArrayHasKey( 'errors', $result ); |
|
224 | + $this->assertEquals(404, $status); |
|
225 | + $this->assertArrayHasKey('errors', $result); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -230,24 +230,24 @@ discard block |
||
230 | 230 | { |
231 | 231 | $params = array( |
232 | 232 | 'filter' => array( |
233 | - '==' => array( 'product.type.code' => 'select' ) |
|
233 | + '==' => array('product.type.code' => 'select') |
|
234 | 234 | ) |
235 | 235 | ); |
236 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
237 | - $this->view->addHelper( 'param', $helper ); |
|
236 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
237 | + $this->view->addHelper('param', $helper); |
|
238 | 238 | |
239 | 239 | $header = array(); |
240 | 240 | $status = 500; |
241 | 241 | |
242 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
242 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
243 | 243 | |
244 | - $this->assertEquals( 200, $status ); |
|
245 | - $this->assertEquals( 1, count( $header ) ); |
|
246 | - $this->assertEquals( 3, $result['meta']['total'] ); |
|
247 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
248 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
249 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
250 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
244 | + $this->assertEquals(200, $status); |
|
245 | + $this->assertEquals(1, count($header)); |
|
246 | + $this->assertEquals(3, $result['meta']['total']); |
|
247 | + $this->assertEquals(3, count($result['data'])); |
|
248 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
249 | + $this->assertEquals(0, count($result['included'])); |
|
250 | + $this->assertArrayNotHasKey('errors', $result); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -256,26 +256,26 @@ discard block |
||
256 | 256 | $params = array( |
257 | 257 | 'filter' => array( |
258 | 258 | '&&' => array( |
259 | - array( '=~' => array( 'product.label' => 'Unittest: Test' ) ), |
|
260 | - array( '==' => array( 'product.type.code' => 'select' ) ), |
|
259 | + array('=~' => array('product.label' => 'Unittest: Test')), |
|
260 | + array('==' => array('product.type.code' => 'select')), |
|
261 | 261 | ) |
262 | 262 | ) |
263 | 263 | ); |
264 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
265 | - $this->view->addHelper( 'param', $helper ); |
|
264 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
265 | + $this->view->addHelper('param', $helper); |
|
266 | 266 | |
267 | 267 | $header = array(); |
268 | 268 | $status = 500; |
269 | 269 | |
270 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
270 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
271 | 271 | |
272 | - $this->assertEquals( 200, $status ); |
|
273 | - $this->assertEquals( 1, count( $header ) ); |
|
274 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
275 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
276 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
277 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
278 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
272 | + $this->assertEquals(200, $status); |
|
273 | + $this->assertEquals(1, count($header)); |
|
274 | + $this->assertEquals(2, $result['meta']['total']); |
|
275 | + $this->assertEquals(2, count($result['data'])); |
|
276 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
277 | + $this->assertEquals(0, count($result['included'])); |
|
278 | + $this->assertArrayNotHasKey('errors', $result); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | |
@@ -287,24 +287,24 @@ discard block |
||
287 | 287 | 'limit' => 25 |
288 | 288 | ) |
289 | 289 | ); |
290 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
291 | - $this->view->addHelper( 'param', $helper ); |
|
290 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
291 | + $this->view->addHelper('param', $helper); |
|
292 | 292 | |
293 | 293 | $header = array(); |
294 | 294 | $status = 500; |
295 | 295 | |
296 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
296 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
297 | 297 | |
298 | - $this->assertEquals( 200, $status ); |
|
299 | - $this->assertEquals( 1, count( $header ) ); |
|
300 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
301 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
302 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
303 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
304 | - $this->assertArrayHasKey( 'first', $result['links'] ); |
|
305 | - $this->assertArrayHasKey( 'prev', $result['links'] ); |
|
306 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
307 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
298 | + $this->assertEquals(200, $status); |
|
299 | + $this->assertEquals(1, count($header)); |
|
300 | + $this->assertEquals(28, $result['meta']['total']); |
|
301 | + $this->assertEquals(3, count($result['data'])); |
|
302 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
303 | + $this->assertEquals(0, count($result['included'])); |
|
304 | + $this->assertArrayHasKey('first', $result['links']); |
|
305 | + $this->assertArrayHasKey('prev', $result['links']); |
|
306 | + $this->assertArrayHasKey('self', $result['links']); |
|
307 | + $this->assertArrayNotHasKey('errors', $result); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -313,23 +313,23 @@ discard block |
||
313 | 313 | $params = array( |
314 | 314 | 'sort' => 'product.label,-product.code' |
315 | 315 | ); |
316 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
317 | - $this->view->addHelper( 'param', $helper ); |
|
316 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
317 | + $this->view->addHelper('param', $helper); |
|
318 | 318 | |
319 | 319 | $header = array(); |
320 | 320 | $status = 500; |
321 | 321 | |
322 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
322 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
323 | 323 | |
324 | - $this->assertEquals( 200, $status ); |
|
325 | - $this->assertEquals( 1, count( $header ) ); |
|
326 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
327 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
328 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
329 | - $this->assertEquals( 'QRST', $result['data'][0]['attributes']['product.code'] ); |
|
330 | - $this->assertEquals( '16 discs', $result['data'][0]['attributes']['product.label'] ); |
|
331 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
332 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
324 | + $this->assertEquals(200, $status); |
|
325 | + $this->assertEquals(1, count($header)); |
|
326 | + $this->assertEquals(28, $result['meta']['total']); |
|
327 | + $this->assertEquals(25, count($result['data'])); |
|
328 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
329 | + $this->assertEquals('QRST', $result['data'][0]['attributes']['product.code']); |
|
330 | + $this->assertEquals('16 discs', $result['data'][0]['attributes']['product.label']); |
|
331 | + $this->assertEquals(0, count($result['included'])); |
|
332 | + $this->assertArrayNotHasKey('errors', $result); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -342,88 +342,88 @@ discard block |
||
342 | 342 | 'sort' => 'product.id', |
343 | 343 | 'include' => 'product' |
344 | 344 | ); |
345 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
346 | - $this->view->addHelper( 'param', $helper ); |
|
345 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
346 | + $this->view->addHelper('param', $helper); |
|
347 | 347 | |
348 | 348 | $header = array(); |
349 | 349 | $status = 500; |
350 | 350 | |
351 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
351 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
352 | 352 | |
353 | - $this->assertEquals( 200, $status ); |
|
354 | - $this->assertEquals( 1, count( $header ) ); |
|
355 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
356 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
357 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
358 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
359 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
353 | + $this->assertEquals(200, $status); |
|
354 | + $this->assertEquals(1, count($header)); |
|
355 | + $this->assertEquals(28, $result['meta']['total']); |
|
356 | + $this->assertEquals(25, count($result['data'])); |
|
357 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
358 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
359 | + $this->assertArrayNotHasKey('errors', $result); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
363 | 363 | public function testPatch() |
364 | 364 | { |
365 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
365 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
366 | 366 | |
367 | 367 | $item = $productManagerStub->createItem(); |
368 | - $item->setLabel( 'test' ); |
|
369 | - $item->setId( '-1' ); |
|
368 | + $item->setLabel('test'); |
|
369 | + $item->setId('-1'); |
|
370 | 370 | |
371 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
372 | - $productManagerStub->expects( $this->exactly( 3 ) )->method( 'getItem' ) // 3x due to decorator |
|
373 | - ->will( $this->returnValue( $item ) ); |
|
371 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
372 | + $productManagerStub->expects($this->exactly(3))->method('getItem') // 3x due to decorator |
|
373 | + ->will($this->returnValue($item)); |
|
374 | 374 | |
375 | 375 | |
376 | - $params = array( 'id' => '-1' ); |
|
377 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
378 | - $this->view->addHelper( 'param', $helper ); |
|
376 | + $params = array('id' => '-1'); |
|
377 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
378 | + $this->view->addHelper('param', $helper); |
|
379 | 379 | |
380 | 380 | $body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}'; |
381 | 381 | $header = array(); |
382 | 382 | $status = 500; |
383 | 383 | |
384 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
384 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
385 | 385 | |
386 | - $this->assertEquals( 200, $status ); |
|
387 | - $this->assertEquals( 1, count( $header ) ); |
|
388 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
389 | - $this->assertArrayHasKey( 'data', $result ); |
|
390 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
391 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
392 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
393 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
394 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
386 | + $this->assertEquals(200, $status); |
|
387 | + $this->assertEquals(1, count($header)); |
|
388 | + $this->assertEquals(1, $result['meta']['total']); |
|
389 | + $this->assertArrayHasKey('data', $result); |
|
390 | + $this->assertEquals('-1', $result['data']['id']); |
|
391 | + $this->assertEquals('product', $result['data']['type']); |
|
392 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
393 | + $this->assertArrayNotHasKey('included', $result); |
|
394 | + $this->assertArrayNotHasKey('errors', $result); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
398 | 398 | public function testPatchBulk() |
399 | 399 | { |
400 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
400 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
401 | 401 | |
402 | 402 | $item = $productManagerStub->createItem(); |
403 | - $item->setLabel( 'test' ); |
|
404 | - $item->setId( '-1' ); |
|
403 | + $item->setLabel('test'); |
|
404 | + $item->setId('-1'); |
|
405 | 405 | |
406 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
|
407 | - $productManagerStub->expects( $this->exactly( 6 ) )->method( 'getItem' ) // 6x due to decorator |
|
408 | - ->will( $this->returnValue( $item ) ); |
|
406 | + $productManagerStub->expects($this->exactly(2))->method('saveItem'); |
|
407 | + $productManagerStub->expects($this->exactly(6))->method('getItem') // 6x due to decorator |
|
408 | + ->will($this->returnValue($item)); |
|
409 | 409 | |
410 | 410 | |
411 | 411 | $body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}'; |
412 | 412 | $header = array(); |
413 | 413 | $status = 500; |
414 | 414 | |
415 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
415 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
416 | 416 | |
417 | - $this->assertEquals( 200, $status ); |
|
418 | - $this->assertEquals( 1, count( $header ) ); |
|
419 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
420 | - $this->assertArrayHasKey( 'data', $result ); |
|
421 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
422 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
423 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
424 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
425 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
426 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
417 | + $this->assertEquals(200, $status); |
|
418 | + $this->assertEquals(1, count($header)); |
|
419 | + $this->assertEquals(2, $result['meta']['total']); |
|
420 | + $this->assertArrayHasKey('data', $result); |
|
421 | + $this->assertEquals(2, count($result['data'])); |
|
422 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
423 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
424 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
425 | + $this->assertArrayNotHasKey('included', $result); |
|
426 | + $this->assertArrayNotHasKey('errors', $result); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | |
@@ -433,14 +433,14 @@ discard block |
||
433 | 433 | $header = array(); |
434 | 434 | $status = 500; |
435 | 435 | |
436 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
436 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
437 | 437 | |
438 | - $this->assertEquals( 400, $status ); |
|
439 | - $this->assertEquals( 1, count( $header ) ); |
|
440 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
441 | - $this->assertArrayHasKey( 'errors', $result ); |
|
442 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
443 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
438 | + $this->assertEquals(400, $status); |
|
439 | + $this->assertEquals(1, count($header)); |
|
440 | + $this->assertEquals(0, $result['meta']['total']); |
|
441 | + $this->assertArrayHasKey('errors', $result); |
|
442 | + $this->assertArrayNotHasKey('included', $result); |
|
443 | + $this->assertArrayNotHasKey('data', $result); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | |
@@ -450,127 +450,127 @@ discard block |
||
450 | 450 | $header = array(); |
451 | 451 | $status = 500; |
452 | 452 | |
453 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
453 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
454 | 454 | |
455 | - $this->assertEquals( 400, $status ); |
|
456 | - $this->assertEquals( 1, count( $header ) ); |
|
457 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
458 | - $this->assertArrayHasKey( 'errors', $result ); |
|
455 | + $this->assertEquals(400, $status); |
|
456 | + $this->assertEquals(1, count($header)); |
|
457 | + $this->assertEquals(0, $result['meta']['total']); |
|
458 | + $this->assertArrayHasKey('errors', $result); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | |
462 | 462 | public function testPatchException() |
463 | 463 | { |
464 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
465 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
464 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
465 | + ->will($this->throwException(new \Exception('test exception'))); |
|
466 | 466 | |
467 | 467 | $header = array(); |
468 | 468 | $status = 500; |
469 | 469 | |
470 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
470 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
471 | 471 | |
472 | - $this->assertEquals( 500, $status ); |
|
473 | - $this->assertArrayHasKey( 'errors', $result ); |
|
472 | + $this->assertEquals(500, $status); |
|
473 | + $this->assertArrayHasKey('errors', $result); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
477 | 477 | public function testPatchMShopException() |
478 | 478 | { |
479 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
480 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
479 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
480 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
481 | 481 | |
482 | 482 | $header = array(); |
483 | 483 | $status = 500; |
484 | 484 | |
485 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
485 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
486 | 486 | |
487 | - $this->assertEquals( 404, $status ); |
|
488 | - $this->assertArrayHasKey( 'errors', $result ); |
|
487 | + $this->assertEquals(404, $status); |
|
488 | + $this->assertArrayHasKey('errors', $result); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
492 | 492 | public function testPost() |
493 | 493 | { |
494 | - $productManagerStub = $this->getProductMock( array( 'createItem', 'getItem', 'saveItem' ) ); |
|
494 | + $productManagerStub = $this->getProductMock(array('createItem', 'getItem', 'saveItem')); |
|
495 | 495 | |
496 | 496 | $item = new \Aimeos\MShop\Product\Item\Standard(); |
497 | - $item->setId( '-1' ); |
|
497 | + $item->setId('-1'); |
|
498 | 498 | |
499 | - $productManagerStub->expects( $this->once() )->method( 'createItem' ) |
|
500 | - ->will( $this->returnValue( $item ) ); |
|
501 | - $productManagerStub->expects( $this->any() )->method( 'getItem' ) |
|
502 | - ->will( $this->returnValue( $item ) ); |
|
503 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
499 | + $productManagerStub->expects($this->once())->method('createItem') |
|
500 | + ->will($this->returnValue($item)); |
|
501 | + $productManagerStub->expects($this->any())->method('getItem') |
|
502 | + ->will($this->returnValue($item)); |
|
503 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
504 | 504 | |
505 | 505 | |
506 | 506 | $body = '{"data": {"type": "product", "attributes": {"product.type": "default", "product.label": "test"}}}'; |
507 | 507 | $header = array(); |
508 | 508 | $status = 500; |
509 | 509 | |
510 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
510 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
511 | 511 | |
512 | - $this->assertEquals( 201, $status ); |
|
513 | - $this->assertEquals( 1, count( $header ) ); |
|
514 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
515 | - $this->assertArrayHasKey( 'data', $result ); |
|
516 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
517 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
518 | - $this->assertGreaterThan( 0, $result['data']['attributes']['product.typeid'] ); |
|
519 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
520 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
521 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
512 | + $this->assertEquals(201, $status); |
|
513 | + $this->assertEquals(1, count($header)); |
|
514 | + $this->assertEquals(1, $result['meta']['total']); |
|
515 | + $this->assertArrayHasKey('data', $result); |
|
516 | + $this->assertEquals('-1', $result['data']['id']); |
|
517 | + $this->assertEquals('product', $result['data']['type']); |
|
518 | + $this->assertGreaterThan(0, $result['data']['attributes']['product.typeid']); |
|
519 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
520 | + $this->assertArrayNotHasKey('included', $result); |
|
521 | + $this->assertArrayNotHasKey('errors', $result); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
525 | 525 | public function testPostBulk() |
526 | 526 | { |
527 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
527 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
528 | 528 | |
529 | 529 | $item = $productManagerStub->createItem(); |
530 | - $item->setLabel( 'test' ); |
|
531 | - $item->setId( '-1' ); |
|
530 | + $item->setLabel('test'); |
|
531 | + $item->setId('-1'); |
|
532 | 532 | |
533 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
|
534 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' ) |
|
535 | - ->will( $this->returnValue( $item ) ); |
|
533 | + $productManagerStub->expects($this->exactly(2))->method('saveItem'); |
|
534 | + $productManagerStub->expects($this->exactly(2))->method('getItem') |
|
535 | + ->will($this->returnValue($item)); |
|
536 | 536 | |
537 | 537 | |
538 | 538 | $body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}'; |
539 | 539 | $header = array(); |
540 | 540 | $status = 500; |
541 | 541 | |
542 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
542 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
543 | 543 | |
544 | - $this->assertEquals( 201, $status ); |
|
545 | - $this->assertEquals( 1, count( $header ) ); |
|
546 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
547 | - $this->assertArrayHasKey( 'data', $result ); |
|
548 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
549 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
550 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
551 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
552 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
553 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
544 | + $this->assertEquals(201, $status); |
|
545 | + $this->assertEquals(1, count($header)); |
|
546 | + $this->assertEquals(2, $result['meta']['total']); |
|
547 | + $this->assertArrayHasKey('data', $result); |
|
548 | + $this->assertEquals(2, count($result['data'])); |
|
549 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
550 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
551 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
552 | + $this->assertArrayNotHasKey('included', $result); |
|
553 | + $this->assertArrayNotHasKey('errors', $result); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
557 | 557 | public function testPostRelationships() |
558 | 558 | { |
559 | - $productManagerStub = $this->getProductMock( array( 'getSubManager', 'createItem', 'getItem', 'saveItem' ) ); |
|
560 | - $productManagerListsStub = $this->getProductListsMock( array( 'saveItem' ) ); |
|
559 | + $productManagerStub = $this->getProductMock(array('getSubManager', 'createItem', 'getItem', 'saveItem')); |
|
560 | + $productManagerListsStub = $this->getProductListsMock(array('saveItem')); |
|
561 | 561 | |
562 | 562 | $item = new \Aimeos\MShop\Product\Item\Standard(); |
563 | - $item->setId( '-1' ); |
|
563 | + $item->setId('-1'); |
|
564 | 564 | |
565 | - $productManagerStub->expects( $this->once() )->method( 'createItem' ) |
|
566 | - ->will( $this->returnValue( $item ) ); |
|
567 | - $productManagerStub->expects( $this->any() )->method( 'getItem' ) |
|
568 | - ->will( $this->returnValue( $item ) ); |
|
569 | - $productManagerStub->expects( $this->once() )->method( 'getSubManager' ) |
|
570 | - ->will( $this->returnValue( $productManagerListsStub ) ); |
|
571 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
565 | + $productManagerStub->expects($this->once())->method('createItem') |
|
566 | + ->will($this->returnValue($item)); |
|
567 | + $productManagerStub->expects($this->any())->method('getItem') |
|
568 | + ->will($this->returnValue($item)); |
|
569 | + $productManagerStub->expects($this->once())->method('getSubManager') |
|
570 | + ->will($this->returnValue($productManagerListsStub)); |
|
571 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
572 | 572 | |
573 | - $productManagerListsStub->expects( $this->once() )->method( 'saveItem' ); |
|
573 | + $productManagerListsStub->expects($this->once())->method('saveItem'); |
|
574 | 574 | |
575 | 575 | $body = '{"data": {"type": "product", |
576 | 576 | "attributes": {"product.label": "test"}, |
@@ -581,17 +581,17 @@ discard block |
||
581 | 581 | $header = array(); |
582 | 582 | $status = 500; |
583 | 583 | |
584 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
584 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
585 | 585 | |
586 | - $this->assertEquals( 201, $status ); |
|
587 | - $this->assertEquals( 1, count( $header ) ); |
|
588 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
589 | - $this->assertArrayHasKey( 'data', $result ); |
|
590 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
591 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
592 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
593 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
594 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
586 | + $this->assertEquals(201, $status); |
|
587 | + $this->assertEquals(1, count($header)); |
|
588 | + $this->assertEquals(1, $result['meta']['total']); |
|
589 | + $this->assertArrayHasKey('data', $result); |
|
590 | + $this->assertEquals('-1', $result['data']['id']); |
|
591 | + $this->assertEquals('product', $result['data']['type']); |
|
592 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
593 | + $this->assertArrayNotHasKey('included', $result); |
|
594 | + $this->assertArrayNotHasKey('errors', $result); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | |
@@ -601,14 +601,14 @@ discard block |
||
601 | 601 | $header = array(); |
602 | 602 | $status = 500; |
603 | 603 | |
604 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
604 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
605 | 605 | |
606 | - $this->assertEquals( 400, $status ); |
|
607 | - $this->assertEquals( 1, count( $header ) ); |
|
608 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
609 | - $this->assertArrayHasKey( 'errors', $result ); |
|
610 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
611 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
606 | + $this->assertEquals(400, $status); |
|
607 | + $this->assertEquals(1, count($header)); |
|
608 | + $this->assertEquals(0, $result['meta']['total']); |
|
609 | + $this->assertArrayHasKey('errors', $result); |
|
610 | + $this->assertArrayNotHasKey('included', $result); |
|
611 | + $this->assertArrayNotHasKey('data', $result); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -618,42 +618,42 @@ discard block |
||
618 | 618 | $header = array(); |
619 | 619 | $status = 500; |
620 | 620 | |
621 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
621 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
622 | 622 | |
623 | - $this->assertEquals( 403, $status ); |
|
624 | - $this->assertEquals( 1, count( $header ) ); |
|
625 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
626 | - $this->assertArrayHasKey( 'errors', $result ); |
|
623 | + $this->assertEquals(403, $status); |
|
624 | + $this->assertEquals(1, count($header)); |
|
625 | + $this->assertEquals(0, $result['meta']['total']); |
|
626 | + $this->assertArrayHasKey('errors', $result); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
630 | 630 | public function testPostException() |
631 | 631 | { |
632 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
633 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
632 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
633 | + ->will($this->throwException(new \Exception('test exception'))); |
|
634 | 634 | |
635 | 635 | $header = array(); |
636 | 636 | $status = 500; |
637 | 637 | |
638 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
638 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
639 | 639 | |
640 | - $this->assertEquals( 500, $status ); |
|
641 | - $this->assertArrayHasKey( 'errors', $result ); |
|
640 | + $this->assertEquals(500, $status); |
|
641 | + $this->assertArrayHasKey('errors', $result); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | |
645 | 645 | public function testPostMShopException() |
646 | 646 | { |
647 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
648 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
647 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
648 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
649 | 649 | |
650 | 650 | $header = array(); |
651 | 651 | $status = 500; |
652 | 652 | |
653 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
653 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
654 | 654 | |
655 | - $this->assertEquals( 404, $status ); |
|
656 | - $this->assertArrayHasKey( 'errors', $result ); |
|
655 | + $this->assertEquals(404, $status); |
|
656 | + $this->assertArrayHasKey('errors', $result); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | |
@@ -663,11 +663,11 @@ discard block |
||
663 | 663 | $header = array(); |
664 | 664 | $status = 500; |
665 | 665 | |
666 | - $result = json_decode( $this->object->put( $body, $header, $status ), true ); |
|
666 | + $result = json_decode($this->object->put($body, $header, $status), true); |
|
667 | 667 | |
668 | - $this->assertEquals( 501, $status ); |
|
669 | - $this->assertEquals( 1, count( $header ) ); |
|
670 | - $this->assertArrayHasKey( 'errors', $result ); |
|
668 | + $this->assertEquals(501, $status); |
|
669 | + $this->assertEquals(1, count($header)); |
|
670 | + $this->assertArrayHasKey('errors', $result); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -676,87 +676,87 @@ discard block |
||
676 | 676 | $header = array(); |
677 | 677 | $status = 500; |
678 | 678 | |
679 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
679 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
680 | 680 | |
681 | - $this->assertEquals( 200, $status ); |
|
682 | - $this->assertEquals( 2, count( $header ) ); |
|
683 | - $this->assertEquals( 59, count( $result['meta']['resources'] ) ); |
|
684 | - $this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) ); |
|
685 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
681 | + $this->assertEquals(200, $status); |
|
682 | + $this->assertEquals(2, count($header)); |
|
683 | + $this->assertEquals(59, count($result['meta']['resources'])); |
|
684 | + $this->assertGreaterThan(0, count($result['meta']['attributes'])); |
|
685 | + $this->assertArrayNotHasKey('errors', $result); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | |
689 | 689 | public function testOptionsException() |
690 | 690 | { |
691 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
692 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
691 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
692 | + ->will($this->throwException(new \Exception('test exception'))); |
|
693 | 693 | |
694 | 694 | $header = array(); |
695 | 695 | $status = 500; |
696 | 696 | |
697 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
697 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
698 | 698 | |
699 | - $this->assertEquals( 500, $status ); |
|
700 | - $this->assertArrayHasKey( 'errors', $result ); |
|
699 | + $this->assertEquals(500, $status); |
|
700 | + $this->assertArrayHasKey('errors', $result); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
704 | 704 | public function testOptionsMShopException() |
705 | 705 | { |
706 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
707 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
706 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
707 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
708 | 708 | |
709 | 709 | $header = array(); |
710 | 710 | $status = 500; |
711 | 711 | |
712 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
712 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
713 | 713 | |
714 | - $this->assertEquals( 404, $status ); |
|
715 | - $this->assertArrayHasKey( 'errors', $result ); |
|
714 | + $this->assertEquals(404, $status); |
|
715 | + $this->assertArrayHasKey('errors', $result); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | |
719 | - protected function getProductMock( array $methods ) |
|
719 | + protected function getProductMock(array $methods) |
|
720 | 720 | { |
721 | 721 | $name = 'ClientJsonAdmStandard'; |
722 | - $this->context->getConfig()->set( 'mshop/product/manager/name', $name ); |
|
722 | + $this->context->getConfig()->set('mshop/product/manager/name', $name); |
|
723 | 723 | |
724 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' ) |
|
725 | - ->setConstructorArgs( array( $this->context ) ) |
|
726 | - ->setMethods( $methods ) |
|
724 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard') |
|
725 | + ->setConstructorArgs(array($this->context)) |
|
726 | + ->setMethods($methods) |
|
727 | 727 | ->getMock(); |
728 | 728 | |
729 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub ); |
|
729 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub); |
|
730 | 730 | |
731 | 731 | return $stub; |
732 | 732 | } |
733 | 733 | |
734 | 734 | |
735 | - protected function getProductListsMock( array $methods ) |
|
735 | + protected function getProductListsMock(array $methods) |
|
736 | 736 | { |
737 | 737 | $name = 'ClientJsonAdmStandard'; |
738 | - $this->context->getConfig()->set( 'mshop/product/manager/lists/name', $name ); |
|
738 | + $this->context->getConfig()->set('mshop/product/manager/lists/name', $name); |
|
739 | 739 | |
740 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' ) |
|
741 | - ->setConstructorArgs( array( $this->context ) ) |
|
742 | - ->setMethods( $methods ) |
|
740 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard') |
|
741 | + ->setConstructorArgs(array($this->context)) |
|
742 | + ->setMethods($methods) |
|
743 | 743 | ->getMock(); |
744 | 744 | |
745 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub ); |
|
745 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub); |
|
746 | 746 | |
747 | 747 | return $stub; |
748 | 748 | } |
749 | 749 | |
750 | 750 | |
751 | - protected function getProductItem( $code = 'CNC' ) |
|
751 | + protected function getProductItem($code = 'CNC') |
|
752 | 752 | { |
753 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
753 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
754 | 754 | $search = $manager->createSearch(); |
755 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
756 | - $items = $manager->searchItems( $search ); |
|
755 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
756 | + $items = $manager->searchItems($search); |
|
757 | 757 | |
758 | - if( ( $item = reset( $items ) ) === false ) { |
|
759 | - throw new \Exception( sprintf( 'No product item with code "%1$s" found', $code ) ); |
|
758 | + if (($item = reset($items)) === false) { |
|
759 | + throw new \Exception(sprintf('No product item with code "%1$s" found', $code)); |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | return $item; |
@@ -49,6 +49,7 @@ discard block |
||
49 | 49 | * @param string $body Request body |
50 | 50 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
51 | 51 | * @param integer &$status Variable which contains the HTTP status afterwards |
52 | + * @param integer $status |
|
52 | 53 | * @return string Content for response body |
53 | 54 | */ |
54 | 55 | public function delete( $body, array &$header, &$status ) |
@@ -252,6 +253,7 @@ discard block |
||
252 | 253 | * @param string $body Request body |
253 | 254 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
254 | 255 | * @param integer &$status Variable which contains the HTTP status afterwards |
256 | + * @param integer $status |
|
255 | 257 | * @return string Content for response body |
256 | 258 | */ |
257 | 259 | public function patch( $body, array &$header, &$status ) |
@@ -380,6 +382,7 @@ discard block |
||
380 | 382 | * @param string $body Request body |
381 | 383 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
382 | 384 | * @param integer &$status Variable which contains the HTTP status afterwards |
385 | + * @param integer $status |
|
383 | 386 | * @return string Content for response body |
384 | 387 | */ |
385 | 388 | public function post( $body, array &$header, &$status ) |
@@ -508,6 +511,7 @@ discard block |
||
508 | 511 | * @param string $body Request body |
509 | 512 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
510 | 513 | * @param integer &$status Variable which contains the HTTP status afterwards |
514 | + * @param integer $status |
|
511 | 515 | * @return string Content for response body |
512 | 516 | */ |
513 | 517 | public function put( $body, array &$header, &$status ) |
@@ -559,6 +563,7 @@ discard block |
||
559 | 563 | * @param string $body Request body |
560 | 564 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
561 | 565 | * @param integer &$status Variable which contains the HTTP status afterwards |
566 | + * @param integer $status |
|
562 | 567 | * @return string Content for response body |
563 | 568 | */ |
564 | 569 | public function options( $body, array &$header, &$status ) |
@@ -59,24 +59,21 @@ discard block |
||
59 | 59 | { |
60 | 60 | $view = $this->deleteItems( $view, $body ); |
61 | 61 | $status = 200; |
62 | - } |
|
63 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
62 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
64 | 63 | { |
65 | 64 | $status = $e->getCode(); |
66 | 65 | $view->errors = array( array( |
67 | 66 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
68 | 67 | 'detail' => $e->getTraceAsString(), |
69 | 68 | ) ); |
70 | - } |
|
71 | - catch( \Aimeos\MShop\Exception $e ) |
|
69 | + } catch( \Aimeos\MShop\Exception $e ) |
|
72 | 70 | { |
73 | 71 | $status = 404; |
74 | 72 | $view->errors = array( array( |
75 | 73 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
76 | 74 | 'detail' => $e->getTraceAsString(), |
77 | 75 | ) ); |
78 | - } |
|
79 | - catch( \Exception $e ) |
|
76 | + } catch( \Exception $e ) |
|
80 | 77 | { |
81 | 78 | $status = 500; |
82 | 79 | $view->errors = array( array( |
@@ -133,16 +130,14 @@ discard block |
||
133 | 130 | { |
134 | 131 | $view = $this->getItem( $view ); |
135 | 132 | $status = 200; |
136 | - } |
|
137 | - catch( \Aimeos\MShop\Exception $e ) |
|
133 | + } catch( \Aimeos\MShop\Exception $e ) |
|
138 | 134 | { |
139 | 135 | $status = 404; |
140 | 136 | $view->errors = array( array( |
141 | 137 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
142 | 138 | 'detail' => $e->getTraceAsString(), |
143 | 139 | ) ); |
144 | - } |
|
145 | - catch( \Exception $e ) |
|
140 | + } catch( \Exception $e ) |
|
146 | 141 | { |
147 | 142 | $status = 500; |
148 | 143 | $view->errors = array( array( |
@@ -199,24 +194,21 @@ discard block |
||
199 | 194 | { |
200 | 195 | $view = $this->patchItems( $view, $body, $header ); |
201 | 196 | $status = 200; |
202 | - } |
|
203 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
197 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
204 | 198 | { |
205 | 199 | $status = $e->getCode(); |
206 | 200 | $view->errors = array( array( |
207 | 201 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
208 | 202 | 'detail' => $e->getTraceAsString(), |
209 | 203 | ) ); |
210 | - } |
|
211 | - catch( \Aimeos\MShop\Exception $e ) |
|
204 | + } catch( \Aimeos\MShop\Exception $e ) |
|
212 | 205 | { |
213 | 206 | $status = 404; |
214 | 207 | $view->errors = array( array( |
215 | 208 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
216 | 209 | 'detail' => $e->getTraceAsString(), |
217 | 210 | ) ); |
218 | - } |
|
219 | - catch( \Exception $e ) |
|
211 | + } catch( \Exception $e ) |
|
220 | 212 | { |
221 | 213 | $status = 500; |
222 | 214 | $view->errors = array( array( |
@@ -273,24 +265,21 @@ discard block |
||
273 | 265 | { |
274 | 266 | $view = $this->postItems( $view, $body, $header ); |
275 | 267 | $status = 201; |
276 | - } |
|
277 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
268 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
278 | 269 | { |
279 | 270 | $status = $e->getCode(); |
280 | 271 | $view->errors = array( array( |
281 | 272 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
282 | 273 | 'detail' => $e->getTraceAsString(), |
283 | 274 | ) ); |
284 | - } |
|
285 | - catch( \Aimeos\MShop\Exception $e ) |
|
275 | + } catch( \Aimeos\MShop\Exception $e ) |
|
286 | 276 | { |
287 | 277 | $status = 404; |
288 | 278 | $view->errors = array( array( |
289 | 279 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
290 | 280 | 'detail' => $e->getTraceAsString(), |
291 | 281 | ) ); |
292 | - } |
|
293 | - catch( \Exception $e ) |
|
282 | + } catch( \Exception $e ) |
|
294 | 283 | { |
295 | 284 | $status = 500; |
296 | 285 | $view->errors = array( array( |
@@ -411,16 +400,14 @@ discard block |
||
411 | 400 | 'Allow' => 'DELETE,GET,POST,OPTIONS' |
412 | 401 | ); |
413 | 402 | $status = 200; |
414 | - } |
|
415 | - catch( \Aimeos\MShop\Exception $e ) |
|
403 | + } catch( \Aimeos\MShop\Exception $e ) |
|
416 | 404 | { |
417 | 405 | $status = 404; |
418 | 406 | $view->errors = array( array( |
419 | 407 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
420 | 408 | 'detail' => $e->getTraceAsString(), |
421 | 409 | ) ); |
422 | - } |
|
423 | - catch( \Exception $e ) |
|
410 | + } catch( \Exception $e ) |
|
424 | 411 | { |
425 | 412 | $status = 500; |
426 | 413 | $view->errors = array( array( |
@@ -481,8 +468,7 @@ discard block |
||
481 | 468 | $ids = $this->getIds( $request ); |
482 | 469 | $manager->deleteItems( $ids ); |
483 | 470 | $view->total = count( $ids ); |
484 | - } |
|
485 | - else |
|
471 | + } else |
|
486 | 472 | { |
487 | 473 | $manager->deleteItem( $id ); |
488 | 474 | $view->total = 1; |
@@ -510,8 +496,7 @@ discard block |
||
510 | 496 | $view->data = $manager->searchItems( $search, array(), $total ); |
511 | 497 | $view->childItems = $this->getChildItems( $view->data, $include ); |
512 | 498 | $view->listItems = $this->getListItems( $view->data, $include ); |
513 | - } |
|
514 | - else |
|
499 | + } else |
|
515 | 500 | { |
516 | 501 | $view->data = $manager->getItem( $id, array() ); |
517 | 502 | $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
@@ -786,16 +771,14 @@ discard block |
||
786 | 771 | $view->data = $data; |
787 | 772 | $view->total = count( $data ); |
788 | 773 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
789 | - } |
|
790 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
774 | + } elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
791 | 775 | { |
792 | 776 | $request->data->id = $id; |
793 | 777 | $data = $this->saveEntry( $manager, $request->data ); |
794 | 778 | |
795 | 779 | $view->data = $data; |
796 | 780 | $view->total = 1; |
797 | - } |
|
798 | - else |
|
781 | + } else |
|
799 | 782 | { |
800 | 783 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
801 | 784 | } |
@@ -832,8 +815,7 @@ discard block |
||
832 | 815 | $view->data = $data; |
833 | 816 | $view->total = count( $data ); |
834 | 817 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
835 | - } |
|
836 | - else |
|
818 | + } else |
|
837 | 819 | { |
838 | 820 | $request->data->id = null; |
839 | 821 | $data = $this->saveEntry( $manager, $request->data ); |
@@ -29,39 +29,39 @@ discard block |
||
29 | 29 | * @param integer &$status Variable which contains the HTTP status afterwards |
30 | 30 | * @return string Content for response body |
31 | 31 | */ |
32 | - public function delete( $body, array &$header, &$status ) |
|
32 | + public function delete($body, array &$header, &$status) |
|
33 | 33 | { |
34 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
34 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
35 | 35 | $view = $this->getView(); |
36 | 36 | |
37 | 37 | try |
38 | 38 | { |
39 | - $view = $this->deleteItems( $view, $body ); |
|
39 | + $view = $this->deleteItems($view, $body); |
|
40 | 40 | $status = 200; |
41 | 41 | } |
42 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
42 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
43 | 43 | { |
44 | 44 | $status = $e->getCode(); |
45 | - $view->errors = array( array( |
|
46 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
45 | + $view->errors = array(array( |
|
46 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
47 | 47 | 'detail' => $e->getTraceAsString(), |
48 | - ) ); |
|
48 | + )); |
|
49 | 49 | } |
50 | - catch( \Aimeos\MShop\Exception $e ) |
|
50 | + catch (\Aimeos\MShop\Exception $e) |
|
51 | 51 | { |
52 | 52 | $status = 404; |
53 | - $view->errors = array( array( |
|
54 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
53 | + $view->errors = array(array( |
|
54 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
55 | 55 | 'detail' => $e->getTraceAsString(), |
56 | - ) ); |
|
56 | + )); |
|
57 | 57 | } |
58 | - catch( \Exception $e ) |
|
58 | + catch (\Exception $e) |
|
59 | 59 | { |
60 | 60 | $status = 500; |
61 | - $view->errors = array( array( |
|
61 | + $view->errors = array(array( |
|
62 | 62 | 'title' => $e->getMessage(), |
63 | 63 | 'detail' => $e->getTraceAsString(), |
64 | - ) ); |
|
64 | + )); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** admin/jsonadm/standard/template-delete |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
92 | 92 | $default = 'delete-default.php'; |
93 | 93 | |
94 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
94 | + return $view->render($view->config($tplconf, $default)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -103,31 +103,31 @@ discard block |
||
103 | 103 | * @param integer &$status Variable which contains the HTTP status afterwards |
104 | 104 | * @return string Content for response body |
105 | 105 | */ |
106 | - public function get( $body, array &$header, &$status ) |
|
106 | + public function get($body, array &$header, &$status) |
|
107 | 107 | { |
108 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
108 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
109 | 109 | $view = $this->getView(); |
110 | 110 | |
111 | 111 | try |
112 | 112 | { |
113 | - $view = $this->getItems( $view ); |
|
113 | + $view = $this->getItems($view); |
|
114 | 114 | $status = 200; |
115 | 115 | } |
116 | - catch( \Aimeos\MShop\Exception $e ) |
|
116 | + catch (\Aimeos\MShop\Exception $e) |
|
117 | 117 | { |
118 | 118 | $status = 404; |
119 | - $view->errors = array( array( |
|
120 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
119 | + $view->errors = array(array( |
|
120 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
121 | 121 | 'detail' => $e->getTraceAsString(), |
122 | - ) ); |
|
122 | + )); |
|
123 | 123 | } |
124 | - catch( \Exception $e ) |
|
124 | + catch (\Exception $e) |
|
125 | 125 | { |
126 | 126 | $status = 500; |
127 | - $view->errors = array( array( |
|
127 | + $view->errors = array(array( |
|
128 | 128 | 'title' => $e->getMessage(), |
129 | 129 | 'detail' => $e->getTraceAsString(), |
130 | - ) ); |
|
130 | + )); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** admin/jsonadm/standard/template-get |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $tplconf = 'admin/jsonadm/standard/template-get'; |
158 | 158 | $default = 'get-default.php'; |
159 | 159 | |
160 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
160 | + return $view->render($view->config($tplconf, $default)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -169,39 +169,39 @@ discard block |
||
169 | 169 | * @param integer &$status Variable which contains the HTTP status afterwards |
170 | 170 | * @return string Content for response body |
171 | 171 | */ |
172 | - public function patch( $body, array &$header, &$status ) |
|
172 | + public function patch($body, array &$header, &$status) |
|
173 | 173 | { |
174 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
174 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
175 | 175 | $view = $this->getView(); |
176 | 176 | |
177 | 177 | try |
178 | 178 | { |
179 | - $view = $this->patchItems( $view, $body, $header ); |
|
179 | + $view = $this->patchItems($view, $body, $header); |
|
180 | 180 | $status = 200; |
181 | 181 | } |
182 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
182 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
183 | 183 | { |
184 | 184 | $status = $e->getCode(); |
185 | - $view->errors = array( array( |
|
186 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
185 | + $view->errors = array(array( |
|
186 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
187 | 187 | 'detail' => $e->getTraceAsString(), |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | } |
190 | - catch( \Aimeos\MShop\Exception $e ) |
|
190 | + catch (\Aimeos\MShop\Exception $e) |
|
191 | 191 | { |
192 | 192 | $status = 404; |
193 | - $view->errors = array( array( |
|
194 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
193 | + $view->errors = array(array( |
|
194 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
195 | 195 | 'detail' => $e->getTraceAsString(), |
196 | - ) ); |
|
196 | + )); |
|
197 | 197 | } |
198 | - catch( \Exception $e ) |
|
198 | + catch (\Exception $e) |
|
199 | 199 | { |
200 | 200 | $status = 500; |
201 | - $view->errors = array( array( |
|
201 | + $view->errors = array(array( |
|
202 | 202 | 'title' => $e->getMessage(), |
203 | 203 | 'detail' => $e->getTraceAsString(), |
204 | - ) ); |
|
204 | + )); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** admin/jsonadm/standard/template-patch |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
232 | 232 | $default = 'patch-default.php'; |
233 | 233 | |
234 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
234 | + return $view->render($view->config($tplconf, $default)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -243,39 +243,39 @@ discard block |
||
243 | 243 | * @param integer &$status Variable which contains the HTTP status afterwards |
244 | 244 | * @return string Content for response body |
245 | 245 | */ |
246 | - public function post( $body, array &$header, &$status ) |
|
246 | + public function post($body, array &$header, &$status) |
|
247 | 247 | { |
248 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
248 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
249 | 249 | $view = $this->getView(); |
250 | 250 | |
251 | 251 | try |
252 | 252 | { |
253 | - $view = $this->postItems( $view, $body, $header ); |
|
253 | + $view = $this->postItems($view, $body, $header); |
|
254 | 254 | $status = 201; |
255 | 255 | } |
256 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
256 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
257 | 257 | { |
258 | 258 | $status = $e->getCode(); |
259 | - $view->errors = array( array( |
|
260 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
259 | + $view->errors = array(array( |
|
260 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
261 | 261 | 'detail' => $e->getTraceAsString(), |
262 | - ) ); |
|
262 | + )); |
|
263 | 263 | } |
264 | - catch( \Aimeos\MShop\Exception $e ) |
|
264 | + catch (\Aimeos\MShop\Exception $e) |
|
265 | 265 | { |
266 | 266 | $status = 404; |
267 | - $view->errors = array( array( |
|
268 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
267 | + $view->errors = array(array( |
|
268 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
269 | 269 | 'detail' => $e->getTraceAsString(), |
270 | - ) ); |
|
270 | + )); |
|
271 | 271 | } |
272 | - catch( \Exception $e ) |
|
272 | + catch (\Exception $e) |
|
273 | 273 | { |
274 | 274 | $status = 500; |
275 | - $view->errors = array( array( |
|
275 | + $view->errors = array(array( |
|
276 | 276 | 'title' => $e->getMessage(), |
277 | 277 | 'detail' => $e->getTraceAsString(), |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** admin/jsonadm/standard/template-post |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $tplconf = 'admin/jsonadm/standard/template-post'; |
306 | 306 | $default = 'post-default.php'; |
307 | 307 | |
308 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
308 | + return $view->render($view->config($tplconf, $default)); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -317,15 +317,15 @@ discard block |
||
317 | 317 | * @param integer &$status Variable which contains the HTTP status afterwards |
318 | 318 | * @return string Content for response body |
319 | 319 | */ |
320 | - public function put( $body, array &$header, &$status ) |
|
320 | + public function put($body, array &$header, &$status) |
|
321 | 321 | { |
322 | 322 | $status = 501; |
323 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
323 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
324 | 324 | $view = $this->getView(); |
325 | 325 | |
326 | - $view->errors = array( array( |
|
327 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
328 | - ) ); |
|
326 | + $view->errors = array(array( |
|
327 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
328 | + )); |
|
329 | 329 | |
330 | 330 | /** admin/jsonadm/standard/template-put |
331 | 331 | * Relative path to the JSON API template for PUT requests |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $tplconf = 'admin/jsonadm/standard/template-put'; |
355 | 355 | $default = 'put-default.php'; |
356 | 356 | |
357 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
357 | + return $view->render($view->config($tplconf, $default)); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @param integer &$status Variable which contains the HTTP status afterwards |
367 | 367 | * @return string Content for response body |
368 | 368 | */ |
369 | - public function options( $body, array &$header, &$status ) |
|
369 | + public function options($body, array &$header, &$status) |
|
370 | 370 | { |
371 | 371 | $context = $this->getContext(); |
372 | 372 | $view = $this->getView(); |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | { |
376 | 376 | $resources = $attributes = array(); |
377 | 377 | |
378 | - foreach( $this->getDomains( $view ) as $domain ) |
|
378 | + foreach ($this->getDomains($view) as $domain) |
|
379 | 379 | { |
380 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
381 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
382 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
380 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
381 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
382 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | $view->resources = $resources; |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | ); |
392 | 392 | $status = 200; |
393 | 393 | } |
394 | - catch( \Aimeos\MShop\Exception $e ) |
|
394 | + catch (\Aimeos\MShop\Exception $e) |
|
395 | 395 | { |
396 | 396 | $status = 404; |
397 | - $view->errors = array( array( |
|
398 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
397 | + $view->errors = array(array( |
|
398 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
399 | 399 | 'detail' => $e->getTraceAsString(), |
400 | - ) ); |
|
400 | + )); |
|
401 | 401 | } |
402 | - catch( \Exception $e ) |
|
402 | + catch (\Exception $e) |
|
403 | 403 | { |
404 | 404 | $status = 500; |
405 | - $view->errors = array( array( |
|
405 | + $view->errors = array(array( |
|
406 | 406 | 'title' => $e->getMessage(), |
407 | 407 | 'detail' => $e->getTraceAsString(), |
408 | - ) ); |
|
408 | + )); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** admin/jsonadm/standard/template-options |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $tplconf = 'admin/jsonadm/standard/template-options'; |
436 | 436 | $default = 'options-default.php'; |
437 | 437 | |
438 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
438 | + return $view->render($view->config($tplconf, $default)); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -447,23 +447,23 @@ discard block |
||
447 | 447 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
448 | 448 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
449 | 449 | */ |
450 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
450 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
451 | 451 | { |
452 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
452 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
453 | 453 | |
454 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
454 | + if (($id = $view->param('id')) == null) |
|
455 | 455 | { |
456 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
457 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
456 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
457 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
458 | 458 | } |
459 | 459 | |
460 | - $ids = $this->getIds( $request ); |
|
461 | - $manager->deleteItems( $ids ); |
|
462 | - $view->total = count( $ids ); |
|
460 | + $ids = $this->getIds($request); |
|
461 | + $manager->deleteItems($ids); |
|
462 | + $view->total = count($ids); |
|
463 | 463 | } |
464 | 464 | else |
465 | 465 | { |
466 | - $manager->deleteItem( $id ); |
|
466 | + $manager->deleteItem($id); |
|
467 | 467 | $view->total = 1; |
468 | 468 | } |
469 | 469 | |
@@ -477,27 +477,27 @@ discard block |
||
477 | 477 | * @param \Aimeos\MW\View\Iface $view View instance |
478 | 478 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
479 | 479 | */ |
480 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
480 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
481 | 481 | { |
482 | 482 | $total = 1; |
483 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
484 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
483 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
484 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
485 | 485 | |
486 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
486 | + if (($id = $view->param('id')) == null) |
|
487 | 487 | { |
488 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
489 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
490 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
491 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
488 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
489 | + $view->data = $manager->searchItems($search, array(), $total); |
|
490 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
491 | + $view->listItems = $this->getListItems($view->data, $include); |
|
492 | 492 | } |
493 | 493 | else |
494 | 494 | { |
495 | - $view->data = $manager->getItem( $id, array() ); |
|
496 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
497 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
495 | + $view->data = $manager->getItem($id, array()); |
|
496 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
497 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
498 | 498 | } |
499 | 499 | |
500 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
500 | + $view->refItems = $this->getRefItems($view->listItems); |
|
501 | 501 | $view->total = $total; |
502 | 502 | |
503 | 503 | return $view; |
@@ -511,9 +511,9 @@ discard block |
||
511 | 511 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
512 | 512 | * @deprecated 2016.06 Use getItems() instead |
513 | 513 | */ |
514 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
514 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
515 | 515 | { |
516 | - return $this->getItems( $view ); |
|
516 | + return $this->getItems($view); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -525,33 +525,33 @@ discard block |
||
525 | 525 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
526 | 526 | * @return \Aimeos\MW\View\Iface Updated view instance |
527 | 527 | */ |
528 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
528 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
529 | 529 | { |
530 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
531 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
530 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
531 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
532 | 532 | } |
533 | 533 | |
534 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
534 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
535 | 535 | |
536 | - if( is_array( $request->data ) ) |
|
536 | + if (is_array($request->data)) |
|
537 | 537 | { |
538 | - $data = $this->saveData( $manager, $request ); |
|
538 | + $data = $this->saveData($manager, $request); |
|
539 | 539 | |
540 | 540 | $view->data = $data; |
541 | - $view->total = count( $data ); |
|
541 | + $view->total = count($data); |
|
542 | 542 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
543 | 543 | } |
544 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
544 | + elseif (($id = $view->param('id')) != null) |
|
545 | 545 | { |
546 | 546 | $request->data->id = $id; |
547 | - $data = $this->saveEntry( $manager, $request->data ); |
|
547 | + $data = $this->saveEntry($manager, $request->data); |
|
548 | 548 | |
549 | 549 | $view->data = $data; |
550 | 550 | $view->total = 1; |
551 | 551 | } |
552 | 552 | else |
553 | 553 | { |
554 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
554 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | return $view; |
@@ -566,31 +566,31 @@ discard block |
||
566 | 566 | * @param array &$header Associative list of HTTP headers as value/result parameter |
567 | 567 | * @return \Aimeos\MW\View\Iface Updated view instance |
568 | 568 | */ |
569 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
569 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
570 | 570 | { |
571 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
572 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
571 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
572 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
573 | 573 | } |
574 | 574 | |
575 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
576 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
575 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
576 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
580 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
580 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
581 | 581 | |
582 | - if( is_array( $request->data ) ) |
|
582 | + if (is_array($request->data)) |
|
583 | 583 | { |
584 | - $data = $this->saveData( $manager, $request ); |
|
584 | + $data = $this->saveData($manager, $request); |
|
585 | 585 | |
586 | 586 | $view->data = $data; |
587 | - $view->total = count( $data ); |
|
587 | + $view->total = count($data); |
|
588 | 588 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
589 | 589 | } |
590 | 590 | else |
591 | 591 | { |
592 | 592 | $request->data->id = null; |
593 | - $data = $this->saveEntry( $manager, $request->data ); |
|
593 | + $data = $this->saveEntry($manager, $request->data); |
|
594 | 594 | |
595 | 595 | $view->data = $data; |
596 | 596 | $view->total = 1; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $templatePaths List of file system paths where the templates are stored |
34 | 34 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
37 | 37 | { |
38 | 38 | $this->view = $view; |
39 | 39 | $this->context = $context; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $include List of resource types that should be fetched |
50 | 50 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
51 | 51 | */ |
52 | - protected function getChildItems( array $items, array $include ) |
|
52 | + protected function getChildItems(array $items, array $include) |
|
53 | 53 | { |
54 | 54 | return array(); |
55 | 55 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
73 | 73 | * @return array List of domain names |
74 | 74 | */ |
75 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
75 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
76 | 76 | { |
77 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
77 | + if (($domains = $view->param('resource')) == '') |
|
78 | 78 | { |
79 | 79 | /** admin/jsonadm/domains |
80 | 80 | * A list of domain names whose clients are available for the JSON API |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
97 | 97 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
98 | 98 | ); |
99 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
99 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return (array) $domains; |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | * @param \stdClass $request Decoded request body |
110 | 110 | * @return array List of item IDs |
111 | 111 | */ |
112 | - protected function getIds( $request ) |
|
112 | + protected function getIds($request) |
|
113 | 113 | { |
114 | 114 | $ids = array(); |
115 | 115 | |
116 | - if( isset( $request->data ) ) |
|
116 | + if (isset($request->data)) |
|
117 | 117 | { |
118 | - foreach( (array) $request->data as $entry ) |
|
118 | + foreach ((array) $request->data as $entry) |
|
119 | 119 | { |
120 | - if( isset( $entry->id ) ) { |
|
120 | + if (isset($entry->id)) { |
|
121 | 121 | $ids[] = $entry->id; |
122 | 122 | } |
123 | 123 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param array $include List of resource types that should be fetched |
135 | 135 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
136 | 136 | */ |
137 | - protected function getListItems( array $items, array $include ) |
|
137 | + protected function getListItems(array $items, array $include) |
|
138 | 138 | { |
139 | 139 | return array(); |
140 | 140 | } |
@@ -157,23 +157,23 @@ discard block |
||
157 | 157 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
158 | 158 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
159 | 159 | */ |
160 | - protected function getRefItems( array $listItems ) |
|
160 | + protected function getRefItems(array $listItems) |
|
161 | 161 | { |
162 | 162 | $list = $map = array(); |
163 | 163 | $context = $this->getContext(); |
164 | 164 | |
165 | - foreach( $listItems as $listItem ) { |
|
165 | + foreach ($listItems as $listItem) { |
|
166 | 166 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
167 | 167 | } |
168 | 168 | |
169 | - foreach( $map as $domain => $ids ) |
|
169 | + foreach ($map as $domain => $ids) |
|
170 | 170 | { |
171 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
171 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
172 | 172 | |
173 | 173 | $search = $manager->createSearch(); |
174 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
174 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
175 | 175 | |
176 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
176 | + $list = array_merge($list, $manager->searchItems($search)); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $list; |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param array $params List of criteria data with condition, sorting and paging |
210 | 210 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
211 | 211 | */ |
212 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
212 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
213 | 213 | { |
214 | - $this->initCriteriaConditions( $criteria, $params ); |
|
215 | - $this->initCriteriaSortations( $criteria, $params ); |
|
216 | - $this->initCriteriaSlice( $criteria, $params ); |
|
214 | + $this->initCriteriaConditions($criteria, $params); |
|
215 | + $this->initCriteriaSortations($criteria, $params); |
|
216 | + $this->initCriteriaSlice($criteria, $params); |
|
217 | 217 | |
218 | 218 | return $criteria; |
219 | 219 | } |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
226 | 226 | * @param array $params List of criteria data with condition, sorting and paging |
227 | 227 | */ |
228 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
228 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
229 | 229 | { |
230 | - if( !isset( $params['filter'] ) ) { |
|
230 | + if (!isset($params['filter'])) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | 234 | $existing = $criteria->getConditions(); |
235 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
235 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
236 | 236 | |
237 | - $expr = array( $criteria->getConditions(), $existing ); |
|
238 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
237 | + $expr = array($criteria->getConditions(), $existing); |
|
238 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
246 | 246 | * @param array $params List of criteria data with condition, sorting and paging |
247 | 247 | */ |
248 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
248 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
249 | 249 | { |
250 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
251 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
250 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
251 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
252 | 252 | |
253 | - $criteria->setSlice( $start, $size ); |
|
253 | + $criteria->setSlice($start, $size); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -260,24 +260,24 @@ discard block |
||
260 | 260 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
261 | 261 | * @param array $params List of criteria data with condition, sorting and paging |
262 | 262 | */ |
263 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
263 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
264 | 264 | { |
265 | - if( !isset( $params['sort'] ) ) { |
|
265 | + if (!isset($params['sort'])) { |
|
266 | 266 | return; |
267 | 267 | } |
268 | 268 | |
269 | 269 | $sortation = array(); |
270 | 270 | |
271 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
271 | + foreach (explode(',', $params['sort']) as $sort) |
|
272 | 272 | { |
273 | - if( $sort[0] === '-' ) { |
|
274 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
273 | + if ($sort[0] === '-') { |
|
274 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
275 | 275 | } else { |
276 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
276 | + $sortation[] = $criteria->sort('+', $sort); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | - $criteria->setSortations( $sortation ); |
|
280 | + $criteria->setSortations($sortation); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | * @param \stdClass $request Object with request body data |
289 | 289 | * @return array List of items |
290 | 290 | */ |
291 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
291 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
292 | 292 | { |
293 | 293 | $data = array(); |
294 | 294 | |
295 | - if( isset( $request->data ) ) |
|
295 | + if (isset($request->data)) |
|
296 | 296 | { |
297 | - foreach( (array) $request->data as $entry ) { |
|
298 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
297 | + foreach ((array) $request->data as $entry) { |
|
298 | + $data[] = $this->saveEntry($manager, $entry); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -310,22 +310,22 @@ discard block |
||
310 | 310 | * @param \stdClass $entry Object including "id" and "attributes" elements |
311 | 311 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
312 | 312 | */ |
313 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
313 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
314 | 314 | { |
315 | - if( isset( $entry->id ) ) { |
|
316 | - $item = $manager->getItem( $entry->id ); |
|
315 | + if (isset($entry->id)) { |
|
316 | + $item = $manager->getItem($entry->id); |
|
317 | 317 | } else { |
318 | 318 | $item = $manager->createItem(); |
319 | 319 | } |
320 | 320 | |
321 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
322 | - $manager->saveItem( $item ); |
|
321 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
322 | + $manager->saveItem($item); |
|
323 | 323 | |
324 | - if( isset( $entry->relationships ) ) { |
|
325 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
324 | + if (isset($entry->relationships)) { |
|
325 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
326 | 326 | } |
327 | 327 | |
328 | - return $manager->getItem( $item->getId() ); |
|
328 | + return $manager->getItem($item->getId()); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -336,28 +336,28 @@ discard block |
||
336 | 336 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
337 | 337 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
338 | 338 | */ |
339 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
340 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
339 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
340 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
341 | 341 | { |
342 | 342 | $id = $item->getId(); |
343 | - $listManager = $manager->getSubManager( 'lists' ); |
|
343 | + $listManager = $manager->getSubManager('lists'); |
|
344 | 344 | |
345 | - foreach( (array) $relationships as $domain => $list ) |
|
345 | + foreach ((array) $relationships as $domain => $list) |
|
346 | 346 | { |
347 | - if( isset( $list->data ) ) |
|
347 | + if (isset($list->data)) |
|
348 | 348 | { |
349 | - foreach( (array) $list->data as $data ) |
|
349 | + foreach ((array) $list->data as $data) |
|
350 | 350 | { |
351 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
351 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
352 | 352 | |
353 | - if( isset( $data->id ) ) { |
|
354 | - $listItem->setRefId( $data->id ); |
|
353 | + if (isset($data->id)) { |
|
354 | + $listItem->setRefId($data->id); |
|
355 | 355 | } |
356 | 356 | |
357 | - $listItem->setParentId( $id ); |
|
358 | - $listItem->setDomain( $domain ); |
|
357 | + $listItem->setParentId($id); |
|
358 | + $listItem->setDomain($domain); |
|
359 | 359 | |
360 | - $listManager->saveItem( $listItem, false ); |
|
360 | + $listManager->saveItem($listItem, false); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | } |
@@ -374,20 +374,20 @@ discard block |
||
374 | 374 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
375 | 375 | */ |
376 | 376 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
377 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
377 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
378 | 378 | { |
379 | - if( isset( $data->attributes ) ) |
|
379 | + if (isset($data->attributes)) |
|
380 | 380 | { |
381 | 381 | $attr = (array) $data->attributes; |
382 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
382 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
383 | 383 | |
384 | - if( isset( $attr[$key.'.type'] ) ) |
|
384 | + if (isset($attr[$key . '.type'])) |
|
385 | 385 | { |
386 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], array(), $domain ); |
|
387 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
386 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], array(), $domain); |
|
387 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
388 | 388 | } |
389 | 389 | |
390 | - $item->fromArray( $attr ); |
|
390 | + $item->fromArray($attr); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | return $item; |
@@ -106,6 +106,7 @@ |
||
106 | 106 | * @param string $body Request body |
107 | 107 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
109 | + * @param integer $status |
|
109 | 110 | * @return string Content for response body |
110 | 111 | */ |
111 | 112 | public function get( $body, array &$header, &$status ) |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
109 | 109 | * @return string Content for response body |
110 | 110 | */ |
111 | - public function get( $body, array &$header, &$status ) |
|
111 | + public function get($body, array &$header, &$status) |
|
112 | 112 | { |
113 | 113 | /** admin/jsonadm/partials/catalog/template-data |
114 | 114 | * Relative path to the data partial template file for the catalog client |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @since 2016.07 |
126 | 126 | * @category Developer |
127 | 127 | */ |
128 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/catalog/template-data' ) ); |
|
128 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/catalog/template-data')); |
|
129 | 129 | |
130 | - return parent::get( $body, $header, $status ); |
|
130 | + return parent::get($body, $header, $status); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | * @param array $include List of resource types that should be fetched |
139 | 139 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
140 | 140 | */ |
141 | - protected function getChildItems( array $items, array $include ) |
|
141 | + protected function getChildItems(array $items, array $include) |
|
142 | 142 | { |
143 | 143 | $list = array(); |
144 | 144 | |
145 | - if( in_array( 'catalog', $include ) ) |
|
145 | + if (in_array('catalog', $include)) |
|
146 | 146 | { |
147 | - foreach( $items as $item ) { |
|
148 | - $list = array_merge( $list, $item->getChildren() ); |
|
147 | + foreach ($items as $item) { |
|
148 | + $list = array_merge($list, $item->getChildren()); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -159,27 +159,27 @@ discard block |
||
159 | 159 | * @param \Aimeos\MW\View\Iface $view View instance |
160 | 160 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
161 | 161 | */ |
162 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
162 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
163 | 163 | { |
164 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
165 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' ); |
|
166 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
164 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
165 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); |
|
166 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
167 | 167 | $total = 1; |
168 | 168 | |
169 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
169 | + if (($id = $view->param('id')) == null) |
|
170 | 170 | { |
171 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
172 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
173 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
171 | + $view->data = $manager->searchItems($search, array(), $total); |
|
172 | + $view->listItems = $this->getListItems($view->data, $include); |
|
173 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
174 | 174 | } |
175 | 175 | else |
176 | 176 | { |
177 | - $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
178 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
179 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
177 | + $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
178 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
179 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
180 | 180 | } |
181 | 181 | |
182 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
182 | + $view->refItems = $this->getRefItems($view->listItems); |
|
183 | 183 | $view->total = $total; |
184 | 184 | |
185 | 185 | return $view; |
@@ -193,18 +193,18 @@ discard block |
||
193 | 193 | * @param array $include List of resource types that should be fetched |
194 | 194 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
195 | 195 | */ |
196 | - protected function getListItems( array $items, array $include ) |
|
196 | + protected function getListItems(array $items, array $include) |
|
197 | 197 | { |
198 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
198 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
199 | 199 | |
200 | 200 | $search = $manager->createSearch(); |
201 | 201 | $expr = array( |
202 | - $search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ), |
|
203 | - $search->compare( '==', 'catalog.lists.domain', $include ), |
|
202 | + $search->compare('==', 'catalog.lists.parentid', array_keys($items)), |
|
203 | + $search->compare('==', 'catalog.lists.domain', $include), |
|
204 | 204 | ); |
205 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
205 | + $search->setConditions($search->combine('&&', $expr)); |
|
206 | 206 | |
207 | - return $manager->searchItems( $search ); |
|
207 | + return $manager->searchItems($search); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -215,32 +215,32 @@ discard block |
||
215 | 215 | * @param \stdClass $entry Object including "id" and "attributes" elements |
216 | 216 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
217 | 217 | */ |
218 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
218 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
219 | 219 | { |
220 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
221 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
220 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
221 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
222 | 222 | |
223 | - if( isset( $entry->id ) ) |
|
223 | + if (isset($entry->id)) |
|
224 | 224 | { |
225 | - $item = $manager->getItem( $entry->id ); |
|
226 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
227 | - $manager->saveItem( $item ); |
|
225 | + $item = $manager->getItem($entry->id); |
|
226 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
227 | + $manager->saveItem($item); |
|
228 | 228 | |
229 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
230 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
229 | + if (isset($entry->parentid) && $targetId !== null) { |
|
230 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | else |
234 | 234 | { |
235 | 235 | $item = $manager->createItem(); |
236 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
237 | - $manager->insertItem( $item, $targetId, $refId ); |
|
236 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
237 | + $manager->insertItem($item, $targetId, $refId); |
|
238 | 238 | } |
239 | 239 | |
240 | - if( isset( $entry->relationships ) ) { |
|
241 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
240 | + if (isset($entry->relationships)) { |
|
241 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
242 | 242 | } |
243 | 243 | |
244 | - return $manager->getItem( $item->getId() ); |
|
244 | + return $manager->getItem($item->getId()); |
|
245 | 245 | } |
246 | 246 | } |
@@ -171,8 +171,7 @@ discard block |
||
171 | 171 | $view->data = $manager->searchItems( $search, array(), $total ); |
172 | 172 | $view->listItems = $this->getListItems( $view->data, $include ); |
173 | 173 | $view->childItems = $this->getChildItems( $view->data, $include ); |
174 | - } |
|
175 | - else |
|
174 | + } else |
|
176 | 175 | { |
177 | 176 | $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
178 | 177 | $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
@@ -229,8 +228,7 @@ discard block |
||
229 | 228 | if( isset( $entry->parentid ) && $targetId !== null ) { |
230 | 229 | $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
231 | 230 | } |
232 | - } |
|
233 | - else |
|
231 | + } else |
|
234 | 232 | { |
235 | 233 | $item = $manager->createItem(); |
236 | 234 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |