@@ -52,12 +52,10 @@ |
||
52 | 52 | foreach( $data as $item ) { |
53 | 53 | $response[] = $build( $item, $fields, $childItems ); |
54 | 54 | } |
55 | -} |
|
56 | -elseif( $data !== null ) |
|
55 | +} elseif( $data !== null ) |
|
57 | 56 | { |
58 | 57 | $response = $build( $data, $fields, $childItems ); |
59 | -} |
|
60 | -else |
|
58 | +} else |
|
61 | 59 | { |
62 | 60 | $response = null; |
63 | 61 | } |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems ) |
|
9 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems) |
|
10 | 10 | { |
11 | 11 | $id = $item->getId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
15 | 15 | |
16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
20 | 20 | |
21 | - if( isset( $fields[$type] ) ) { |
|
22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
21 | + if (isset($fields[$type])) { |
|
22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $result = array( |
@@ -27,33 +27,33 @@ discard block |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => array() |
33 | 33 | ); |
34 | 34 | |
35 | - foreach( $childItems as $childItem ) |
|
35 | + foreach ($childItems as $childItem) |
|
36 | 36 | { |
37 | - if( $childItem->getParentId() == $id ) |
|
37 | + if ($childItem->getParentId() == $id) |
|
38 | 38 | { |
39 | 39 | $type = $childItem->getResourceType(); |
40 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
40 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - foreach( $listItems as $listId => $listItem ) |
|
44 | + foreach ($listItems as $listId => $listItem) |
|
45 | 45 | { |
46 | - if( $listItem->getParentId() == $id ) |
|
46 | + if ($listItem->getParentId() == $id) |
|
47 | 47 | { |
48 | 48 | $type = $listItem->getDomain(); |
49 | - $params = array( 'resource' => $listItem->getResourceType(), 'id' => $listId ); |
|
49 | + $params = array('resource' => $listItem->getResourceType(), 'id' => $listId); |
|
50 | 50 | |
51 | - $result['relationships'][$type][] = array( 'data' => array( |
|
51 | + $result['relationships'][$type][] = array('data' => array( |
|
52 | 52 | 'id' => $listItem->getRefId(), 'type' => $type, |
53 | 53 | 'attributes' => $listItem->toArray(), 'links' => array( |
54 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
54 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
55 | 55 | ) |
56 | - ) ); |
|
56 | + )); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | }; |
62 | 62 | |
63 | 63 | |
64 | -$fields = $this->param( 'fields', array() ); |
|
64 | +$fields = $this->param('fields', array()); |
|
65 | 65 | |
66 | -foreach( (array) $fields as $resource => $list ) { |
|
67 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
66 | +foreach ((array) $fields as $resource => $list) { |
|
67 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | -$data = $this->get( 'data', array() ); |
|
72 | -$childItems = $this->get( 'childItems', array() ); |
|
73 | -$listItems = $this->get( 'listItems', array() ); |
|
71 | +$data = $this->get('data', array()); |
|
72 | +$childItems = $this->get('childItems', array()); |
|
73 | +$listItems = $this->get('listItems', array()); |
|
74 | 74 | |
75 | -if( is_array( $data ) ) |
|
75 | +if (is_array($data)) |
|
76 | 76 | { |
77 | 77 | $response = array(); |
78 | 78 | |
79 | - foreach( $data as $item ) { |
|
80 | - $response[] = $build( $this, $item, $fields, $childItems, $listItems ); |
|
79 | + foreach ($data as $item) { |
|
80 | + $response[] = $build($this, $item, $fields, $childItems, $listItems); |
|
81 | 81 | } |
82 | 82 | } |
83 | -elseif( $data !== null ) |
|
83 | +elseif ($data !== null) |
|
84 | 84 | { |
85 | - $response = $build( $this, $data, $fields, $childItems, $listItems ); |
|
85 | + $response = $build($this, $data, $fields, $childItems, $listItems); |
|
86 | 86 | } |
87 | 87 | else |
88 | 88 | { |
@@ -90,4 +90,4 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | -echo json_encode( $response, $options ); |
|
94 | 93 | \ No newline at end of file |
94 | +echo json_encode($response, $options); |
|
95 | 95 | \ No newline at end of file |
@@ -52,12 +52,10 @@ |
||
52 | 52 | foreach( $data as $item ) { |
53 | 53 | $response[] = $build( $item, $fields, $childItems ); |
54 | 54 | } |
55 | -} |
|
56 | -elseif( $data !== null ) |
|
55 | +} elseif( $data !== null ) |
|
57 | 56 | { |
58 | 57 | $response = $build( $data, $fields, $childItems ); |
59 | -} |
|
60 | -else |
|
58 | +} else |
|
61 | 59 | { |
62 | 60 | $response = null; |
63 | 61 | } |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Iface $item, array $fields, array $childItems ) |
|
8 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Order\Item\Iface $item, array $fields, array $childItems) |
|
9 | 9 | { |
10 | 10 | $id = $item->getId(); |
11 | 11 | $baseId = $item->getBaseId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
15 | 15 | |
16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
20 | 20 | |
21 | - if( isset( $fields[$type] ) ) { |
|
22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
21 | + if (isset($fields[$type])) { |
|
22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $result = array( |
@@ -27,25 +27,25 @@ discard block |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => array() |
33 | 33 | ); |
34 | 34 | |
35 | - foreach( $childItems as $childId => $childItem ) |
|
35 | + foreach ($childItems as $childId => $childItem) |
|
36 | 36 | { |
37 | - if( $childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id |
|
37 | + if ($childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id |
|
38 | 38 | || $childItem instanceof \Aimeos\MShop\Order\Item\Base\Iface && $childItem->getId() == $baseId |
39 | 39 | ) { |
40 | 40 | $type = $childItem->getResourceType(); |
41 | - $params = array( 'resource' => $childItem->getResourceType(), 'id' => $childId ); |
|
41 | + $params = array('resource' => $childItem->getResourceType(), 'id' => $childId); |
|
42 | 42 | |
43 | - $result['relationships'][$type][] = array( 'data' => array( |
|
43 | + $result['relationships'][$type][] = array('data' => array( |
|
44 | 44 | 'id' => $childId, 'type' => $type, |
45 | 45 | 'links' => array( |
46 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
46 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
47 | 47 | ) |
48 | - ) ); |
|
48 | + )); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
@@ -53,27 +53,27 @@ discard block |
||
53 | 53 | }; |
54 | 54 | |
55 | 55 | |
56 | -$fields = $this->param( 'fields', array() ); |
|
56 | +$fields = $this->param('fields', array()); |
|
57 | 57 | |
58 | -foreach( (array) $fields as $resource => $list ) { |
|
59 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
58 | +foreach ((array) $fields as $resource => $list) { |
|
59 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | -$data = $this->get( 'data', array() ); |
|
64 | -$childItems = $this->get( 'childItems', array() ); |
|
63 | +$data = $this->get('data', array()); |
|
64 | +$childItems = $this->get('childItems', array()); |
|
65 | 65 | |
66 | -if( is_array( $data ) ) |
|
66 | +if (is_array($data)) |
|
67 | 67 | { |
68 | 68 | $response = array(); |
69 | 69 | |
70 | - foreach( $data as $item ) { |
|
71 | - $response[] = $build( $this, $item, $fields, $childItems ); |
|
70 | + foreach ($data as $item) { |
|
71 | + $response[] = $build($this, $item, $fields, $childItems); |
|
72 | 72 | } |
73 | 73 | } |
74 | -elseif( $data !== null ) |
|
74 | +elseif ($data !== null) |
|
75 | 75 | { |
76 | - $response = $build( $this, $data, $fields, $childItems ); |
|
76 | + $response = $build($this, $data, $fields, $childItems); |
|
77 | 77 | } |
78 | 78 | else |
79 | 79 | { |
@@ -81,4 +81,4 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | -echo json_encode( $response, $options ); |
|
85 | 84 | \ No newline at end of file |
85 | +echo json_encode($response, $options); |
|
86 | 86 | \ No newline at end of file |
@@ -1,12 +1,12 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>, |
|
4 | -<?php elseif( isset( $this->data ) ) : ?> |
|
5 | - "data": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>, |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>, |
|
4 | +<?php elseif (isset($this->data)) : ?> |
|
5 | + "data": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>, |
|
6 | 6 | <?php endif; ?> |
7 | 7 | |
8 | 8 | "meta": { |
9 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
9 | + "total": <?php echo $this->get('total', 0); ?> |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJadm::getContext(); |
17 | 17 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
18 | 18 | |
19 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
19 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
20 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJadm::getContext(); |
27 | 27 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
28 | 28 | |
29 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
30 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
29 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
30 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJadm::getContext(); |
37 | 37 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
38 | 38 | |
39 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '' ); |
|
40 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
39 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, ''); |
|
40 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | $context = \TestHelperJadm::getContext(); |
47 | 47 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
48 | 48 | |
49 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
50 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '%^' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
50 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '%^'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -56,68 +56,68 @@ discard block |
||
56 | 56 | $context = \TestHelperJadm::getContext(); |
57 | 57 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
58 | 58 | |
59 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
60 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '', '%^' ); |
|
59 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
60 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '', '%^'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function testClear() |
65 | 65 | { |
66 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
66 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
67 | 67 | |
68 | 68 | $context = \TestHelperJadm::getContext(); |
69 | 69 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
70 | 70 | |
71 | - $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
71 | + $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
72 | 72 | \Aimeos\Admin\JsonAdm\Factory::clear(); |
73 | - $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
73 | + $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
74 | 74 | |
75 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
75 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
76 | 76 | |
77 | - $this->assertNotSame( $client1, $client2 ); |
|
77 | + $this->assertNotSame($client1, $client2); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testClearSite() |
82 | 82 | { |
83 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
83 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
84 | 84 | |
85 | 85 | $context = \TestHelperJadm::getContext(); |
86 | 86 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
87 | 87 | |
88 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
89 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
90 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context ); |
|
88 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
89 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
90 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context); |
|
91 | 91 | |
92 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
93 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
92 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
93 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
94 | 94 | |
95 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
95 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
96 | 96 | |
97 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
98 | - $this->assertNotSame( $cntlB1, $cntlB2 ); |
|
97 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
98 | + $this->assertNotSame($cntlB1, $cntlB2); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | public function testClearSpecific() |
103 | 103 | { |
104 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
104 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
105 | 105 | |
106 | 106 | $context = \TestHelperJadm::getContext(); |
107 | 107 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
108 | 108 | |
109 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
110 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
109 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
110 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
111 | 111 | |
112 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context, 'order' ); |
|
112 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context, 'order'); |
|
113 | 113 | |
114 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
115 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
114 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
115 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
116 | 116 | |
117 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
117 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
118 | 118 | |
119 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
120 | - $this->assertSame( $cntlB1, $cntlB2 ); |
|
119 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
120 | + $this->assertSame($cntlB1, $cntlB2); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | } |
124 | 124 | \ No newline at end of file |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
34 | 34 | * @param string $path Path describing the client to clear, e.g. "product/lists/type" |
35 | 35 | */ |
36 | - static public function clear( $id = null, $path = null ) |
|
36 | + static public function clear($id = null, $path = null) |
|
37 | 37 | { |
38 | - if( $id !== null ) |
|
38 | + if ($id !== null) |
|
39 | 39 | { |
40 | - if( $path !== null ) { |
|
40 | + if ($path !== null) { |
|
41 | 41 | self::$clients[$id][$path] = null; |
42 | 42 | } else { |
43 | 43 | self::$clients[$id] = array(); |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
66 | 66 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
67 | 67 | */ |
68 | - static public function createClient( \Aimeos\MShop\Context\Item\Iface $context, |
|
69 | - array $templatePaths, $path, $name = null ) |
|
68 | + static public function createClient(\Aimeos\MShop\Context\Item\Iface $context, |
|
69 | + array $templatePaths, $path, $name = null) |
|
70 | 70 | { |
71 | - $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); |
|
71 | + $path = strtolower(trim($path, "/ \n\t\r\0\x0B")); |
|
72 | 72 | |
73 | - if( empty( $path ) ) { |
|
74 | - return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name ); |
|
73 | + if (empty($path)) { |
|
74 | + return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $id = (string) $context; |
78 | 78 | |
79 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) { |
|
80 | - self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name ); |
|
79 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) { |
|
80 | + self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return self::$clients[$id][$path]; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param boolean $value True to enable caching, false to disable it. |
91 | 91 | * @return boolean Previous cache setting |
92 | 92 | */ |
93 | - static public function setCache( $value ) |
|
93 | + static public function setCache($value) |
|
94 | 94 | { |
95 | 95 | $old = self::$cache; |
96 | 96 | self::$cache = (boolean) $value; |
@@ -109,37 +109,37 @@ discard block |
||
109 | 109 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
110 | 110 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
111 | 111 | */ |
112 | - protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context, |
|
113 | - array $templatePaths, $path, $name ) |
|
112 | + protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context, |
|
113 | + array $templatePaths, $path, $name) |
|
114 | 114 | { |
115 | - $parts = explode( '/', $path ); |
|
115 | + $parts = explode('/', $path); |
|
116 | 116 | |
117 | - foreach( $parts as $key => $part ) |
|
117 | + foreach ($parts as $key => $part) |
|
118 | 118 | { |
119 | - if( ctype_alnum( $part ) === false ) |
|
119 | + if (ctype_alnum($part) === false) |
|
120 | 120 | { |
121 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
122 | - throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 ); |
|
121 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
122 | + throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400); |
|
123 | 123 | } |
124 | 124 | |
125 | - $parts[$key] = ucwords( $part ); |
|
125 | + $parts[$key] = ucwords($part); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
129 | 129 | $view = $context->getView(); |
130 | - $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\Factory'; |
|
130 | + $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\Factory'; |
|
131 | 131 | |
132 | - if( class_exists( $factory ) === true ) |
|
132 | + if (class_exists($factory) === true) |
|
133 | 133 | { |
134 | - $args = array( $context, $view, $templatePaths, $path, $name ); |
|
134 | + $args = array($context, $view, $templatePaths, $path, $name); |
|
135 | 135 | |
136 | - if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
|
137 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
|
136 | + if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) { |
|
137 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid factory "%1$s"', $factory), 400); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
142 | - $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
|
142 | + $client = self::createClientRoot($context, $view, $templatePaths, $path, $name); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $client; |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
158 | 158 | * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created |
159 | 159 | */ |
160 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
161 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null ) |
|
160 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
161 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) |
|
162 | 162 | { |
163 | 163 | /** admin/jsonadm/name |
164 | 164 | * Class name of the used JSON API client implementation |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | * @since 2015.12 |
194 | 194 | * @category Developer |
195 | 195 | */ |
196 | - if( $name === null ) { |
|
197 | - $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
|
196 | + if ($name === null) { |
|
197 | + $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); |
|
198 | 198 | } |
199 | 199 | |
200 | - if( ctype_alnum( $name ) === false ) |
|
200 | + if (ctype_alnum($name) === false) |
|
201 | 201 | { |
202 | - $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
203 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
202 | + $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
203 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
207 | 207 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
208 | 208 | |
209 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
209 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
210 | 210 | |
211 | 211 | /** admin/jsonadm/decorators/excludes |
212 | 212 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -286,6 +286,6 @@ discard block |
||
286 | 286 | * @see admin/jsonadm/decorators/global |
287 | 287 | */ |
288 | 288 | |
289 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
289 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
290 | 290 | } |
291 | 291 | } |
@@ -136,8 +136,7 @@ |
||
136 | 136 | if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
137 | 137 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
138 | 138 | } |
139 | - } |
|
140 | - else |
|
139 | + } else |
|
141 | 140 | { |
142 | 141 | $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
143 | 142 | } |
@@ -19,77 +19,77 @@ discard block |
||
19 | 19 | $this->context = \TestHelperJadm::getContext(); |
20 | 20 | $config = $this->context->getConfig(); |
21 | 21 | |
22 | - $config->set( 'admin/jsonadm/common/decorators/default', array() ); |
|
23 | - $config->set( 'admin/jsonadm/decorators/global', array() ); |
|
24 | - $config->set( 'admin/jsonadm/decorators/local', array() ); |
|
22 | + $config->set('admin/jsonadm/common/decorators/default', array()); |
|
23 | + $config->set('admin/jsonadm/decorators/global', array()); |
|
24 | + $config->set('admin/jsonadm/decorators/local', array()); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testInjectClient() |
30 | 30 | { |
31 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
32 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
31 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
32 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
33 | 33 | |
34 | - $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
34 | + $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
35 | 35 | |
36 | - $this->assertSame( $cntl, $iCntl ); |
|
36 | + $this->assertSame($cntl, $iCntl); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testInjectClientReset() |
41 | 41 | { |
42 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
43 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
44 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', null ); |
|
42 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
43 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
44 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', null); |
|
45 | 45 | |
46 | - $new = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
46 | + $new = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
47 | 47 | |
48 | - $this->assertNotSame( $cntl, $new ); |
|
48 | + $this->assertNotSame($cntl, $new); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | public function testAddDecoratorsInvalidName() |
53 | 53 | { |
54 | - $decorators = array( '$' ); |
|
54 | + $decorators = array('$'); |
|
55 | 55 | $view = $this->context->getView(); |
56 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
56 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
57 | 57 | |
58 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
59 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute' ); |
|
58 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
59 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | 63 | public function testAddDecoratorsInvalidClass() |
64 | 64 | { |
65 | - $decorators = array( 'Test' ); |
|
65 | + $decorators = array('Test'); |
|
66 | 66 | $view = $this->context->getView(); |
67 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
67 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
68 | 68 | |
69 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
70 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute' ); |
|
69 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
70 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testAddDecoratorsInvalidInterface() |
75 | 75 | { |
76 | - $decorators = array( 'Test' ); |
|
76 | + $decorators = array('Test'); |
|
77 | 77 | $view = $this->context->getView(); |
78 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
78 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
79 | 79 | |
80 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
81 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, |
|
82 | - '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute' ); |
|
80 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
81 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, |
|
82 | + '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testAddClientDecoratorsExcludes() |
87 | 87 | { |
88 | - $this->context->getConfig()->set( 'admin/jsonadm/decorators/excludes', array( 'TestDecorator' ) ); |
|
89 | - $this->context->getConfig()->set( 'admin/jsonadm/common/decorators/default', array( 'TestDecorator' ) ); |
|
88 | + $this->context->getConfig()->set('admin/jsonadm/decorators/excludes', array('TestDecorator')); |
|
89 | + $this->context->getConfig()->set('admin/jsonadm/common/decorators/default', array('TestDecorator')); |
|
90 | 90 | |
91 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
92 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
91 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
92 | + \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @param string $classprefix |
102 | 102 | * @param string $path |
103 | 103 | */ |
104 | - public static function addDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
105 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
104 | + public static function addDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
105 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
106 | 106 | { |
107 | - self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
|
107 | + self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); |
|
108 | 108 | } |
109 | 109 | |
110 | - public static function addClientDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, |
|
111 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
110 | + public static function addClientDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, |
|
111 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
112 | 112 | { |
113 | - self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
113 | + self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $templatePaths List of file system paths where the templates are stored |
34 | 34 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
37 | 37 | { |
38 | 38 | $this->view = $view; |
39 | 39 | $this->context = $context; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $include List of resource types that should be fetched |
50 | 50 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
51 | 51 | */ |
52 | - protected function getChildItems( array $items, array $include ) |
|
52 | + protected function getChildItems(array $items, array $include) |
|
53 | 53 | { |
54 | 54 | return array(); |
55 | 55 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
73 | 73 | * @return array List of domain names |
74 | 74 | */ |
75 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
75 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
76 | 76 | { |
77 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
77 | + if (($domains = $view->param('resource')) == '') |
|
78 | 78 | { |
79 | 79 | /** admin/jsonadm/domains |
80 | 80 | * A list of domain names whose clients are available for the JSON API |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
97 | 97 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
98 | 98 | ); |
99 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
99 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return (array) $domains; |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | * @param \stdClass $request Decoded request body |
110 | 110 | * @return array List of item IDs |
111 | 111 | */ |
112 | - protected function getIds( $request ) |
|
112 | + protected function getIds($request) |
|
113 | 113 | { |
114 | 114 | $ids = array(); |
115 | 115 | |
116 | - if( isset( $request->data ) ) |
|
116 | + if (isset($request->data)) |
|
117 | 117 | { |
118 | - foreach( (array) $request->data as $entry ) |
|
118 | + foreach ((array) $request->data as $entry) |
|
119 | 119 | { |
120 | - if( isset( $entry->id ) ) { |
|
120 | + if (isset($entry->id)) { |
|
121 | 121 | $ids[] = $entry->id; |
122 | 122 | } |
123 | 123 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param array $include List of resource types that should be fetched |
135 | 135 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
136 | 136 | */ |
137 | - protected function getListItems( array $items, array $include ) |
|
137 | + protected function getListItems(array $items, array $include) |
|
138 | 138 | { |
139 | 139 | return array(); |
140 | 140 | } |
@@ -157,23 +157,23 @@ discard block |
||
157 | 157 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
158 | 158 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
159 | 159 | */ |
160 | - protected function getRefItems( array $listItems ) |
|
160 | + protected function getRefItems(array $listItems) |
|
161 | 161 | { |
162 | 162 | $list = $map = array(); |
163 | 163 | $context = $this->getContext(); |
164 | 164 | |
165 | - foreach( $listItems as $listItem ) { |
|
165 | + foreach ($listItems as $listItem) { |
|
166 | 166 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
167 | 167 | } |
168 | 168 | |
169 | - foreach( $map as $domain => $ids ) |
|
169 | + foreach ($map as $domain => $ids) |
|
170 | 170 | { |
171 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
171 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
172 | 172 | |
173 | 173 | $search = $manager->createSearch(); |
174 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
174 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
175 | 175 | |
176 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
176 | + $list = array_merge($list, $manager->searchItems($search)); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $list; |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param array $params List of criteria data with condition, sorting and paging |
210 | 210 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
211 | 211 | */ |
212 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
212 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
213 | 213 | { |
214 | - $this->initCriteriaConditions( $criteria, $params ); |
|
215 | - $this->initCriteriaSortations( $criteria, $params ); |
|
216 | - $this->initCriteriaSlice( $criteria, $params ); |
|
214 | + $this->initCriteriaConditions($criteria, $params); |
|
215 | + $this->initCriteriaSortations($criteria, $params); |
|
216 | + $this->initCriteriaSlice($criteria, $params); |
|
217 | 217 | |
218 | 218 | return $criteria; |
219 | 219 | } |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
226 | 226 | * @param array $params List of criteria data with condition, sorting and paging |
227 | 227 | */ |
228 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
228 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
229 | 229 | { |
230 | - if( !isset( $params['filter'] ) ) { |
|
230 | + if (!isset($params['filter'])) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | 234 | $existing = $criteria->getConditions(); |
235 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
235 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
236 | 236 | |
237 | - $expr = array( $criteria->getConditions(), $existing ); |
|
238 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
237 | + $expr = array($criteria->getConditions(), $existing); |
|
238 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
246 | 246 | * @param array $params List of criteria data with condition, sorting and paging |
247 | 247 | */ |
248 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
248 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
249 | 249 | { |
250 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
251 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
250 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
251 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
252 | 252 | |
253 | - $criteria->setSlice( $start, $size ); |
|
253 | + $criteria->setSlice($start, $size); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -260,24 +260,24 @@ discard block |
||
260 | 260 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
261 | 261 | * @param array $params List of criteria data with condition, sorting and paging |
262 | 262 | */ |
263 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
263 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
264 | 264 | { |
265 | - if( !isset( $params['sort'] ) ) { |
|
265 | + if (!isset($params['sort'])) { |
|
266 | 266 | return; |
267 | 267 | } |
268 | 268 | |
269 | 269 | $sortation = array(); |
270 | 270 | |
271 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
271 | + foreach (explode(',', $params['sort']) as $sort) |
|
272 | 272 | { |
273 | - if( $sort[0] === '-' ) { |
|
274 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
273 | + if ($sort[0] === '-') { |
|
274 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
275 | 275 | } else { |
276 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
276 | + $sortation[] = $criteria->sort('+', $sort); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | - $criteria->setSortations( $sortation ); |
|
280 | + $criteria->setSortations($sortation); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | * @param \stdClass $request Object with request body data |
289 | 289 | * @return array List of items |
290 | 290 | */ |
291 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
291 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
292 | 292 | { |
293 | 293 | $data = array(); |
294 | 294 | |
295 | - if( isset( $request->data ) ) |
|
295 | + if (isset($request->data)) |
|
296 | 296 | { |
297 | - foreach( (array) $request->data as $entry ) { |
|
298 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
297 | + foreach ((array) $request->data as $entry) { |
|
298 | + $data[] = $this->saveEntry($manager, $entry); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -310,22 +310,22 @@ discard block |
||
310 | 310 | * @param \stdClass $entry Object including "id" and "attributes" elements |
311 | 311 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
312 | 312 | */ |
313 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
313 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
314 | 314 | { |
315 | - if( isset( $entry->id ) ) { |
|
316 | - $item = $manager->getItem( $entry->id ); |
|
315 | + if (isset($entry->id)) { |
|
316 | + $item = $manager->getItem($entry->id); |
|
317 | 317 | } else { |
318 | 318 | $item = $manager->createItem(); |
319 | 319 | } |
320 | 320 | |
321 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
322 | - $manager->saveItem( $item ); |
|
321 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
322 | + $manager->saveItem($item); |
|
323 | 323 | |
324 | - if( isset( $entry->relationships ) ) { |
|
325 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
324 | + if (isset($entry->relationships)) { |
|
325 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
326 | 326 | } |
327 | 327 | |
328 | - return $manager->getItem( $item->getId() ); |
|
328 | + return $manager->getItem($item->getId()); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -336,28 +336,28 @@ discard block |
||
336 | 336 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
337 | 337 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
338 | 338 | */ |
339 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
340 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
339 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
340 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
341 | 341 | { |
342 | 342 | $id = $item->getId(); |
343 | - $listManager = $manager->getSubManager( 'lists' ); |
|
343 | + $listManager = $manager->getSubManager('lists'); |
|
344 | 344 | |
345 | - foreach( (array) $relationships as $domain => $list ) |
|
345 | + foreach ((array) $relationships as $domain => $list) |
|
346 | 346 | { |
347 | - if( isset( $list->data ) ) |
|
347 | + if (isset($list->data)) |
|
348 | 348 | { |
349 | - foreach( (array) $list->data as $data ) |
|
349 | + foreach ((array) $list->data as $data) |
|
350 | 350 | { |
351 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
351 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
352 | 352 | |
353 | - if( isset( $data->id ) ) { |
|
354 | - $listItem->setRefId( $data->id ); |
|
353 | + if (isset($data->id)) { |
|
354 | + $listItem->setRefId($data->id); |
|
355 | 355 | } |
356 | 356 | |
357 | - $listItem->setParentId( $id ); |
|
358 | - $listItem->setDomain( $domain ); |
|
357 | + $listItem->setParentId($id); |
|
358 | + $listItem->setDomain($domain); |
|
359 | 359 | |
360 | - $listManager->saveItem( $listItem, false ); |
|
360 | + $listManager->saveItem($listItem, false); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | } |
@@ -374,20 +374,20 @@ discard block |
||
374 | 374 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
375 | 375 | */ |
376 | 376 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
377 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
377 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
378 | 378 | { |
379 | - if( isset( $data->attributes ) ) |
|
379 | + if (isset($data->attributes)) |
|
380 | 380 | { |
381 | 381 | $attr = (array) $data->attributes; |
382 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
382 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
383 | 383 | |
384 | - if( isset( $attr[$key.'.type'] ) ) |
|
384 | + if (isset($attr[$key . '.type'])) |
|
385 | 385 | { |
386 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], array(), $domain ); |
|
387 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
386 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], array(), $domain); |
|
387 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
388 | 388 | } |
389 | 389 | |
390 | - $item->fromArray( $attr ); |
|
390 | + $item->fromArray($attr); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | return $item; |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Catalog\Item\Iface $item, array $fields, array $listItems ) |
|
9 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Catalog\Item\Iface $item, array $fields, array $listItems) |
|
10 | 10 | { |
11 | 11 | $id = $item->getId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
15 | 15 | |
16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
20 | 20 | |
21 | - if( isset( $fields[$type] ) ) { |
|
22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
21 | + if (isset($fields[$type])) { |
|
22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $result = array( |
@@ -27,30 +27,30 @@ discard block |
||
27 | 27 | 'type' => $type, |
28 | 28 | 'attributes' => $attributes, |
29 | 29 | 'links' => array( |
30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
31 | 31 | ), |
32 | 32 | 'relationships' => array() |
33 | 33 | ); |
34 | 34 | |
35 | - foreach( $item->getChildren() as $childItem ) |
|
35 | + foreach ($item->getChildren() as $childItem) |
|
36 | 36 | { |
37 | 37 | $type = $childItem->getResourceType(); |
38 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
38 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
39 | 39 | } |
40 | 40 | |
41 | - foreach( $listItems as $listId => $listItem ) |
|
41 | + foreach ($listItems as $listId => $listItem) |
|
42 | 42 | { |
43 | - if( $listItem->getParentId() == $id ) |
|
43 | + if ($listItem->getParentId() == $id) |
|
44 | 44 | { |
45 | 45 | $type = $listItem->getDomain(); |
46 | - $params = array( 'resource' => $listItem->getResourceType(), 'id' => $listId ); |
|
46 | + $params = array('resource' => $listItem->getResourceType(), 'id' => $listId); |
|
47 | 47 | |
48 | - $result['relationships'][$type][] = array( 'data' => array( |
|
48 | + $result['relationships'][$type][] = array('data' => array( |
|
49 | 49 | 'id' => $listItem->getRefId(), 'type' => $type, |
50 | 50 | 'attributes' => $listItem->toArray(), 'links' => array( |
51 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
51 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
52 | 52 | ) |
53 | - ) ); |
|
53 | + )); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -58,27 +58,27 @@ discard block |
||
58 | 58 | }; |
59 | 59 | |
60 | 60 | |
61 | -$fields = $this->param( 'fields', array() ); |
|
61 | +$fields = $this->param('fields', array()); |
|
62 | 62 | |
63 | -foreach( (array) $fields as $resource => $list ) { |
|
64 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
63 | +foreach ((array) $fields as $resource => $list) { |
|
64 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | -$data = $this->get( 'data', array() ); |
|
69 | -$listItems = $this->get( 'listItems', array() ); |
|
68 | +$data = $this->get('data', array()); |
|
69 | +$listItems = $this->get('listItems', array()); |
|
70 | 70 | |
71 | -if( is_array( $data ) ) |
|
71 | +if (is_array($data)) |
|
72 | 72 | { |
73 | 73 | $response = array(); |
74 | 74 | |
75 | - foreach( $data as $item ) { |
|
76 | - $response[] = $build( $this, $item, $fields, $listItems ); |
|
75 | + foreach ($data as $item) { |
|
76 | + $response[] = $build($this, $item, $fields, $listItems); |
|
77 | 77 | } |
78 | 78 | } |
79 | -elseif( $data !== null ) |
|
79 | +elseif ($data !== null) |
|
80 | 80 | { |
81 | - $response = $build( $this, $data, $fields, $listItems ); |
|
81 | + $response = $build($this, $data, $fields, $listItems); |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
@@ -86,4 +86,4 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | -echo json_encode( $response, $options ); |
|
90 | 89 | \ No newline at end of file |
90 | +echo json_encode($response, $options); |
|
91 | 91 | \ No newline at end of file |
@@ -52,12 +52,10 @@ |
||
52 | 52 | foreach( $data as $item ) { |
53 | 53 | $response[] = $build( $item, $fields, $childItems ); |
54 | 54 | } |
55 | -} |
|
56 | -elseif( $data !== null ) |
|
55 | +} elseif( $data !== null ) |
|
57 | 56 | { |
58 | 57 | $response = $build( $data, $fields, $childItems ); |
59 | -} |
|
60 | -else |
|
58 | +} else |
|
61 | 59 | { |
62 | 60 | $response = null; |
63 | 61 | } |
@@ -171,8 +171,7 @@ discard block |
||
171 | 171 | $view->data = $manager->searchItems( $search, array(), $total ); |
172 | 172 | $view->listItems = $this->getListItems( $view->data, $include ); |
173 | 173 | $view->childItems = $this->getChildItems( $view->data, $include ); |
174 | - } |
|
175 | - else |
|
174 | + } else |
|
176 | 175 | { |
177 | 176 | $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
178 | 177 | $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
@@ -229,8 +228,7 @@ discard block |
||
229 | 228 | if( isset( $entry->parentid ) && $targetId !== null ) { |
230 | 229 | $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
231 | 230 | } |
232 | - } |
|
233 | - else |
|
231 | + } else |
|
234 | 232 | { |
235 | 233 | $item = $manager->createItem(); |
236 | 234 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
@@ -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 = array(); |
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->getChildren() ); |
|
149 | + foreach ($items as $item) { |
|
150 | + $list = array_merge($list, $item->getChildren()); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -162,35 +162,35 @@ 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 ) : array() ); |
|
177 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
176 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
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, array(), $total ); |
|
183 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
184 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
182 | + $view->data = $manager->searchItems($search, array(), $total); |
|
183 | + $view->listItems = $this->getListItems($view->data, $include); |
|
184 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
185 | 185 | } |
186 | 186 | else |
187 | 187 | { |
188 | - $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
189 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
190 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
188 | + $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
189 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
190 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
191 | 191 | } |
192 | 192 | |
193 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
193 | + $view->refItems = $this->getRefItems($view->listItems); |
|
194 | 194 | $view->total = $total; |
195 | 195 | |
196 | 196 | return $response; |
@@ -204,18 +204,18 @@ discard block |
||
204 | 204 | * @param array $include List of resource types that should be fetched |
205 | 205 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
206 | 206 | */ |
207 | - protected function getListItems( array $items, array $include ) |
|
207 | + protected function getListItems(array $items, array $include) |
|
208 | 208 | { |
209 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
209 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
210 | 210 | |
211 | 211 | $search = $manager->createSearch(); |
212 | 212 | $expr = array( |
213 | - $search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ), |
|
214 | - $search->compare( '==', 'catalog.lists.domain', $include ), |
|
213 | + $search->compare('==', 'catalog.lists.parentid', array_keys($items)), |
|
214 | + $search->compare('==', 'catalog.lists.domain', $include), |
|
215 | 215 | ); |
216 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
216 | + $search->setConditions($search->combine('&&', $expr)); |
|
217 | 217 | |
218 | - return $manager->searchItems( $search ); |
|
218 | + return $manager->searchItems($search); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -226,32 +226,32 @@ discard block |
||
226 | 226 | * @param \stdClass $entry Object including "id" and "attributes" elements |
227 | 227 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
228 | 228 | */ |
229 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
229 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
230 | 230 | { |
231 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
232 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
231 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
232 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
233 | 233 | |
234 | - if( isset( $entry->id ) ) |
|
234 | + if (isset($entry->id)) |
|
235 | 235 | { |
236 | - $item = $manager->getItem( $entry->id ); |
|
237 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
238 | - $manager->saveItem( $item ); |
|
236 | + $item = $manager->getItem($entry->id); |
|
237 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
238 | + $manager->saveItem($item); |
|
239 | 239 | |
240 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
241 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
240 | + if (isset($entry->parentid) && $targetId !== null) { |
|
241 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | else |
245 | 245 | { |
246 | 246 | $item = $manager->createItem(); |
247 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
248 | - $manager->insertItem( $item, $targetId, $refId ); |
|
247 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
248 | + $manager->insertItem($item, $targetId, $refId); |
|
249 | 249 | } |
250 | 250 | |
251 | - if( isset( $entry->relationships ) ) { |
|
252 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
251 | + if (isset($entry->relationships)) { |
|
252 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
253 | 253 | } |
254 | 254 | |
255 | - return $manager->getItem( $item->getId() ); |
|
255 | + return $manager->getItem($item->getId()); |
|
256 | 256 | } |
257 | 257 | } |