@@ -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 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard( $this->context, $this->view, $templatePaths, 'catalog' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard($this->context, $this->view, $templatePaths, 'catalog'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,137 +30,137 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'catalog.code' => 'cafe' ) |
|
33 | + '==' => array('catalog.code' => 'cafe') |
|
34 | 34 | ), |
35 | 35 | 'include' => 'text' |
36 | 36 | ); |
37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
38 | - $this->view->addHelper( 'param', $helper ); |
|
37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
38 | + $this->view->addHelper('param', $helper); |
|
39 | 39 | |
40 | 40 | $header = array(); |
41 | 41 | $status = 500; |
42 | 42 | |
43 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
43 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
44 | 44 | |
45 | - $this->assertEquals( 200, $status ); |
|
46 | - $this->assertEquals( 1, count( $header ) ); |
|
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'catalog', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) ); |
|
51 | - $this->assertEquals( 6, count( $result['included'] ) ); |
|
52 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
45 | + $this->assertEquals(200, $status); |
|
46 | + $this->assertEquals(1, count($header)); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('catalog', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(6, count($result['data'][0]['relationships']['text'])); |
|
51 | + $this->assertEquals(6, count($result['included'])); |
|
52 | + $this->assertArrayNotHasKey('errors', $result); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | 56 | public function testGetTree() |
57 | 57 | { |
58 | 58 | $params = array( |
59 | - 'id' => $this->getCatalogItem( 'group' )->getId(), |
|
59 | + 'id' => $this->getCatalogItem('group')->getId(), |
|
60 | 60 | 'filter' => array( |
61 | - '==' => array( 'catalog.status' => 1 ) |
|
61 | + '==' => array('catalog.status' => 1) |
|
62 | 62 | ), |
63 | 63 | 'include' => 'catalog,text' |
64 | 64 | ); |
65 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
66 | - $this->view->addHelper( 'param', $helper ); |
|
65 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
66 | + $this->view->addHelper('param', $helper); |
|
67 | 67 | |
68 | 68 | $header = array(); |
69 | 69 | $status = 500; |
70 | 70 | |
71 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
71 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
72 | 72 | |
73 | - $this->assertEquals( 200, $status ); |
|
74 | - $this->assertEquals( 1, count( $header ) ); |
|
75 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
76 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
77 | - $this->assertEquals( 2, count( $result['data']['relationships']['catalog'] ) ); |
|
78 | - $this->assertEquals( 2, count( $result['included'] ) ); |
|
79 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
73 | + $this->assertEquals(200, $status); |
|
74 | + $this->assertEquals(1, count($header)); |
|
75 | + $this->assertEquals(1, $result['meta']['total']); |
|
76 | + $this->assertEquals('catalog', $result['data']['type']); |
|
77 | + $this->assertEquals(2, count($result['data']['relationships']['catalog'])); |
|
78 | + $this->assertEquals(2, count($result['included'])); |
|
79 | + $this->assertArrayNotHasKey('errors', $result); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | 83 | public function testPatch() |
84 | 84 | { |
85 | - $stub = $this->getCatalogMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
85 | + $stub = $this->getCatalogMock(array('getItem', 'moveItem', 'saveItem')); |
|
86 | 86 | |
87 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
88 | - $stub->expects( $this->once() )->method( 'saveItem' ); |
|
89 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
90 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
87 | + $stub->expects($this->once())->method('moveItem'); |
|
88 | + $stub->expects($this->once())->method('saveItem'); |
|
89 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
90 | + ->will($this->returnValue($stub->createItem())); |
|
91 | 91 | |
92 | 92 | |
93 | - $params = array( 'id' => '-1' ); |
|
94 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
95 | - $this->view->addHelper( 'param', $helper ); |
|
93 | + $params = array('id' => '-1'); |
|
94 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
95 | + $this->view->addHelper('param', $helper); |
|
96 | 96 | |
97 | 97 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "catalog", "attributes": {"catalog.label": "test"}}}'; |
98 | 98 | $header = array(); |
99 | 99 | $status = 500; |
100 | 100 | |
101 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
101 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
102 | 102 | |
103 | - $this->assertEquals( 200, $status ); |
|
104 | - $this->assertEquals( 1, count( $header ) ); |
|
105 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
106 | - $this->assertArrayHasKey( 'data', $result ); |
|
107 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
108 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
109 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
103 | + $this->assertEquals(200, $status); |
|
104 | + $this->assertEquals(1, count($header)); |
|
105 | + $this->assertEquals(1, $result['meta']['total']); |
|
106 | + $this->assertArrayHasKey('data', $result); |
|
107 | + $this->assertEquals('catalog', $result['data']['type']); |
|
108 | + $this->assertArrayNotHasKey('included', $result); |
|
109 | + $this->assertArrayNotHasKey('errors', $result); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | 113 | public function testPost() |
114 | 114 | { |
115 | - $stub = $this->getCatalogMock( array( 'getItem', 'insertItem' ) ); |
|
115 | + $stub = $this->getCatalogMock(array('getItem', 'insertItem')); |
|
116 | 116 | |
117 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
118 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
119 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
117 | + $stub->expects($this->any())->method('getItem') |
|
118 | + ->will($this->returnValue($stub->createItem())); |
|
119 | + $stub->expects($this->once())->method('insertItem'); |
|
120 | 120 | |
121 | 121 | |
122 | 122 | $body = '{"data": {"type": "catalog", "attributes": {"catalog.code": "test", "catalog.label": "Test catalog"}}}'; |
123 | 123 | $header = array(); |
124 | 124 | $status = 500; |
125 | 125 | |
126 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
126 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
127 | 127 | |
128 | - $this->assertEquals( 201, $status ); |
|
129 | - $this->assertEquals( 1, count( $header ) ); |
|
130 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
131 | - $this->assertArrayHasKey( 'data', $result ); |
|
132 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
133 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
134 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
128 | + $this->assertEquals(201, $status); |
|
129 | + $this->assertEquals(1, count($header)); |
|
130 | + $this->assertEquals(1, $result['meta']['total']); |
|
131 | + $this->assertArrayHasKey('data', $result); |
|
132 | + $this->assertEquals('catalog', $result['data']['type']); |
|
133 | + $this->assertArrayNotHasKey('included', $result); |
|
134 | + $this->assertArrayNotHasKey('errors', $result); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
138 | - protected function getCatalogItem( $code ) |
|
138 | + protected function getCatalogItem($code) |
|
139 | 139 | { |
140 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
140 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
141 | 141 | $search = $manager->createSearch(); |
142 | - $search->setConditions( $search->compare( '==', 'catalog.code', $code ) ); |
|
143 | - $items = $manager->searchItems( $search ); |
|
142 | + $search->setConditions($search->compare('==', 'catalog.code', $code)); |
|
143 | + $items = $manager->searchItems($search); |
|
144 | 144 | |
145 | - if( ( $item = reset( $items ) ) === false ) { |
|
146 | - throw new \Exception( sprintf( 'No catalog item with code "%1$s" found', $code ) ); |
|
145 | + if (($item = reset($items)) === false) { |
|
146 | + throw new \Exception(sprintf('No catalog item with code "%1$s" found', $code)); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $item; |
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | - protected function getCatalogMock( array $methods ) |
|
153 | + protected function getCatalogMock(array $methods) |
|
154 | 154 | { |
155 | 155 | $name = 'ClientJsonAdmStandard'; |
156 | - $this->context->getConfig()->set( 'mshop/catalog/manager/name', $name ); |
|
156 | + $this->context->getConfig()->set('mshop/catalog/manager/name', $name); |
|
157 | 157 | |
158 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Catalog\\Manager\\Standard' ) |
|
159 | - ->setConstructorArgs( array( $this->context ) ) |
|
160 | - ->setMethods( $methods ) |
|
158 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Catalog\\Manager\\Standard') |
|
159 | + ->setConstructorArgs(array($this->context)) |
|
160 | + ->setMethods($methods) |
|
161 | 161 | ->getMock(); |
162 | 162 | |
163 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub ); |
|
163 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub); |
|
164 | 164 | |
165 | 165 | return $stub; |
166 | 166 | } |
@@ -29,39 +29,39 @@ discard block |
||
29 | 29 | * @param integer &$status Variable which contains the HTTP status afterwards |
30 | 30 | * @return string Content for response body |
31 | 31 | */ |
32 | - public function delete( $body, array &$header, &$status ) |
|
32 | + public function delete($body, array &$header, &$status) |
|
33 | 33 | { |
34 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
34 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
35 | 35 | $view = $this->getView(); |
36 | 36 | |
37 | 37 | try |
38 | 38 | { |
39 | - $view = $this->deleteItems( $view, $body ); |
|
39 | + $view = $this->deleteItems($view, $body); |
|
40 | 40 | $status = 200; |
41 | 41 | } |
42 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
42 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
43 | 43 | { |
44 | 44 | $status = $e->getCode(); |
45 | - $view->errors = array( array( |
|
46 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
45 | + $view->errors = array(array( |
|
46 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
47 | 47 | 'detail' => $e->getTraceAsString(), |
48 | - ) ); |
|
48 | + )); |
|
49 | 49 | } |
50 | - catch( \Aimeos\MShop\Exception $e ) |
|
50 | + catch (\Aimeos\MShop\Exception $e) |
|
51 | 51 | { |
52 | 52 | $status = 404; |
53 | - $view->errors = array( array( |
|
54 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
53 | + $view->errors = array(array( |
|
54 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
55 | 55 | 'detail' => $e->getTraceAsString(), |
56 | - ) ); |
|
56 | + )); |
|
57 | 57 | } |
58 | - catch( \Exception $e ) |
|
58 | + catch (\Exception $e) |
|
59 | 59 | { |
60 | 60 | $status = 500; |
61 | - $view->errors = array( array( |
|
61 | + $view->errors = array(array( |
|
62 | 62 | 'title' => $e->getMessage(), |
63 | 63 | 'detail' => $e->getTraceAsString(), |
64 | - ) ); |
|
64 | + )); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** admin/jsonadm/standard/template-delete |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
92 | 92 | $default = 'delete-default.php'; |
93 | 93 | |
94 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
94 | + return $view->render($view->config($tplconf, $default)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -103,31 +103,31 @@ discard block |
||
103 | 103 | * @param integer &$status Variable which contains the HTTP status afterwards |
104 | 104 | * @return string Content for response body |
105 | 105 | */ |
106 | - public function get( $body, array &$header, &$status ) |
|
106 | + public function get($body, array &$header, &$status) |
|
107 | 107 | { |
108 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
108 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
109 | 109 | $view = $this->getView(); |
110 | 110 | |
111 | 111 | try |
112 | 112 | { |
113 | - $view = $this->getItems( $view ); |
|
113 | + $view = $this->getItems($view); |
|
114 | 114 | $status = 200; |
115 | 115 | } |
116 | - catch( \Aimeos\MShop\Exception $e ) |
|
116 | + catch (\Aimeos\MShop\Exception $e) |
|
117 | 117 | { |
118 | 118 | $status = 404; |
119 | - $view->errors = array( array( |
|
120 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
119 | + $view->errors = array(array( |
|
120 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
121 | 121 | 'detail' => $e->getTraceAsString(), |
122 | - ) ); |
|
122 | + )); |
|
123 | 123 | } |
124 | - catch( \Exception $e ) |
|
124 | + catch (\Exception $e) |
|
125 | 125 | { |
126 | 126 | $status = 500; |
127 | - $view->errors = array( array( |
|
127 | + $view->errors = array(array( |
|
128 | 128 | 'title' => $e->getMessage(), |
129 | 129 | 'detail' => $e->getTraceAsString(), |
130 | - ) ); |
|
130 | + )); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** admin/jsonadm/standard/template-get |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $tplconf = 'admin/jsonadm/standard/template-get'; |
158 | 158 | $default = 'get-default.php'; |
159 | 159 | |
160 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
160 | + return $view->render($view->config($tplconf, $default)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -169,39 +169,39 @@ discard block |
||
169 | 169 | * @param integer &$status Variable which contains the HTTP status afterwards |
170 | 170 | * @return string Content for response body |
171 | 171 | */ |
172 | - public function patch( $body, array &$header, &$status ) |
|
172 | + public function patch($body, array &$header, &$status) |
|
173 | 173 | { |
174 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
174 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
175 | 175 | $view = $this->getView(); |
176 | 176 | |
177 | 177 | try |
178 | 178 | { |
179 | - $view = $this->patchItems( $view, $body, $header ); |
|
179 | + $view = $this->patchItems($view, $body, $header); |
|
180 | 180 | $status = 200; |
181 | 181 | } |
182 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
182 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
183 | 183 | { |
184 | 184 | $status = $e->getCode(); |
185 | - $view->errors = array( array( |
|
186 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
185 | + $view->errors = array(array( |
|
186 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
187 | 187 | 'detail' => $e->getTraceAsString(), |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | } |
190 | - catch( \Aimeos\MShop\Exception $e ) |
|
190 | + catch (\Aimeos\MShop\Exception $e) |
|
191 | 191 | { |
192 | 192 | $status = 404; |
193 | - $view->errors = array( array( |
|
194 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
193 | + $view->errors = array(array( |
|
194 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
195 | 195 | 'detail' => $e->getTraceAsString(), |
196 | - ) ); |
|
196 | + )); |
|
197 | 197 | } |
198 | - catch( \Exception $e ) |
|
198 | + catch (\Exception $e) |
|
199 | 199 | { |
200 | 200 | $status = 500; |
201 | - $view->errors = array( array( |
|
201 | + $view->errors = array(array( |
|
202 | 202 | 'title' => $e->getMessage(), |
203 | 203 | 'detail' => $e->getTraceAsString(), |
204 | - ) ); |
|
204 | + )); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** admin/jsonadm/standard/template-patch |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
232 | 232 | $default = 'patch-default.php'; |
233 | 233 | |
234 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
234 | + return $view->render($view->config($tplconf, $default)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -243,39 +243,39 @@ discard block |
||
243 | 243 | * @param integer &$status Variable which contains the HTTP status afterwards |
244 | 244 | * @return string Content for response body |
245 | 245 | */ |
246 | - public function post( $body, array &$header, &$status ) |
|
246 | + public function post($body, array &$header, &$status) |
|
247 | 247 | { |
248 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
248 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
249 | 249 | $view = $this->getView(); |
250 | 250 | |
251 | 251 | try |
252 | 252 | { |
253 | - $view = $this->postItems( $view, $body, $header ); |
|
253 | + $view = $this->postItems($view, $body, $header); |
|
254 | 254 | $status = 201; |
255 | 255 | } |
256 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
256 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
257 | 257 | { |
258 | 258 | $status = $e->getCode(); |
259 | - $view->errors = array( array( |
|
260 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
259 | + $view->errors = array(array( |
|
260 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
261 | 261 | 'detail' => $e->getTraceAsString(), |
262 | - ) ); |
|
262 | + )); |
|
263 | 263 | } |
264 | - catch( \Aimeos\MShop\Exception $e ) |
|
264 | + catch (\Aimeos\MShop\Exception $e) |
|
265 | 265 | { |
266 | 266 | $status = 404; |
267 | - $view->errors = array( array( |
|
268 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
267 | + $view->errors = array(array( |
|
268 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
269 | 269 | 'detail' => $e->getTraceAsString(), |
270 | - ) ); |
|
270 | + )); |
|
271 | 271 | } |
272 | - catch( \Exception $e ) |
|
272 | + catch (\Exception $e) |
|
273 | 273 | { |
274 | 274 | $status = 500; |
275 | - $view->errors = array( array( |
|
275 | + $view->errors = array(array( |
|
276 | 276 | 'title' => $e->getMessage(), |
277 | 277 | 'detail' => $e->getTraceAsString(), |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** admin/jsonadm/standard/template-post |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $tplconf = 'admin/jsonadm/standard/template-post'; |
306 | 306 | $default = 'post-default.php'; |
307 | 307 | |
308 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
308 | + return $view->render($view->config($tplconf, $default)); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -317,15 +317,15 @@ discard block |
||
317 | 317 | * @param integer &$status Variable which contains the HTTP status afterwards |
318 | 318 | * @return string Content for response body |
319 | 319 | */ |
320 | - public function put( $body, array &$header, &$status ) |
|
320 | + public function put($body, array &$header, &$status) |
|
321 | 321 | { |
322 | 322 | $status = 501; |
323 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
323 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
324 | 324 | $view = $this->getView(); |
325 | 325 | |
326 | - $view->errors = array( array( |
|
327 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
328 | - ) ); |
|
326 | + $view->errors = array(array( |
|
327 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
328 | + )); |
|
329 | 329 | |
330 | 330 | /** admin/jsonadm/standard/template-put |
331 | 331 | * Relative path to the JSON API template for PUT requests |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $tplconf = 'admin/jsonadm/standard/template-put'; |
355 | 355 | $default = 'put-default.php'; |
356 | 356 | |
357 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
357 | + return $view->render($view->config($tplconf, $default)); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @param integer &$status Variable which contains the HTTP status afterwards |
367 | 367 | * @return string Content for response body |
368 | 368 | */ |
369 | - public function options( $body, array &$header, &$status ) |
|
369 | + public function options($body, array &$header, &$status) |
|
370 | 370 | { |
371 | 371 | $context = $this->getContext(); |
372 | 372 | $view = $this->getView(); |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | { |
376 | 376 | $resources = $attributes = array(); |
377 | 377 | |
378 | - foreach( $this->getDomains( $view ) as $domain ) |
|
378 | + foreach ($this->getDomains($view) as $domain) |
|
379 | 379 | { |
380 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
381 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
382 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
380 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
381 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
382 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | $view->resources = $resources; |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | ); |
392 | 392 | $status = 200; |
393 | 393 | } |
394 | - catch( \Aimeos\MShop\Exception $e ) |
|
394 | + catch (\Aimeos\MShop\Exception $e) |
|
395 | 395 | { |
396 | 396 | $status = 404; |
397 | - $view->errors = array( array( |
|
398 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
397 | + $view->errors = array(array( |
|
398 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
399 | 399 | 'detail' => $e->getTraceAsString(), |
400 | - ) ); |
|
400 | + )); |
|
401 | 401 | } |
402 | - catch( \Exception $e ) |
|
402 | + catch (\Exception $e) |
|
403 | 403 | { |
404 | 404 | $status = 500; |
405 | - $view->errors = array( array( |
|
405 | + $view->errors = array(array( |
|
406 | 406 | 'title' => $e->getMessage(), |
407 | 407 | 'detail' => $e->getTraceAsString(), |
408 | - ) ); |
|
408 | + )); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** admin/jsonadm/standard/template-options |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $tplconf = 'admin/jsonadm/standard/template-options'; |
436 | 436 | $default = 'options-default.php'; |
437 | 437 | |
438 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
438 | + return $view->render($view->config($tplconf, $default)); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -447,23 +447,23 @@ discard block |
||
447 | 447 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
448 | 448 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
449 | 449 | */ |
450 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
450 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
451 | 451 | { |
452 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
452 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
453 | 453 | |
454 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
454 | + if (($id = $view->param('id')) == null) |
|
455 | 455 | { |
456 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
457 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
456 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
457 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
458 | 458 | } |
459 | 459 | |
460 | - $ids = $this->getIds( $request ); |
|
461 | - $manager->deleteItems( $ids ); |
|
462 | - $view->total = count( $ids ); |
|
460 | + $ids = $this->getIds($request); |
|
461 | + $manager->deleteItems($ids); |
|
462 | + $view->total = count($ids); |
|
463 | 463 | } |
464 | 464 | else |
465 | 465 | { |
466 | - $manager->deleteItem( $id ); |
|
466 | + $manager->deleteItem($id); |
|
467 | 467 | $view->total = 1; |
468 | 468 | } |
469 | 469 | |
@@ -477,27 +477,27 @@ discard block |
||
477 | 477 | * @param \Aimeos\MW\View\Iface $view View instance |
478 | 478 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
479 | 479 | */ |
480 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
480 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
481 | 481 | { |
482 | 482 | $total = 1; |
483 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
484 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
483 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
484 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
485 | 485 | |
486 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
486 | + if (($id = $view->param('id')) == null) |
|
487 | 487 | { |
488 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
489 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
490 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
491 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
488 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
489 | + $view->data = $manager->searchItems($search, array(), $total); |
|
490 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
491 | + $view->listItems = $this->getListItems($view->data, $include); |
|
492 | 492 | } |
493 | 493 | else |
494 | 494 | { |
495 | - $view->data = $manager->getItem( $id, array() ); |
|
496 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
497 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
495 | + $view->data = $manager->getItem($id, array()); |
|
496 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
497 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
498 | 498 | } |
499 | 499 | |
500 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
500 | + $view->refItems = $this->getRefItems($view->listItems); |
|
501 | 501 | $view->total = $total; |
502 | 502 | |
503 | 503 | return $view; |
@@ -511,9 +511,9 @@ discard block |
||
511 | 511 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
512 | 512 | * @deprecated 2016.06 Use getItems() instead |
513 | 513 | */ |
514 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
514 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
515 | 515 | { |
516 | - return $this->getItems( $view ); |
|
516 | + return $this->getItems($view); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -525,33 +525,33 @@ discard block |
||
525 | 525 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
526 | 526 | * @return \Aimeos\MW\View\Iface Updated view instance |
527 | 527 | */ |
528 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
528 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
529 | 529 | { |
530 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
531 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
530 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
531 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
532 | 532 | } |
533 | 533 | |
534 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
534 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
535 | 535 | |
536 | - if( is_array( $request->data ) ) |
|
536 | + if (is_array($request->data)) |
|
537 | 537 | { |
538 | - $data = $this->saveData( $manager, $request ); |
|
538 | + $data = $this->saveData($manager, $request); |
|
539 | 539 | |
540 | 540 | $view->data = $data; |
541 | - $view->total = count( $data ); |
|
541 | + $view->total = count($data); |
|
542 | 542 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
543 | 543 | } |
544 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
544 | + elseif (($id = $view->param('id')) != null) |
|
545 | 545 | { |
546 | 546 | $request->data->id = $id; |
547 | - $data = $this->saveEntry( $manager, $request->data ); |
|
547 | + $data = $this->saveEntry($manager, $request->data); |
|
548 | 548 | |
549 | 549 | $view->data = $data; |
550 | 550 | $view->total = 1; |
551 | 551 | } |
552 | 552 | else |
553 | 553 | { |
554 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
554 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | return $view; |
@@ -566,31 +566,31 @@ discard block |
||
566 | 566 | * @param array &$header Associative list of HTTP headers as value/result parameter |
567 | 567 | * @return \Aimeos\MW\View\Iface Updated view instance |
568 | 568 | */ |
569 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
569 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
570 | 570 | { |
571 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
572 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
571 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
572 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
573 | 573 | } |
574 | 574 | |
575 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
576 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
575 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
576 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
580 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
580 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
581 | 581 | |
582 | - if( is_array( $request->data ) ) |
|
582 | + if (is_array($request->data)) |
|
583 | 583 | { |
584 | - $data = $this->saveData( $manager, $request ); |
|
584 | + $data = $this->saveData($manager, $request); |
|
585 | 585 | |
586 | 586 | $view->data = $data; |
587 | - $view->total = count( $data ); |
|
587 | + $view->total = count($data); |
|
588 | 588 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
589 | 589 | } |
590 | 590 | else |
591 | 591 | { |
592 | 592 | $request->data->id = null; |
593 | - $data = $this->saveEntry( $manager, $request->data ); |
|
593 | + $data = $this->saveEntry($manager, $request->data); |
|
594 | 594 | |
595 | 595 | $view->data = $data; |
596 | 596 | $view->total = 1; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
109 | 109 | * @return string Content for response body |
110 | 110 | */ |
111 | - public function get( $body, array &$header, &$status ) |
|
111 | + public function get($body, array &$header, &$status) |
|
112 | 112 | { |
113 | 113 | /** admin/jsonadm/partials/catalog/template-data |
114 | 114 | * Relative path to the data partial template file for the catalog client |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @since 2016.07 |
126 | 126 | * @category Developer |
127 | 127 | */ |
128 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/catalog/template-data' ) ); |
|
128 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/catalog/template-data')); |
|
129 | 129 | |
130 | - return parent::get( $body, $header, $status ); |
|
130 | + return parent::get($body, $header, $status); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | * @param array $include List of resource types that should be fetched |
139 | 139 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
140 | 140 | */ |
141 | - protected function getChildItems( array $items, array $include ) |
|
141 | + protected function getChildItems(array $items, array $include) |
|
142 | 142 | { |
143 | 143 | $list = array(); |
144 | 144 | |
145 | - if( in_array( 'catalog', $include ) ) |
|
145 | + if (in_array('catalog', $include)) |
|
146 | 146 | { |
147 | - foreach( $items as $item ) { |
|
148 | - $list = array_merge( $list, $item->getChildren() ); |
|
147 | + foreach ($items as $item) { |
|
148 | + $list = array_merge($list, $item->getChildren()); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -159,27 +159,27 @@ discard block |
||
159 | 159 | * @param \Aimeos\MW\View\Iface $view View instance |
160 | 160 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
161 | 161 | */ |
162 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
162 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
163 | 163 | { |
164 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
165 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' ); |
|
166 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
164 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
165 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); |
|
166 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
167 | 167 | $total = 1; |
168 | 168 | |
169 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
169 | + if (($id = $view->param('id')) == null) |
|
170 | 170 | { |
171 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
172 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
173 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
171 | + $view->data = $manager->searchItems($search, array(), $total); |
|
172 | + $view->listItems = $this->getListItems($view->data, $include); |
|
173 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
174 | 174 | } |
175 | 175 | else |
176 | 176 | { |
177 | - $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
178 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
179 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
177 | + $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
178 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
179 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
180 | 180 | } |
181 | 181 | |
182 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
182 | + $view->refItems = $this->getRefItems($view->listItems); |
|
183 | 183 | $view->total = $total; |
184 | 184 | |
185 | 185 | return $view; |
@@ -193,18 +193,18 @@ discard block |
||
193 | 193 | * @param array $include List of resource types that should be fetched |
194 | 194 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
195 | 195 | */ |
196 | - protected function getListItems( array $items, array $include ) |
|
196 | + protected function getListItems(array $items, array $include) |
|
197 | 197 | { |
198 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
198 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
199 | 199 | |
200 | 200 | $search = $manager->createSearch(); |
201 | 201 | $expr = array( |
202 | - $search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ), |
|
203 | - $search->compare( '==', 'catalog.lists.domain', $include ), |
|
202 | + $search->compare('==', 'catalog.lists.parentid', array_keys($items)), |
|
203 | + $search->compare('==', 'catalog.lists.domain', $include), |
|
204 | 204 | ); |
205 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
205 | + $search->setConditions($search->combine('&&', $expr)); |
|
206 | 206 | |
207 | - return $manager->searchItems( $search ); |
|
207 | + return $manager->searchItems($search); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -215,32 +215,32 @@ discard block |
||
215 | 215 | * @param \stdClass $entry Object including "id" and "attributes" elements |
216 | 216 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
217 | 217 | */ |
218 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
218 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
219 | 219 | { |
220 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
221 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
220 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
221 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
222 | 222 | |
223 | - if( isset( $entry->id ) ) |
|
223 | + if (isset($entry->id)) |
|
224 | 224 | { |
225 | - $item = $manager->getItem( $entry->id ); |
|
226 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
227 | - $manager->saveItem( $item ); |
|
225 | + $item = $manager->getItem($entry->id); |
|
226 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
227 | + $manager->saveItem($item); |
|
228 | 228 | |
229 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
230 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
229 | + if (isset($entry->parentid) && $targetId !== null) { |
|
230 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | else |
234 | 234 | { |
235 | 235 | $item = $manager->createItem(); |
236 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
237 | - $manager->insertItem( $item, $targetId, $refId ); |
|
236 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
237 | + $manager->insertItem($item, $targetId, $refId); |
|
238 | 238 | } |
239 | 239 | |
240 | - if( isset( $entry->relationships ) ) { |
|
241 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
240 | + if (isset($entry->relationships)) { |
|
241 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
242 | 242 | } |
243 | 243 | |
244 | - return $manager->getItem( $item->getId() ); |
|
244 | + return $manager->getItem($item->getId()); |
|
245 | 245 | } |
246 | 246 | } |