@@ -9,32 +9,32 @@ discard block |
||
9 | 9 | |
10 | 10 | |
11 | 11 | $options = 0; |
12 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
12 | +if (defined('JSON_PRETTY_PRINT')) { |
|
13 | 13 | $options = JSON_PRETTY_PRINT; |
14 | 14 | } |
15 | 15 | |
16 | 16 | |
17 | -$fields = $this->param( 'fields', [] ); |
|
17 | +$fields = $this->param('fields', []); |
|
18 | 18 | |
19 | -foreach( (array) $fields as $resource => $list ) { |
|
20 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
19 | +foreach ((array) $fields as $resource => $list) { |
|
20 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
24 | -$build = function( \Aimeos\MShop\Locale\Item\Site\Iface $item ) use ( $fields ) |
|
24 | +$build = function(\Aimeos\MShop\Locale\Item\Site\Iface $item) use ($fields) |
|
25 | 25 | { |
26 | 26 | $id = $item->getId(); |
27 | 27 | $type = $item->getResourceType(); |
28 | - $params = array( 'resource' => $type, 'id' => $id ); |
|
29 | - $attributes = $item->toArray( true ); |
|
28 | + $params = array('resource' => $type, 'id' => $id); |
|
29 | + $attributes = $item->toArray(true); |
|
30 | 30 | |
31 | - $target = $this->config( 'admin/jsonadm/url/target' ); |
|
32 | - $cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
33 | - $action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
34 | - $config = $this->config( 'admin/jsonadm/url/config', [] ); |
|
31 | + $target = $this->config('admin/jsonadm/url/target'); |
|
32 | + $cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
33 | + $action = $this->config('admin/jsonadm/url/action', 'get'); |
|
34 | + $config = $this->config('admin/jsonadm/url/config', []); |
|
35 | 35 | |
36 | - if( isset( $fields[$type] ) ) { |
|
37 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
36 | + if (isset($fields[$type])) { |
|
37 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $result = array( |
@@ -42,34 +42,34 @@ discard block |
||
42 | 42 | 'type' => $type, |
43 | 43 | 'attributes' => $attributes, |
44 | 44 | 'links' => array( |
45 | - 'self' => $this->url( $target, $cntl, $action, $params, [], $config ) |
|
45 | + 'self' => $this->url($target, $cntl, $action, $params, [], $config) |
|
46 | 46 | ), |
47 | 47 | 'relationships' => [] |
48 | 48 | ); |
49 | 49 | |
50 | - foreach( $item->getChildren() as $childItem ) |
|
50 | + foreach ($item->getChildren() as $childItem) |
|
51 | 51 | { |
52 | 52 | $type = $childItem->getResourceType(); |
53 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
53 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return $result; |
57 | 57 | }; |
58 | 58 | |
59 | 59 | |
60 | -$data = $this->get( 'data', [] ); |
|
60 | +$data = $this->get('data', []); |
|
61 | 61 | |
62 | -if( is_array( $data ) ) |
|
62 | +if (is_array($data)) |
|
63 | 63 | { |
64 | 64 | $response = []; |
65 | 65 | |
66 | - foreach( $data as $item ) { |
|
67 | - $response[] = $build( $item ); |
|
66 | + foreach ($data as $item) { |
|
67 | + $response[] = $build($item); |
|
68 | 68 | } |
69 | 69 | } |
70 | -elseif( $data !== null ) |
|
70 | +elseif ($data !== null) |
|
71 | 71 | { |
72 | - $response = $build( $data ); |
|
72 | + $response = $build($data); |
|
73 | 73 | } |
74 | 74 | else |
75 | 75 | { |
@@ -77,4 +77,4 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | |
80 | -echo json_encode( $response, $options ); |
|
81 | 80 | \ No newline at end of file |
81 | +echo json_encode($response, $options); |
|
82 | 82 | \ No newline at end of file |
@@ -66,12 +66,10 @@ |
||
66 | 66 | foreach( $data as $item ) { |
67 | 67 | $response[] = $build( $item ); |
68 | 68 | } |
69 | -} |
|
70 | -elseif( $data !== null ) |
|
69 | +} elseif( $data !== null ) |
|
71 | 70 | { |
72 | 71 | $response = $build( $data ); |
73 | -} |
|
74 | -else |
|
72 | +} else |
|
75 | 73 | { |
76 | 74 | $response = null; |
77 | 75 | } |
@@ -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\Locale\Site\Standard( $this->context, $this->view, $templatePaths, 'locale/site' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Locale\Site\Standard($this->context, $this->view, $templatePaths, 'locale/site'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,153 +30,153 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'locale.site.code' => 'unittest' ) |
|
33 | + '==' => array('locale.site.code' => 'unittest') |
|
34 | 34 | ), |
35 | 35 | ); |
36 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
37 | - $this->view->addHelper( 'param', $helper ); |
|
36 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
37 | + $this->view->addHelper('param', $helper); |
|
38 | 38 | |
39 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
40 | - $result = json_decode( (string) $response->getBody(), true ); |
|
39 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
40 | + $result = json_decode((string) $response->getBody(), true); |
|
41 | 41 | |
42 | 42 | |
43 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
44 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
43 | + $this->assertEquals(200, $response->getStatusCode()); |
|
44 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
45 | 45 | |
46 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
47 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
48 | - $this->assertEquals( 'locale/site', $result['data'][0]['type'] ); |
|
49 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
46 | + $this->assertEquals(1, $result['meta']['total']); |
|
47 | + $this->assertEquals(1, count($result['data'])); |
|
48 | + $this->assertEquals('locale/site', $result['data'][0]['type']); |
|
49 | + $this->assertEquals(0, count($result['included'])); |
|
50 | 50 | |
51 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
51 | + $this->assertArrayNotHasKey('errors', $result); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testGetTree() |
56 | 56 | { |
57 | 57 | $params = array( |
58 | - 'id' => $this->getSiteItem( 'unittest' )->getId(), |
|
58 | + 'id' => $this->getSiteItem('unittest')->getId(), |
|
59 | 59 | 'filter' => array( |
60 | - '==' => array( 'locale.status' => 0 ) |
|
60 | + '==' => array('locale.status' => 0) |
|
61 | 61 | ), |
62 | 62 | 'include' => 'locale/site' |
63 | 63 | ); |
64 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
65 | - $this->view->addHelper( 'param', $helper ); |
|
64 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
65 | + $this->view->addHelper('param', $helper); |
|
66 | 66 | |
67 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
68 | - $result = json_decode( (string) $response->getBody(), true ); |
|
67 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
68 | + $result = json_decode((string) $response->getBody(), true); |
|
69 | 69 | |
70 | 70 | |
71 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
72 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
71 | + $this->assertEquals(200, $response->getStatusCode()); |
|
72 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
73 | 73 | |
74 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
75 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
76 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
74 | + $this->assertEquals(1, $result['meta']['total']); |
|
75 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
76 | + $this->assertEquals(0, count($result['included'])); |
|
77 | 77 | |
78 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
78 | + $this->assertArrayNotHasKey('errors', $result); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | 82 | public function testPatch() |
83 | 83 | { |
84 | - $stub = $this->getSiteMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
84 | + $stub = $this->getSiteMock(array('getItem', 'moveItem', 'saveItem')); |
|
85 | 85 | $item = $stub->createItem(); |
86 | 86 | |
87 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
88 | - $stub->expects( $this->once() )->method( 'saveItem' ) |
|
89 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
90 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
91 | - ->will( $this->returnValue( $item ) ); |
|
87 | + $stub->expects($this->once())->method('moveItem'); |
|
88 | + $stub->expects($this->once())->method('saveItem') |
|
89 | + ->will($this->returnValue($stub->createItem())); |
|
90 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
91 | + ->will($this->returnValue($item)); |
|
92 | 92 | |
93 | 93 | |
94 | - $params = array( 'id' => '-1' ); |
|
95 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
96 | - $this->view->addHelper( 'param', $helper ); |
|
94 | + $params = array('id' => '-1'); |
|
95 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
96 | + $this->view->addHelper('param', $helper); |
|
97 | 97 | |
98 | 98 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "locale/site", "attributes": {"locale.site.label": "test"}}}'; |
99 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
99 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
100 | 100 | |
101 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
102 | - $result = json_decode( (string) $response->getBody(), true ); |
|
101 | + $response = $this->object->patch($request, $this->view->response()); |
|
102 | + $result = json_decode((string) $response->getBody(), true); |
|
103 | 103 | |
104 | 104 | |
105 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
106 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
105 | + $this->assertEquals(200, $response->getStatusCode()); |
|
106 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
107 | 107 | |
108 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
109 | - $this->assertArrayHasKey( 'data', $result ); |
|
110 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
108 | + $this->assertEquals(1, $result['meta']['total']); |
|
109 | + $this->assertArrayHasKey('data', $result); |
|
110 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
111 | 111 | |
112 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
113 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
112 | + $this->assertArrayNotHasKey('included', $result); |
|
113 | + $this->assertArrayNotHasKey('errors', $result); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
117 | 117 | public function testPost() |
118 | 118 | { |
119 | - $stub = $this->getSiteMock( array( 'getItem', 'insertItem' ) ); |
|
119 | + $stub = $this->getSiteMock(array('getItem', 'insertItem')); |
|
120 | 120 | $item = $stub->createItem(); |
121 | 121 | |
122 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
123 | - ->will( $this->returnValue( $item ) ); |
|
124 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
122 | + $stub->expects($this->any())->method('getItem') |
|
123 | + ->will($this->returnValue($item)); |
|
124 | + $stub->expects($this->once())->method('insertItem'); |
|
125 | 125 | |
126 | 126 | |
127 | 127 | $body = '{"data": {"type": "locale/site", "attributes": {"locale.site.code": "unittest", "locale.site.label": "Unit test"}}}'; |
128 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
128 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
129 | 129 | |
130 | - $response = $this->object->post( $request, $this->view->response() ); |
|
131 | - $result = json_decode( (string) $response->getBody(), true ); |
|
130 | + $response = $this->object->post($request, $this->view->response()); |
|
131 | + $result = json_decode((string) $response->getBody(), true); |
|
132 | 132 | |
133 | 133 | |
134 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
135 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
134 | + $this->assertEquals(201, $response->getStatusCode()); |
|
135 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
136 | 136 | |
137 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
138 | - $this->assertArrayHasKey( 'data', $result ); |
|
139 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
137 | + $this->assertEquals(1, $result['meta']['total']); |
|
138 | + $this->assertArrayHasKey('data', $result); |
|
139 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
140 | 140 | |
141 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
142 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
141 | + $this->assertArrayNotHasKey('included', $result); |
|
142 | + $this->assertArrayNotHasKey('errors', $result); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | - protected function getSiteItem( $code ) |
|
146 | + protected function getSiteItem($code) |
|
147 | 147 | { |
148 | - $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $this->context )->getSubManager( 'site' ); |
|
148 | + $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->context)->getSubManager('site'); |
|
149 | 149 | $search = $manager->createSearch(); |
150 | - $search->setConditions( $search->compare( '==', 'locale.site.code', $code ) ); |
|
151 | - $items = $manager->searchItems( $search ); |
|
150 | + $search->setConditions($search->compare('==', 'locale.site.code', $code)); |
|
151 | + $items = $manager->searchItems($search); |
|
152 | 152 | |
153 | - if( ( $item = reset( $items ) ) === false ) { |
|
154 | - throw new \RuntimeException( sprintf( 'No locale site item with code "%1$s" found', $code ) ); |
|
153 | + if (($item = reset($items)) === false) { |
|
154 | + throw new \RuntimeException(sprintf('No locale site item with code "%1$s" found', $code)); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $item; |
158 | 158 | } |
159 | 159 | |
160 | 160 | |
161 | - protected function getSiteMock( array $methods ) |
|
161 | + protected function getSiteMock(array $methods) |
|
162 | 162 | { |
163 | 163 | $name = 'ClientJsonAdmStandard'; |
164 | - $this->context->getConfig()->set( 'mshop/locale/manager/name', $name ); |
|
164 | + $this->context->getConfig()->set('mshop/locale/manager/name', $name); |
|
165 | 165 | |
166 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Standard' ) |
|
167 | - ->setConstructorArgs( array( $this->context ) ) |
|
168 | - ->setMethods( array( 'getSubManager' ) ) |
|
166 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Standard') |
|
167 | + ->setConstructorArgs(array($this->context)) |
|
168 | + ->setMethods(array('getSubManager')) |
|
169 | 169 | ->getMock(); |
170 | 170 | |
171 | - $siteStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard' ) |
|
172 | - ->setConstructorArgs( array( $this->context ) ) |
|
173 | - ->setMethods( $methods ) |
|
171 | + $siteStub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard') |
|
172 | + ->setConstructorArgs(array($this->context)) |
|
173 | + ->setMethods($methods) |
|
174 | 174 | ->getMock(); |
175 | 175 | |
176 | - $stub->expects( $this->once() )->method( 'getSubManager' ) |
|
177 | - ->will( $this->returnValue( $siteStub ) ); |
|
176 | + $stub->expects($this->once())->method('getSubManager') |
|
177 | + ->will($this->returnValue($siteStub)); |
|
178 | 178 | |
179 | - \Aimeos\MShop\Locale\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub ); |
|
179 | + \Aimeos\MShop\Locale\Manager\Factory::injectManager('\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub); |
|
180 | 180 | |
181 | 181 | return $siteStub; |
182 | 182 | } |
@@ -9,29 +9,29 @@ discard block |
||
9 | 9 | |
10 | 10 | |
11 | 11 | $options = 0; |
12 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
12 | +if (defined('JSON_PRETTY_PRINT')) { |
|
13 | 13 | $options = JSON_PRETTY_PRINT; |
14 | 14 | } |
15 | 15 | |
16 | 16 | |
17 | -$fields = $this->param( 'fields', [] ); |
|
17 | +$fields = $this->param('fields', []); |
|
18 | 18 | |
19 | -foreach( (array) $fields as $resource => $list ) { |
|
20 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
19 | +foreach ((array) $fields as $resource => $list) { |
|
20 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
24 | -$build = function( array $attrItems, $id ) use ( $fields ) |
|
24 | +$build = function(array $attrItems, $id) use ($fields) |
|
25 | 25 | { |
26 | 26 | $result = []; |
27 | 27 | $type = 'criteria/attribute'; |
28 | 28 | |
29 | - foreach( $attrItems as $attrItem ) |
|
29 | + foreach ($attrItems as $attrItem) |
|
30 | 30 | { |
31 | - $attributes = $attrItem->toArray( true ); |
|
31 | + $attributes = $attrItem->toArray(true); |
|
32 | 32 | |
33 | - if( isset( $fields[$type] ) ) { |
|
34 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
33 | + if (isset($fields[$type])) { |
|
34 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $result[] = array( |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | }; |
46 | 46 | |
47 | 47 | |
48 | -$configItems = $this->get( 'configItems', [] ); |
|
48 | +$configItems = $this->get('configItems', []); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | ?> |
52 | 52 | { |
53 | 53 | "meta": { |
54 | - "total": <?= count( $configItems ); ?> |
|
54 | + "total": <?= count($configItems); ?> |
|
55 | 55 | |
56 | 56 | } |
57 | 57 | |
58 | - <?php if( isset( $this->errors ) ) : ?> |
|
58 | + <?php if (isset($this->errors)) : ?> |
|
59 | 59 | |
60 | - , "errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
60 | + , "errors": <?= $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
61 | 61 | |
62 | 62 | <?php else : ?> |
63 | 63 | |
64 | - , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); ?> |
|
64 | + , "data": <?= json_encode($build($configItems, $this->param('id')), $options); ?> |
|
65 | 65 | |
66 | 66 | <?php endif; ?> |
67 | 67 | } |
@@ -59,9 +59,12 @@ |
||
59 | 59 | |
60 | 60 | , "errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
61 | 61 | |
62 | - <?php else : ?> |
|
62 | + <?php else { |
|
63 | + : ?> |
|
63 | 64 | |
64 | - , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); ?> |
|
65 | + , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); |
|
66 | +} |
|
67 | +?> |
|
65 | 68 | |
66 | 69 | <?php endif; ?> |
67 | 70 | } |
@@ -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 |
@@ -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 = 'coupon/config/get-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 | } |
@@ -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( |