@@ -1,12 +1,12 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>, |
|
4 | -<?php elseif( isset( $this->data ) ) : ?> |
|
5 | - "data": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>, |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>, |
|
4 | +<?php elseif (isset($this->data)) : ?> |
|
5 | + "data": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>, |
|
6 | 6 | <?php endif; ?> |
7 | 7 | |
8 | 8 | "meta": { |
9 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
9 | + "total": <?php echo $this->get('total', 0); ?> |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | } |
@@ -1,29 +1,29 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$target = $this->config( 'admin/jsonadm/url/target' ); |
|
4 | -$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
5 | -$action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
6 | -$config = $this->config( 'admin/jsonadm/url/config', array() ); |
|
3 | +$target = $this->config('admin/jsonadm/url/target'); |
|
4 | +$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
5 | +$action = $this->config('admin/jsonadm/url/action', 'get'); |
|
6 | +$config = $this->config('admin/jsonadm/url/config', array()); |
|
7 | 7 | |
8 | 8 | $resources = $attributes = array(); |
9 | -$site = $this->param( 'site', 'default' ); |
|
9 | +$site = $this->param('site', 'default'); |
|
10 | 10 | |
11 | -foreach( $this->get( 'resources', array() ) as $resource ) { |
|
12 | - $resources[$resource] = $this->url( $target, $cntl, $action, array( 'site' => $site, 'resource' => $resource, 'id' => '' ), array(), $config ); |
|
11 | +foreach ($this->get('resources', array()) as $resource) { |
|
12 | + $resources[$resource] = $this->url($target, $cntl, $action, array('site' => $site, 'resource' => $resource, 'id' => ''), array(), $config); |
|
13 | 13 | } |
14 | 14 | |
15 | -foreach( $this->get( 'attributes', array() ) as $attr ) { |
|
15 | +foreach ($this->get('attributes', array()) as $attr) { |
|
16 | 16 | $attributes[$attr->getCode()] = $attr->toArray(); |
17 | 17 | } |
18 | 18 | |
19 | 19 | ?> |
20 | 20 | { |
21 | 21 | "meta": { |
22 | - "resources": <?php echo json_encode( $resources ); ?>, |
|
23 | - "attributes": <?php echo json_encode( $attributes ); ?> |
|
22 | + "resources": <?php echo json_encode($resources); ?>, |
|
23 | + "attributes": <?php echo json_encode($attributes); ?> |
|
24 | 24 | } |
25 | -<?php if( isset( $this->errors ) ) : ?> |
|
26 | - ,"errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
25 | +<?php if (isset($this->errors)) : ?> |
|
26 | + ,"errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
27 | 27 | <?php endif; ?> |
28 | 28 | |
29 | 29 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
4 | 4 | <?php endif; ?> |
5 | 5 | |
6 | 6 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @see admin/jsonadm/url/action |
15 | 15 | * @see admin/jsonadm/url/config |
16 | 16 | */ |
17 | -$target = $this->config( 'admin/jsonadm/url/target' ); |
|
17 | +$target = $this->config('admin/jsonadm/url/target'); |
|
18 | 18 | |
19 | 19 | /** admin/jsonadm/url/controller |
20 | 20 | * Name of the client whose action should be called |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @see admin/jsonadm/url/action |
31 | 31 | * @see admin/jsonadm/url/config |
32 | 32 | */ |
33 | -$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
33 | +$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
34 | 34 | |
35 | 35 | /** admin/jsonadm/url/action |
36 | 36 | * Name of the action that should create the output |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @see admin/jsonadm/url/controller |
47 | 47 | * @see admin/jsonadm/url/config |
48 | 48 | */ |
49 | -$action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
49 | +$action = $this->config('admin/jsonadm/url/action', 'get'); |
|
50 | 50 | |
51 | 51 | /** admin/jsonadm/url/config |
52 | 52 | * Associative list of configuration options used for generating the URL |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @see admin/jsonadm/url/controller |
69 | 69 | * @see admin/jsonadm/url/action |
70 | 70 | */ |
71 | -$config = $this->config( 'admin/jsonadm/url/config', array() ); |
|
71 | +$config = $this->config('admin/jsonadm/url/config', array()); |
|
72 | 72 | |
73 | 73 | |
74 | 74 | /** admin/jsonadm/partials/template-errors |
@@ -120,22 +120,22 @@ discard block |
||
120 | 120 | */ |
121 | 121 | |
122 | 122 | |
123 | -$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
124 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ); |
|
123 | +$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields'); |
|
124 | +$params = array_intersect_key($this->param(), array_flip($ref)); |
|
125 | 125 | |
126 | -if( !isset( $params['id'] ) ) { |
|
126 | +if (!isset($params['id'])) { |
|
127 | 127 | $params['id'] = ''; |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | -$total = $this->get( 'total', 0 ); |
|
132 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
133 | -$limit = max( $this->param( 'page/limit', 25 ), 1 ); |
|
131 | +$total = $this->get('total', 0); |
|
132 | +$offset = max($this->param('page/offset', 0), 0); |
|
133 | +$limit = max($this->param('page/limit', 25), 1); |
|
134 | 134 | |
135 | -$first = ( $offset > 0 ? 0 : null ); |
|
136 | -$prev = ( $offset - $limit >= 0 ? $offset - $limit : null ); |
|
137 | -$next = ( $offset + $limit < $total ? $offset + $limit : null ); |
|
138 | -$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null ); |
|
135 | +$first = ($offset > 0 ? 0 : null); |
|
136 | +$prev = ($offset - $limit >= 0 ? $offset - $limit : null); |
|
137 | +$next = ($offset + $limit < $total ? $offset + $limit : null); |
|
138 | +$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null); |
|
139 | 139 | |
140 | 140 | ?> |
141 | 141 | { |
@@ -144,27 +144,27 @@ discard block |
||
144 | 144 | |
145 | 145 | }, |
146 | 146 | "links": { |
147 | -<?php if( is_array( $this->get( 'data' ) ) ) : ?> |
|
148 | -<?php if( $first !== null ) : ?> |
|
149 | - "first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
147 | +<?php if (is_array($this->get('data'))) : ?> |
|
148 | +<?php if ($first !== null) : ?> |
|
149 | + "first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
150 | 150 | <?php endif; ?> |
151 | -<?php if( $prev !== null ) : ?> |
|
152 | - "prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
151 | +<?php if ($prev !== null) : ?> |
|
152 | + "prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
153 | 153 | <?php endif; ?> |
154 | -<?php if( $next !== null ) : ?> |
|
155 | - "next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
154 | +<?php if ($next !== null) : ?> |
|
155 | + "next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
156 | 156 | <?php endif; ?> |
157 | -<?php if( $last !== null ) : ?> |
|
158 | - "last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
157 | +<?php if ($last !== null) : ?> |
|
158 | + "last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
159 | 159 | <?php endif; ?> |
160 | 160 | <?php endif; ?> |
161 | - "self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>" |
|
161 | + "self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>" |
|
162 | 162 | }, |
163 | -<?php if( isset( $this->errors ) ) : ?> |
|
164 | - "errors": <?php echo $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
165 | -<?php elseif( isset( $this->data ) ) : ?> |
|
166 | - "data": <?php echo $this->partial( $this->config( $this->get( 'partial-data', 'admin/jsonadm/partials/template-data' ), 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ), 'childItems' => $this->get( 'childItems', array() ), 'listItems' => $this->get( 'listItems', array() ) ) ); ?>, |
|
167 | - "included": <?php echo $this->partial( $this->config( $this->get( 'partial-included', 'admin/jsonadm/partials/template-included' ), 'partials/included-standard.php' ), array( 'childItems' => $this->get( 'childItems', array() ), 'refItems' => $this->get( 'refItems', array() ) ) ); ?> |
|
163 | +<?php if (isset($this->errors)) : ?> |
|
164 | + "errors": <?php echo $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
165 | +<?php elseif (isset($this->data)) : ?> |
|
166 | + "data": <?php echo $this->partial($this->config($this->get('partial-data', 'admin/jsonadm/partials/template-data'), 'partials/data-standard.php'), array('data' => $this->get('data'), 'childItems' => $this->get('childItems', array()), 'listItems' => $this->get('listItems', array()))); ?>, |
|
167 | + "included": <?php echo $this->partial($this->config($this->get('partial-included', 'admin/jsonadm/partials/template-included'), 'partials/included-standard.php'), array('childItems' => $this->get('childItems', array()), 'refItems' => $this->get('refItems', array()))); ?> |
|
168 | 168 | <?php endif; ?> |
169 | 169 | |
170 | 170 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | { |
2 | 2 | "meta": { |
3 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
3 | + "total": <?php echo $this->get('total', 0); ?> |
|
4 | 4 | |
5 | 5 | } |
6 | -<?php if( isset( $this->errors ) ) : ?> |
|
7 | - ,"errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
6 | +<?php if (isset($this->errors)) : ?> |
|
7 | + ,"errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
8 | 8 | <?php endif; ?> |
9 | 9 | |
10 | 10 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>, |
|
4 | -<?php elseif( isset( $this->data ) ) : ?> |
|
5 | - "data": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>, |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>, |
|
4 | +<?php elseif (isset($this->data)) : ?> |
|
5 | + "data": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>, |
|
6 | 6 | <?php endif; ?> |
7 | 7 | |
8 | 8 | "meta": { |
9 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
9 | + "total": <?php echo $this->get('total', 0); ?> |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJadm::getContext(); |
17 | 17 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
18 | 18 | |
19 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
19 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
20 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJadm::getContext(); |
27 | 27 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
28 | 28 | |
29 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
30 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
29 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
30 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJadm::getContext(); |
37 | 37 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
38 | 38 | |
39 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '' ); |
|
40 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
39 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, ''); |
|
40 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | $context = \TestHelperJadm::getContext(); |
47 | 47 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
48 | 48 | |
49 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
50 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '%^' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
50 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '%^'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -56,68 +56,68 @@ discard block |
||
56 | 56 | $context = \TestHelperJadm::getContext(); |
57 | 57 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
58 | 58 | |
59 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
60 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '', '%^' ); |
|
59 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
60 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '', '%^'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function testClear() |
65 | 65 | { |
66 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
66 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
67 | 67 | |
68 | 68 | $context = \TestHelperJadm::getContext(); |
69 | 69 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
70 | 70 | |
71 | - $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
71 | + $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
72 | 72 | \Aimeos\Admin\JsonAdm\Factory::clear(); |
73 | - $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
73 | + $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
74 | 74 | |
75 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
75 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
76 | 76 | |
77 | - $this->assertNotSame( $client1, $client2 ); |
|
77 | + $this->assertNotSame($client1, $client2); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testClearSite() |
82 | 82 | { |
83 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
83 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
84 | 84 | |
85 | 85 | $context = \TestHelperJadm::getContext(); |
86 | 86 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
87 | 87 | |
88 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
89 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
90 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context ); |
|
88 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
89 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
90 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context); |
|
91 | 91 | |
92 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
93 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
92 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
93 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
94 | 94 | |
95 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
95 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
96 | 96 | |
97 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
98 | - $this->assertNotSame( $cntlB1, $cntlB2 ); |
|
97 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
98 | + $this->assertNotSame($cntlB1, $cntlB2); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | public function testClearSpecific() |
103 | 103 | { |
104 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
104 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
105 | 105 | |
106 | 106 | $context = \TestHelperJadm::getContext(); |
107 | 107 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
108 | 108 | |
109 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
110 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
109 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
110 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
111 | 111 | |
112 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context, 'order' ); |
|
112 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context, 'order'); |
|
113 | 113 | |
114 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
115 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
114 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
115 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
116 | 116 | |
117 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
117 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
118 | 118 | |
119 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
120 | - $this->assertSame( $cntlB1, $cntlB2 ); |
|
119 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
120 | + $this->assertSame($cntlB1, $cntlB2); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | } |
124 | 124 | \ No newline at end of file |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
34 | 34 | * @param string $path Path describing the client to clear, e.g. "product/lists/type" |
35 | 35 | */ |
36 | - static public function clear( $id = null, $path = null ) |
|
36 | + static public function clear($id = null, $path = null) |
|
37 | 37 | { |
38 | - if( $id !== null ) |
|
38 | + if ($id !== null) |
|
39 | 39 | { |
40 | - if( $path !== null ) { |
|
40 | + if ($path !== null) { |
|
41 | 41 | self::$clients[$id][$path] = null; |
42 | 42 | } else { |
43 | 43 | self::$clients[$id] = array(); |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
66 | 66 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
67 | 67 | */ |
68 | - static public function createClient( \Aimeos\MShop\Context\Item\Iface $context, |
|
69 | - array $templatePaths, $path, $name = null ) |
|
68 | + static public function createClient(\Aimeos\MShop\Context\Item\Iface $context, |
|
69 | + array $templatePaths, $path, $name = null) |
|
70 | 70 | { |
71 | - $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); |
|
71 | + $path = strtolower(trim($path, "/ \n\t\r\0\x0B")); |
|
72 | 72 | |
73 | - if( empty( $path ) ) { |
|
74 | - return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name ); |
|
73 | + if (empty($path)) { |
|
74 | + return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $id = (string) $context; |
78 | 78 | |
79 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) { |
|
80 | - self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name ); |
|
79 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) { |
|
80 | + self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return self::$clients[$id][$path]; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param boolean $value True to enable caching, false to disable it. |
91 | 91 | * @return boolean Previous cache setting |
92 | 92 | */ |
93 | - static public function setCache( $value ) |
|
93 | + static public function setCache($value) |
|
94 | 94 | { |
95 | 95 | $old = self::$cache; |
96 | 96 | self::$cache = (boolean) $value; |
@@ -109,37 +109,37 @@ discard block |
||
109 | 109 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
110 | 110 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
111 | 111 | */ |
112 | - protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context, |
|
113 | - array $templatePaths, $path, $name ) |
|
112 | + protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context, |
|
113 | + array $templatePaths, $path, $name) |
|
114 | 114 | { |
115 | - $parts = explode( '/', $path ); |
|
115 | + $parts = explode('/', $path); |
|
116 | 116 | |
117 | - foreach( $parts as $key => $part ) |
|
117 | + foreach ($parts as $key => $part) |
|
118 | 118 | { |
119 | - if( ctype_alnum( $part ) === false ) |
|
119 | + if (ctype_alnum($part) === false) |
|
120 | 120 | { |
121 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
122 | - throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 ); |
|
121 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
122 | + throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400); |
|
123 | 123 | } |
124 | 124 | |
125 | - $parts[$key] = ucwords( $part ); |
|
125 | + $parts[$key] = ucwords($part); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
129 | 129 | $view = $context->getView(); |
130 | - $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\Factory'; |
|
130 | + $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\Factory'; |
|
131 | 131 | |
132 | - if( class_exists( $factory ) === true ) |
|
132 | + if (class_exists($factory) === true) |
|
133 | 133 | { |
134 | - $args = array( $context, $view, $templatePaths, $path, $name ); |
|
134 | + $args = array($context, $view, $templatePaths, $path, $name); |
|
135 | 135 | |
136 | - if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
|
137 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
|
136 | + if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) { |
|
137 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid factory "%1$s"', $factory), 400); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
142 | - $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
|
142 | + $client = self::createClientRoot($context, $view, $templatePaths, $path, $name); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $client; |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
158 | 158 | * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created |
159 | 159 | */ |
160 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
161 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null ) |
|
160 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
161 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) |
|
162 | 162 | { |
163 | 163 | /** admin/jsonadm/name |
164 | 164 | * Class name of the used JSON API client implementation |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | * @since 2015.12 |
194 | 194 | * @category Developer |
195 | 195 | */ |
196 | - if( $name === null ) { |
|
197 | - $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
|
196 | + if ($name === null) { |
|
197 | + $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); |
|
198 | 198 | } |
199 | 199 | |
200 | - if( ctype_alnum( $name ) === false ) |
|
200 | + if (ctype_alnum($name) === false) |
|
201 | 201 | { |
202 | - $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
203 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
202 | + $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
203 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
207 | 207 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
208 | 208 | |
209 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
209 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
210 | 210 | |
211 | 211 | /** admin/jsonadm/decorators/excludes |
212 | 212 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -286,6 +286,6 @@ discard block |
||
286 | 286 | * @see admin/jsonadm/decorators/global |
287 | 287 | */ |
288 | 288 | |
289 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
289 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
290 | 290 | } |
291 | 291 | } |
@@ -19,77 +19,77 @@ discard block |
||
19 | 19 | $this->context = \TestHelperJadm::getContext(); |
20 | 20 | $config = $this->context->getConfig(); |
21 | 21 | |
22 | - $config->set( 'admin/jsonadm/common/decorators/default', array() ); |
|
23 | - $config->set( 'admin/jsonadm/decorators/global', array() ); |
|
24 | - $config->set( 'admin/jsonadm/decorators/local', array() ); |
|
22 | + $config->set('admin/jsonadm/common/decorators/default', array()); |
|
23 | + $config->set('admin/jsonadm/decorators/global', array()); |
|
24 | + $config->set('admin/jsonadm/decorators/local', array()); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testInjectClient() |
30 | 30 | { |
31 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
32 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
31 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
32 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
33 | 33 | |
34 | - $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
34 | + $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
35 | 35 | |
36 | - $this->assertSame( $cntl, $iCntl ); |
|
36 | + $this->assertSame($cntl, $iCntl); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testInjectClientReset() |
41 | 41 | { |
42 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
43 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
44 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', null ); |
|
42 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
43 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
44 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', null); |
|
45 | 45 | |
46 | - $new = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
46 | + $new = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
47 | 47 | |
48 | - $this->assertNotSame( $cntl, $new ); |
|
48 | + $this->assertNotSame($cntl, $new); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | public function testAddDecoratorsInvalidName() |
53 | 53 | { |
54 | - $decorators = array( '$' ); |
|
54 | + $decorators = array('$'); |
|
55 | 55 | $view = $this->context->getView(); |
56 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
56 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
57 | 57 | |
58 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
59 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute' ); |
|
58 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
59 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | 63 | public function testAddDecoratorsInvalidClass() |
64 | 64 | { |
65 | - $decorators = array( 'Test' ); |
|
65 | + $decorators = array('Test'); |
|
66 | 66 | $view = $this->context->getView(); |
67 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
67 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
68 | 68 | |
69 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
70 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute' ); |
|
69 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
70 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testAddDecoratorsInvalidInterface() |
75 | 75 | { |
76 | - $decorators = array( 'Test' ); |
|
76 | + $decorators = array('Test'); |
|
77 | 77 | $view = $this->context->getView(); |
78 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
78 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
79 | 79 | |
80 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
81 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, |
|
82 | - '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute' ); |
|
80 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
81 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, |
|
82 | + '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testAddClientDecoratorsExcludes() |
87 | 87 | { |
88 | - $this->context->getConfig()->set( 'admin/jsonadm/decorators/excludes', array( 'TestDecorator' ) ); |
|
89 | - $this->context->getConfig()->set( 'admin/jsonadm/common/decorators/default', array( 'TestDecorator' ) ); |
|
88 | + $this->context->getConfig()->set('admin/jsonadm/decorators/excludes', array('TestDecorator')); |
|
89 | + $this->context->getConfig()->set('admin/jsonadm/common/decorators/default', array('TestDecorator')); |
|
90 | 90 | |
91 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
92 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
91 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
92 | + \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @param string $classprefix |
102 | 102 | * @param string $path |
103 | 103 | */ |
104 | - public static function addDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
105 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
104 | + public static function addDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
105 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
106 | 106 | { |
107 | - self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
|
107 | + self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); |
|
108 | 108 | } |
109 | 109 | |
110 | - public static function addClientDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, |
|
111 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
110 | + public static function addClientDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, |
|
111 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
112 | 112 | { |
113 | - self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
113 | + self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 |