@@ -10,9 +10,9 @@ |
||
10 | 10 | |
11 | 11 | ?> |
12 | 12 | { |
13 | - <?php if( isset( $this->errors ) ) : ?> |
|
13 | + <?php if (isset($this->errors)) : ?> |
|
14 | 14 | |
15 | - "errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
15 | + "errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
16 | 16 | |
17 | 17 | <?php endif; ?> |
18 | 18 |
@@ -16,9 +16,9 @@ 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 ); |
|
21 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Order\\Standard', $client ); |
|
19 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
20 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
21 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Order\\Standard', $client); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | $context = \TestHelperJadm::getContext(); |
28 | 28 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
29 | 29 | |
30 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
31 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
32 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Order\\Base\\Standard', $client ); |
|
30 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
31 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
32 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Order\\Base\\Standard', $client); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $context = \TestHelperJadm::getContext(); |
39 | 39 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
40 | 40 | |
41 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'stock/type' ); |
|
42 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
43 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Standard', $client ); |
|
41 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'stock/type'); |
|
42 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
43 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Standard', $client); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | $context = \TestHelperJadm::getContext(); |
50 | 50 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
51 | 51 | |
52 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '' ); |
|
53 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
54 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Standard', $client ); |
|
52 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, ''); |
|
53 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
54 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Standard', $client); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | $context = \TestHelperJadm::getContext(); |
61 | 61 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
62 | 62 | |
63 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
64 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '%^' ); |
|
63 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
64 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '%^'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -70,68 +70,68 @@ discard block |
||
70 | 70 | $context = \TestHelperJadm::getContext(); |
71 | 71 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
72 | 72 | |
73 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
74 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '', '%^' ); |
|
73 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
74 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '', '%^'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | 78 | public function testClear() |
79 | 79 | { |
80 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
80 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
81 | 81 | |
82 | 82 | $context = \TestHelperJadm::getContext(); |
83 | 83 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
84 | 84 | |
85 | - $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
85 | + $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
86 | 86 | \Aimeos\Admin\JsonAdm\Factory::clear(); |
87 | - $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
87 | + $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
88 | 88 | |
89 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
89 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
90 | 90 | |
91 | - $this->assertNotSame( $client1, $client2 ); |
|
91 | + $this->assertNotSame($client1, $client2); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
95 | 95 | public function testClearSite() |
96 | 96 | { |
97 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
97 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
98 | 98 | |
99 | 99 | $context = \TestHelperJadm::getContext(); |
100 | 100 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
101 | 101 | |
102 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
103 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
104 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context ); |
|
102 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
103 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
104 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context); |
|
105 | 105 | |
106 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
107 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
106 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
107 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
108 | 108 | |
109 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
109 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
110 | 110 | |
111 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
112 | - $this->assertNotSame( $cntlB1, $cntlB2 ); |
|
111 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
112 | + $this->assertNotSame($cntlB1, $cntlB2); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | 116 | public function testClearSpecific() |
117 | 117 | { |
118 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
118 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
119 | 119 | |
120 | 120 | $context = \TestHelperJadm::getContext(); |
121 | 121 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
122 | 122 | |
123 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
124 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
123 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
124 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
125 | 125 | |
126 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context, 'order' ); |
|
126 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context, 'order'); |
|
127 | 127 | |
128 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
129 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
128 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
129 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
130 | 130 | |
131 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
131 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
132 | 132 | |
133 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
134 | - $this->assertSame( $cntlB1, $cntlB2 ); |
|
133 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
134 | + $this->assertSame($cntlB1, $cntlB2); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | } |
138 | 138 | \ 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] = []; |
@@ -65,14 +65,14 @@ 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 | $id = (string) $context; |
73 | 73 | |
74 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) { |
|
75 | - self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name ); |
|
74 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) { |
|
75 | + self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return self::$clients[$id][$path]; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param boolean $value True to enable caching, false to disable it. |
86 | 86 | * @return boolean Previous cache setting |
87 | 87 | */ |
88 | - static public function setCache( $value ) |
|
88 | + static public function setCache($value) |
|
89 | 89 | { |
90 | 90 | $old = self::$cache; |
91 | 91 | self::$cache = (boolean) $value; |
@@ -104,49 +104,49 @@ discard block |
||
104 | 104 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
105 | 105 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
106 | 106 | */ |
107 | - protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context, |
|
108 | - array $templatePaths, $path, $name ) |
|
107 | + protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context, |
|
108 | + array $templatePaths, $path, $name) |
|
109 | 109 | { |
110 | - if( empty( $path ) ) { |
|
111 | - return self::createClientRoot( $context, $templatePaths, $path, $name ); |
|
110 | + if (empty($path)) { |
|
111 | + return self::createClientRoot($context, $templatePaths, $path, $name); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | $pname = $name; |
116 | - $parts = explode( '/', $path ); |
|
116 | + $parts = explode('/', $path); |
|
117 | 117 | |
118 | - foreach( $parts as $key => $part ) |
|
118 | + foreach ($parts as $key => $part) |
|
119 | 119 | { |
120 | - if( ctype_alnum( $part ) === false ) |
|
120 | + if (ctype_alnum($part) === false) |
|
121 | 121 | { |
122 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
123 | - throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 ); |
|
122 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
123 | + throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400); |
|
124 | 124 | } |
125 | 125 | |
126 | - $parts[$key] = ucwords( $part ); |
|
126 | + $parts[$key] = ucwords($part); |
|
127 | 127 | } |
128 | 128 | |
129 | - if( $pname === null ) { |
|
130 | - $pname = $context->getConfig()->get( 'admin/jsonadm/' . $path . '/name', 'Standard' ); |
|
129 | + if ($pname === null) { |
|
130 | + $pname = $context->getConfig()->get('admin/jsonadm/' . $path . '/name', 'Standard'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | 134 | $view = $context->getView(); |
135 | 135 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
136 | - $classname = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\' . $pname; |
|
136 | + $classname = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\' . $pname; |
|
137 | 137 | |
138 | - if( ctype_alnum( $pname ) === false ) |
|
138 | + if (ctype_alnum($pname) === false) |
|
139 | 139 | { |
140 | - $classname = is_string( $pname ) ? $classname : '<not a string>'; |
|
141 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
140 | + $classname = is_string($pname) ? $classname : '<not a string>'; |
|
141 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
142 | 142 | } |
143 | 143 | |
144 | - if( class_exists( $classname ) === false ) { |
|
145 | - return self::createClientRoot( $context, $templatePaths, $path, $name ); |
|
144 | + if (class_exists($classname) === false) { |
|
145 | + return self::createClientRoot($context, $templatePaths, $path, $name); |
|
146 | 146 | } |
147 | 147 | |
148 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
149 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
148 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
149 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
161 | 161 | * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created |
162 | 162 | */ |
163 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
164 | - array $templatePaths, $path, $name = null ) |
|
163 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
164 | + array $templatePaths, $path, $name = null) |
|
165 | 165 | { |
166 | 166 | /** admin/jsonadm/name |
167 | 167 | * Class name of the used JSON API client implementation |
@@ -196,21 +196,21 @@ discard block |
||
196 | 196 | * @since 2015.12 |
197 | 197 | * @category Developer |
198 | 198 | */ |
199 | - if( $name === null ) { |
|
200 | - $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
|
199 | + if ($name === null) { |
|
200 | + $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); |
|
201 | 201 | } |
202 | 202 | |
203 | - if( ctype_alnum( $name ) === false ) |
|
203 | + if (ctype_alnum($name) === false) |
|
204 | 204 | { |
205 | - $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
206 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
205 | + $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
206 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | $view = $context->getView(); |
210 | 210 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
211 | 211 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
212 | 212 | |
213 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
213 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
214 | 214 | |
215 | 215 | /** admin/jsonadm/decorators/excludes |
216 | 216 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -290,6 +290,6 @@ discard block |
||
290 | 290 | * @see admin/jsonadm/decorators/global |
291 | 291 | */ |
292 | 292 | |
293 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
293 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
294 | 294 | } |
295 | 295 | } |
@@ -8,32 +8,32 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | |
11 | -$target = $this->config( 'admin/jsonadm/url/target' ); |
|
12 | -$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
13 | -$action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
14 | -$config = $this->config( 'admin/jsonadm/url/config', [] ); |
|
11 | +$target = $this->config('admin/jsonadm/url/target'); |
|
12 | +$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
13 | +$action = $this->config('admin/jsonadm/url/action', 'get'); |
|
14 | +$config = $this->config('admin/jsonadm/url/config', []); |
|
15 | 15 | |
16 | 16 | |
17 | 17 | $resources = $attributes = []; |
18 | -$site = $this->param( 'site', 'default' ); |
|
18 | +$site = $this->param('site', 'default'); |
|
19 | 19 | |
20 | -foreach( $this->get( 'resources', [] ) as $resource ) { |
|
21 | - $resources[$resource] = $this->url( $target, $cntl, $action, ['site' => $site, 'resource' => $resource], [], $config ); |
|
20 | +foreach ($this->get('resources', []) as $resource) { |
|
21 | + $resources[$resource] = $this->url($target, $cntl, $action, ['site' => $site, 'resource' => $resource], [], $config); |
|
22 | 22 | } |
23 | 23 | |
24 | -foreach( $this->get( 'attributes', [] ) as $attr ) { |
|
25 | - $attributes[$attr->getCode()] = $attr->toArray( true ); |
|
24 | +foreach ($this->get('attributes', []) as $attr) { |
|
25 | + $attributes[$attr->getCode()] = $attr->toArray(true); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | ?> |
30 | 30 | { |
31 | 31 | "meta": { |
32 | - "prefix": <?= json_encode( $this->get( 'prefix' ) ); ?>, |
|
33 | - "resources": <?= json_encode( $resources ); ?>, |
|
34 | - "attributes": <?= json_encode( $attributes ); ?> |
|
32 | + "prefix": <?= json_encode($this->get('prefix')); ?>, |
|
33 | + "resources": <?= json_encode($resources); ?>, |
|
34 | + "attributes": <?= json_encode($attributes); ?> |
|
35 | 35 | |
36 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
36 | + <?php if ($this->csrf()->name() != '') : ?> |
|
37 | 37 | , "csrf": { |
38 | 38 | "name": "<?= $this->csrf()->name(); ?>", |
39 | 39 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | <?php endif; ?> |
42 | 42 | } |
43 | 43 | |
44 | - <?php if( isset( $this->errors ) ) : ?> |
|
44 | + <?php if (isset($this->errors)) : ?> |
|
45 | 45 | |
46 | - ,"errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
46 | + ,"errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
47 | 47 | |
48 | 48 | <?php endif; ?> |
49 | 49 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $this->context = \TestHelperJadm::getContext(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Coupon\Config\Standard( $this->context, $this->view, $templatePaths, 'coupon/config' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Coupon\Config\Standard($this->context, $this->view, $templatePaths, 'coupon/config'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | $params = array( |
32 | 32 | 'id' => 'Example,Required,BasketValues', |
33 | 33 | ); |
34 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
35 | - $this->view->addHelper( 'param', $helper ); |
|
34 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
35 | + $this->view->addHelper('param', $helper); |
|
36 | 36 | |
37 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
38 | - $result = json_decode( (string) $response->getBody(), true ); |
|
37 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
38 | + $result = json_decode((string) $response->getBody(), true); |
|
39 | 39 | |
40 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
41 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
40 | + $this->assertEquals(200, $response->getStatusCode()); |
|
41 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
42 | 42 | |
43 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
44 | - $this->assertInternalType( 'array', $result['data'] ); |
|
45 | - $this->assertEquals( 'basketvalues.total-value-min', $result['data'][0]['id'] ); |
|
46 | - $this->assertEquals( 'basketvalues.total-value-max', $result['data'][1]['id'] ); |
|
43 | + $this->assertEquals(2, $result['meta']['total']); |
|
44 | + $this->assertInternalType('array', $result['data']); |
|
45 | + $this->assertEquals('basketvalues.total-value-min', $result['data'][0]['id']); |
|
46 | + $this->assertEquals('basketvalues.total-value-max', $result['data'][1]['id']); |
|
47 | 47 | |
48 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
48 | + $this->assertArrayNotHasKey('errors', $result); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | \ No newline at end of file |
@@ -118,16 +118,14 @@ |
||
118 | 118 | { |
119 | 119 | $response = $this->getItems( $view, $request, $response ); |
120 | 120 | $status = 200; |
121 | - } |
|
122 | - catch( \Aimeos\MShop\Exception $e ) |
|
121 | + } catch( \Aimeos\MShop\Exception $e ) |
|
123 | 122 | { |
124 | 123 | $status = 404; |
125 | 124 | $view->errors = array( array( |
126 | 125 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
127 | 126 | 'detail' => $e->getTraceAsString(), |
128 | 127 | ) ); |
129 | - } |
|
130 | - catch( \Exception $e ) |
|
128 | + } catch( \Exception $e ) |
|
131 | 129 | { |
132 | 130 | $status = 500; |
133 | 131 | $view->errors = array( array( |
@@ -110,30 +110,30 @@ discard block |
||
110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
112 | 112 | */ |
113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
114 | 114 | { |
115 | 115 | $view = $this->getView(); |
116 | 116 | |
117 | 117 | try |
118 | 118 | { |
119 | - $response = $this->getItems( $view, $request, $response ); |
|
119 | + $response = $this->getItems($view, $request, $response); |
|
120 | 120 | $status = 200; |
121 | 121 | } |
122 | - catch( \Aimeos\MShop\Exception $e ) |
|
122 | + catch (\Aimeos\MShop\Exception $e) |
|
123 | 123 | { |
124 | 124 | $status = 404; |
125 | - $view->errors = array( array( |
|
126 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
125 | + $view->errors = array(array( |
|
126 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
127 | 127 | 'detail' => $e->getTraceAsString(), |
128 | - ) ); |
|
128 | + )); |
|
129 | 129 | } |
130 | - catch( \Exception $e ) |
|
130 | + catch (\Exception $e) |
|
131 | 131 | { |
132 | 132 | $status = 500; |
133 | - $view->errors = array( array( |
|
133 | + $view->errors = array(array( |
|
134 | 134 | 'title' => $e->getMessage(), |
135 | 135 | 'detail' => $e->getTraceAsString(), |
136 | - ) ); |
|
136 | + )); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** admin/jsonadm/coupon/config/template-get |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | $tplconf = 'admin/jsonadm/coupon/config/template-get'; |
159 | 159 | $default = 'config-default.php'; |
160 | 160 | |
161 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
161 | + $body = $view->render($view->config($tplconf, $default)); |
|
162 | 162 | |
163 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
164 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
165 | - ->withStatus( $status ); |
|
163 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
164 | + ->withBody($view->response()->createStreamFromString($body)) |
|
165 | + ->withStatus($status); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
175 | 175 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
176 | 176 | */ |
177 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
177 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
178 | 178 | { |
179 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
180 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
179 | + if (($id = $view->param('id')) == null) { |
|
180 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
181 | 181 | } |
182 | 182 | |
183 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
183 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
184 | 184 | |
185 | 185 | $item = $manager->createItem(); |
186 | - $item->setProvider( $id ); |
|
186 | + $item->setProvider($id); |
|
187 | 187 | |
188 | - $view->configItems = $manager->getProvider( $item, null )->getConfigBE(); |
|
188 | + $view->configItems = $manager->getProvider($item, null)->getConfigBE(); |
|
189 | 189 | |
190 | 190 | return $response; |
191 | 191 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
112 | 112 | */ |
113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
114 | 114 | { |
115 | 115 | /** admin/jsonadm/partials/catalog/template-data |
116 | 116 | * Relative path to the data partial template file for the catalog client |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @since 2016.07 |
128 | 128 | * @category Developer |
129 | 129 | */ |
130 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/catalog/template-data' ) ); |
|
130 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/catalog/template-data')); |
|
131 | 131 | |
132 | - return parent::get( $request, $response ); |
|
132 | + return parent::get($request, $response); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -140,14 +140,14 @@ discard block |
||
140 | 140 | * @param array $include List of resource types that should be fetched |
141 | 141 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
142 | 142 | */ |
143 | - protected function getChildItems( array $items, array $include ) |
|
143 | + protected function getChildItems(array $items, array $include) |
|
144 | 144 | { |
145 | 145 | $list = []; |
146 | 146 | |
147 | - if( in_array( 'catalog', $include ) ) |
|
147 | + if (in_array('catalog', $include)) |
|
148 | 148 | { |
149 | - foreach( $items as $item ) { |
|
150 | - $list = array_merge( $list, [$item], $this->getChildItems( $item->getChildren(), $include ) ); |
|
149 | + foreach ($items as $item) { |
|
150 | + $list = array_merge($list, [$item], $this->getChildItems($item->getChildren(), $include)); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -162,40 +162,40 @@ discard block |
||
162 | 162 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
163 | 163 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
164 | 164 | */ |
165 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
165 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
166 | 166 | { |
167 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' ); |
|
167 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); |
|
168 | 168 | |
169 | - if( ( $key = $view->param( 'aggregate' ) ) !== null ) |
|
169 | + if (($key = $view->param('aggregate')) !== null) |
|
170 | 170 | { |
171 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
172 | - $view->data = $manager->aggregate( $search, $key ); |
|
171 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
172 | + $view->data = $manager->aggregate($search, $key); |
|
173 | 173 | return $response; |
174 | 174 | } |
175 | 175 | |
176 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : [] ); |
|
177 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
176 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : []); |
|
177 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
178 | 178 | $total = 1; |
179 | 179 | |
180 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
180 | + if (($id = $view->param('id')) == null) |
|
181 | 181 | { |
182 | - $view->data = $manager->searchItems( $search, [], $total ); |
|
183 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
182 | + $view->data = $manager->searchItems($search, [], $total); |
|
183 | + $view->listItems = $this->getListItems($view->data, $include); |
|
184 | 184 | $view->childItems = []; |
185 | 185 | } |
186 | 186 | else |
187 | 187 | { |
188 | 188 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST; |
189 | - if( in_array( 'catalog', $include ) ) { |
|
189 | + if (in_array('catalog', $include)) { |
|
190 | 190 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE; |
191 | 191 | } |
192 | 192 | |
193 | - $view->data = $manager->getTree( $id, $include, $level, $search ); |
|
194 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
195 | - $view->childItems = $this->getChildItems( $view->data->getChildren(), $include ); |
|
193 | + $view->data = $manager->getTree($id, $include, $level, $search); |
|
194 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
195 | + $view->childItems = $this->getChildItems($view->data->getChildren(), $include); |
|
196 | 196 | } |
197 | 197 | |
198 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
198 | + $view->refItems = $this->getRefItems($view->listItems); |
|
199 | 199 | $view->total = $total; |
200 | 200 | |
201 | 201 | return $response; |
@@ -209,18 +209,18 @@ discard block |
||
209 | 209 | * @param array $include List of resource types that should be fetched |
210 | 210 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
211 | 211 | */ |
212 | - protected function getListItems( array $items, array $include ) |
|
212 | + protected function getListItems(array $items, array $include) |
|
213 | 213 | { |
214 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
214 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
215 | 215 | |
216 | 216 | $search = $manager->createSearch(); |
217 | 217 | $expr = array( |
218 | - $search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ), |
|
219 | - $search->compare( '==', 'catalog.lists.domain', $include ), |
|
218 | + $search->compare('==', 'catalog.lists.parentid', array_keys($items)), |
|
219 | + $search->compare('==', 'catalog.lists.domain', $include), |
|
220 | 220 | ); |
221 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
221 | + $search->setConditions($search->combine('&&', $expr)); |
|
222 | 222 | |
223 | - return $manager->searchItems( $search ); |
|
223 | + return $manager->searchItems($search); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -231,32 +231,32 @@ discard block |
||
231 | 231 | * @param \stdClass $entry Object including "id" and "attributes" elements |
232 | 232 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
233 | 233 | */ |
234 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
234 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
235 | 235 | { |
236 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
237 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
236 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
237 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
238 | 238 | |
239 | - if( isset( $entry->id ) ) |
|
239 | + if (isset($entry->id)) |
|
240 | 240 | { |
241 | - $item = $manager->getItem( $entry->id ); |
|
242 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
243 | - $item = $manager->saveItem( $item ); |
|
241 | + $item = $manager->getItem($entry->id); |
|
242 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
243 | + $item = $manager->saveItem($item); |
|
244 | 244 | |
245 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
246 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
245 | + if (isset($entry->parentid) && $targetId !== null) { |
|
246 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | 251 | $item = $manager->createItem(); |
252 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
253 | - $manager->insertItem( $item, $targetId, $refId ); |
|
252 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
253 | + $manager->insertItem($item, $targetId, $refId); |
|
254 | 254 | } |
255 | 255 | |
256 | - if( isset( $entry->relationships ) ) { |
|
257 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
256 | + if (isset($entry->relationships)) { |
|
257 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
258 | 258 | } |
259 | 259 | |
260 | - return $manager->getItem( $item->getId() ); |
|
260 | + return $manager->getItem($item->getId()); |
|
261 | 261 | } |
262 | 262 | } |
@@ -182,8 +182,7 @@ discard block |
||
182 | 182 | $view->data = $manager->searchItems( $search, [], $total ); |
183 | 183 | $view->listItems = $this->getListItems( $view->data, $include ); |
184 | 184 | $view->childItems = []; |
185 | - } |
|
186 | - else |
|
185 | + } else |
|
187 | 186 | { |
188 | 187 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST; |
189 | 188 | if( in_array( 'catalog', $include ) ) { |
@@ -245,8 +244,7 @@ discard block |
||
245 | 244 | if( isset( $entry->parentid ) && $targetId !== null ) { |
246 | 245 | $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
247 | 246 | } |
248 | - } |
|
249 | - else |
|
247 | + } else |
|
250 | 248 | { |
251 | 249 | $item = $manager->createItem(); |
252 | 250 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $this->context = \TestHelperJadm::getContext(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard( $this->context, $this->view, $templatePaths, 'catalog' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard($this->context, $this->view, $templatePaths, 'catalog'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,142 +30,142 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'catalog.code' => 'cafe' ) |
|
33 | + '==' => array('catalog.code' => 'cafe') |
|
34 | 34 | ), |
35 | 35 | 'include' => 'text' |
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 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
41 | + $result = json_decode((string) $response->getBody(), true); |
|
42 | 42 | |
43 | 43 | |
44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
46 | 46 | |
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'catalog', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) ); |
|
51 | - $this->assertEquals( 6, count( $result['included'] ) ); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('catalog', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(6, count($result['data'][0]['relationships']['text'])); |
|
51 | + $this->assertEquals(6, count($result['included'])); |
|
52 | 52 | |
53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
53 | + $this->assertArrayNotHasKey('errors', $result); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | public function testGetTree() |
58 | 58 | { |
59 | 59 | $params = array( |
60 | - 'id' => $this->getCatalogItem( 'root' )->getId(), |
|
60 | + 'id' => $this->getCatalogItem('root')->getId(), |
|
61 | 61 | 'include' => 'catalog,text' |
62 | 62 | ); |
63 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
64 | - $this->view->addHelper( 'param', $helper ); |
|
63 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
64 | + $this->view->addHelper('param', $helper); |
|
65 | 65 | |
66 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
67 | - $result = json_decode( (string) $response->getBody(), true ); |
|
66 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
67 | + $result = json_decode((string) $response->getBody(), true); |
|
68 | 68 | |
69 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
70 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
69 | + $this->assertEquals(200, $response->getStatusCode()); |
|
70 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
71 | 71 | |
72 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
73 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
74 | - $this->assertEquals( 2, count( $result['data']['relationships']['catalog'] ) ); |
|
75 | - $this->assertEquals( 7, count( $result['included'] ) ); |
|
72 | + $this->assertEquals(1, $result['meta']['total']); |
|
73 | + $this->assertEquals('catalog', $result['data']['type']); |
|
74 | + $this->assertEquals(2, count($result['data']['relationships']['catalog'])); |
|
75 | + $this->assertEquals(7, count($result['included'])); |
|
76 | 76 | |
77 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
77 | + $this->assertArrayNotHasKey('errors', $result); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testPatch() |
82 | 82 | { |
83 | - $stub = $this->getCatalogMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
83 | + $stub = $this->getCatalogMock(array('getItem', 'moveItem', 'saveItem')); |
|
84 | 84 | |
85 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
86 | - $stub->expects( $this->once() )->method( 'saveItem' ) |
|
87 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
88 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
89 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
85 | + $stub->expects($this->once())->method('moveItem'); |
|
86 | + $stub->expects($this->once())->method('saveItem') |
|
87 | + ->will($this->returnValue($stub->createItem())); |
|
88 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
89 | + ->will($this->returnValue($stub->createItem())); |
|
90 | 90 | |
91 | 91 | |
92 | - $params = array( 'id' => '-1' ); |
|
93 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
94 | - $this->view->addHelper( 'param', $helper ); |
|
92 | + $params = array('id' => '-1'); |
|
93 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
94 | + $this->view->addHelper('param', $helper); |
|
95 | 95 | |
96 | 96 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "catalog", "attributes": {"catalog.label": "test"}}}'; |
97 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
97 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
98 | 98 | |
99 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
100 | - $result = json_decode( (string) $response->getBody(), true ); |
|
99 | + $response = $this->object->patch($request, $this->view->response()); |
|
100 | + $result = json_decode((string) $response->getBody(), true); |
|
101 | 101 | |
102 | 102 | |
103 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
104 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
103 | + $this->assertEquals(200, $response->getStatusCode()); |
|
104 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
105 | 105 | |
106 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
107 | - $this->assertArrayHasKey( 'data', $result ); |
|
108 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
106 | + $this->assertEquals(1, $result['meta']['total']); |
|
107 | + $this->assertArrayHasKey('data', $result); |
|
108 | + $this->assertEquals('catalog', $result['data']['type']); |
|
109 | 109 | |
110 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
111 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
110 | + $this->assertArrayNotHasKey('included', $result); |
|
111 | + $this->assertArrayNotHasKey('errors', $result); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testPost() |
116 | 116 | { |
117 | - $stub = $this->getCatalogMock( array( 'getItem', 'insertItem' ) ); |
|
117 | + $stub = $this->getCatalogMock(array('getItem', 'insertItem')); |
|
118 | 118 | |
119 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
120 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
121 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
119 | + $stub->expects($this->any())->method('getItem') |
|
120 | + ->will($this->returnValue($stub->createItem())); |
|
121 | + $stub->expects($this->once())->method('insertItem'); |
|
122 | 122 | |
123 | 123 | |
124 | 124 | $body = '{"data": {"type": "catalog", "attributes": {"catalog.code": "test", "catalog.label": "Test catalog"}}}'; |
125 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
125 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
126 | 126 | |
127 | - $response = $this->object->post( $request, $this->view->response() ); |
|
128 | - $result = json_decode( (string) $response->getBody(), true ); |
|
127 | + $response = $this->object->post($request, $this->view->response()); |
|
128 | + $result = json_decode((string) $response->getBody(), true); |
|
129 | 129 | |
130 | 130 | |
131 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
132 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
131 | + $this->assertEquals(201, $response->getStatusCode()); |
|
132 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
133 | 133 | |
134 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
135 | - $this->assertArrayHasKey( 'data', $result ); |
|
136 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
134 | + $this->assertEquals(1, $result['meta']['total']); |
|
135 | + $this->assertArrayHasKey('data', $result); |
|
136 | + $this->assertEquals('catalog', $result['data']['type']); |
|
137 | 137 | |
138 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
139 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
138 | + $this->assertArrayNotHasKey('included', $result); |
|
139 | + $this->assertArrayNotHasKey('errors', $result); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | - protected function getCatalogItem( $code ) |
|
143 | + protected function getCatalogItem($code) |
|
144 | 144 | { |
145 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
145 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
146 | 146 | $search = $manager->createSearch(); |
147 | - $search->setConditions( $search->compare( '==', 'catalog.code', $code ) ); |
|
148 | - $items = $manager->searchItems( $search ); |
|
147 | + $search->setConditions($search->compare('==', 'catalog.code', $code)); |
|
148 | + $items = $manager->searchItems($search); |
|
149 | 149 | |
150 | - if( ( $item = reset( $items ) ) === false ) { |
|
151 | - throw new \RuntimeException( sprintf( 'No catalog item with code "%1$s" found', $code ) ); |
|
150 | + if (($item = reset($items)) === false) { |
|
151 | + throw new \RuntimeException(sprintf('No catalog item with code "%1$s" found', $code)); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | return $item; |
155 | 155 | } |
156 | 156 | |
157 | 157 | |
158 | - protected function getCatalogMock( array $methods ) |
|
158 | + protected function getCatalogMock(array $methods) |
|
159 | 159 | { |
160 | 160 | $name = 'ClientJsonAdmStandard'; |
161 | - $this->context->getConfig()->set( 'mshop/catalog/manager/name', $name ); |
|
161 | + $this->context->getConfig()->set('mshop/catalog/manager/name', $name); |
|
162 | 162 | |
163 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Catalog\\Manager\\Standard' ) |
|
164 | - ->setConstructorArgs( array( $this->context ) ) |
|
165 | - ->setMethods( $methods ) |
|
163 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Catalog\\Manager\\Standard') |
|
164 | + ->setConstructorArgs(array($this->context)) |
|
165 | + ->setMethods($methods) |
|
166 | 166 | ->getMock(); |
167 | 167 | |
168 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub ); |
|
168 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub); |
|
169 | 169 | |
170 | 170 | return $stub; |
171 | 171 | } |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | ?> |
12 | 12 | { |
13 | 13 | "meta": { |
14 | - "total": <?= $this->get( 'total', 0 ); ?> |
|
14 | + "total": <?= $this->get('total', 0); ?> |
|
15 | 15 | |
16 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
16 | + <?php if ($this->csrf()->name() != '') : ?> |
|
17 | 17 | , "csrf": { |
18 | 18 | "name": "<?= $this->csrf()->name(); ?>", |
19 | 19 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | |
23 | 23 | } |
24 | 24 | |
25 | - <?php if( isset( $this->errors ) ) : ?> |
|
25 | + <?php if (isset($this->errors)) : ?> |
|
26 | 26 | |
27 | - ,"errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
27 | + ,"errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
28 | 28 | |
29 | 29 | <?php endif; ?> |
30 | 30 |