Completed
Push — master ( d898d1...26c14b )
by Aimeos
02:05
created
admin/jsonadm/src/Admin/JsonAdm/Coupon/Config/Standard.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -110,30 +110,30 @@  discard block
 block discarded – undo
110 110
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
111 111
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
112 112
 	 */
113
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
113
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
114 114
 	{
115 115
 		$view = $this->getView();
116 116
 
117 117
 		try
118 118
 		{
119
-			$response = $this->getItems( $view, $request, $response );
119
+			$response = $this->getItems($view, $request, $response);
120 120
 			$status = 200;
121 121
 		}
122
-		catch( \Aimeos\MShop\Exception $e )
122
+		catch (\Aimeos\MShop\Exception $e)
123 123
 		{
124 124
 			$status = 404;
125
-			$view->errors = array( array(
126
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
125
+			$view->errors = array(array(
126
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
127 127
 				'detail' => $e->getTraceAsString(),
128
-			) );
128
+			));
129 129
 		}
130
-		catch( \Exception $e )
130
+		catch (\Exception $e)
131 131
 		{
132 132
 			$status = 500;
133
-			$view->errors = array( array(
133
+			$view->errors = array(array(
134 134
 				'title' => $e->getMessage(),
135 135
 				'detail' => $e->getTraceAsString(),
136
-			) );
136
+			));
137 137
 		}
138 138
 
139 139
 		/** admin/jsonadm/coupon/config/template-get
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 		$tplconf = 'admin/jsonadm/coupon/config/template-get';
159 159
 		$default = 'coupon/config/get-default.php';
160 160
 
161
-		$body = $view->render( $view->config( $tplconf, $default ) );
161
+		$body = $view->render($view->config($tplconf, $default));
162 162
 
163
-		return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' )
164
-			->withBody( $view->response()->createStreamFromString( $body ) )
165
-			->withStatus( $status );
163
+		return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"')
164
+			->withBody($view->response()->createStreamFromString($body))
165
+			->withStatus($status);
166 166
 	}
167 167
 
168 168
 
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
175 175
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
176 176
 	 */
177
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
177
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
178 178
 	{
179
-		if( ( $id = $view->param( 'id' ) ) == null ) {
180
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 );
179
+		if (($id = $view->param('id')) == null) {
180
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400);
181 181
 		}
182 182
 
183
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' );
183
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon');
184 184
 
185 185
 		$item = $manager->createItem();
186
-		$item->setProvider( $id );
186
+		$item->setProvider($id);
187 187
 
188
-		$view->configItems = $manager->getProvider( $item, null )->getConfigBE();
188
+		$view->configItems = $manager->getProvider($item, null)->getConfigBE();
189 189
 
190 190
 		return $response;
191 191
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -118,16 +118,14 @@
 block discarded – undo
118 118
 		{
119 119
 			$response = $this->getItems( $view, $request, $response );
120 120
 			$status = 200;
121
-		}
122
-		catch( \Aimeos\MShop\Exception $e )
121
+		} catch( \Aimeos\MShop\Exception $e )
123 122
 		{
124 123
 			$status = 404;
125 124
 			$view->errors = array( array(
126 125
 				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
127 126
 				'detail' => $e->getTraceAsString(),
128 127
 			) );
129
-		}
130
-		catch( \Exception $e )
128
+		} catch( \Exception $e )
131 129
 		{
132 130
 			$status = 500;
133 131
 			$view->errors = array( array(
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Catalog/Standard.php 2 patches
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
140 140
 	 * @param array $include List of resource types that should be fetched
141 141
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
142 142
 	 */
143
-	protected function getChildItems( array $items, array $include )
143
+	protected function getChildItems(array $items, array $include)
144 144
 	{
145 145
 		$list = [];
146 146
 
147
-		if( in_array( 'catalog', $include ) )
147
+		if (in_array('catalog', $include))
148 148
 		{
149
-			foreach( $items as $item ) {
150
-				$list = array_merge( $list, [$item], $this->getChildItems( $item->getChildren(), $include ) );
149
+			foreach ($items as $item) {
150
+				$list = array_merge($list, [$item], $this->getChildItems($item->getChildren(), $include));
151 151
 			}
152 152
 		}
153 153
 
@@ -162,40 +162,40 @@  discard block
 block discarded – undo
162 162
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
163 163
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
164 164
 	 */
165
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
165
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
166 166
 	{
167
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' );
167
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog');
168 168
 
169
-		if( ( $key = $view->param( 'aggregate' ) ) !== null )
169
+		if (($key = $view->param('aggregate')) !== null)
170 170
 		{
171
-			$search = $this->initCriteria( $manager->createSearch(), $view->param() );
172
-			$view->data = $manager->aggregate( $search, $key );
171
+			$search = $this->initCriteria($manager->createSearch(), $view->param());
172
+			$view->data = $manager->aggregate($search, $key);
173 173
 			return $response;
174 174
 		}
175 175
 
176
-		$include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : [] );
177
-		$search = $this->initCriteria( $manager->createSearch(), $view->param() );
176
+		$include = (($include = $view->param('include')) !== null ? explode(',', $include) : []);
177
+		$search = $this->initCriteria($manager->createSearch(), $view->param());
178 178
 		$total = 1;
179 179
 
180
-		if( ( $id = $view->param( 'id' ) ) == null )
180
+		if (($id = $view->param('id')) == null)
181 181
 		{
182
-			$view->data = $manager->searchItems( $search, [], $total );
183
-			$view->listItems = $this->getListItems( $view->data, $include );
182
+			$view->data = $manager->searchItems($search, [], $total);
183
+			$view->listItems = $this->getListItems($view->data, $include);
184 184
 			$view->childItems = [];
185 185
 		}
186 186
 		else
187 187
 		{
188 188
 			$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST;
189
-			if( in_array( 'catalog', $include ) ) {
189
+			if (in_array('catalog', $include)) {
190 190
 				$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE;
191 191
 			}
192 192
 
193
-			$view->data = $manager->getTree( $id, $include, $level, $search );
194
-			$view->listItems = $this->getListItems( array( $id => $view->data ), $include );
195
-			$view->childItems = $this->getChildItems( $view->data->getChildren(), $include );
193
+			$view->data = $manager->getTree($id, $include, $level, $search);
194
+			$view->listItems = $this->getListItems(array($id => $view->data), $include);
195
+			$view->childItems = $this->getChildItems($view->data->getChildren(), $include);
196 196
 		}
197 197
 
198
-		$view->refItems = $this->getRefItems( $view->listItems );
198
+		$view->refItems = $this->getRefItems($view->listItems);
199 199
 		$view->total = $total;
200 200
 
201 201
 		return $response;
@@ -209,18 +209,18 @@  discard block
 block discarded – undo
209 209
 	 * @param array $include List of resource types that should be fetched
210 210
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface
211 211
 	 */
212
-	protected function getListItems( array $items, array $include )
212
+	protected function getListItems(array $items, array $include)
213 213
 	{
214
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
214
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
215 215
 
216 216
 		$search = $manager->createSearch();
217 217
 		$expr = array(
218
-			$search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ),
219
-			$search->compare( '==', 'catalog.lists.domain', $include ),
218
+			$search->compare('==', 'catalog.lists.parentid', array_keys($items)),
219
+			$search->compare('==', 'catalog.lists.domain', $include),
220 220
 		);
221
-		$search->setConditions( $search->combine( '&&', $expr ) );
221
+		$search->setConditions($search->combine('&&', $expr));
222 222
 
223
-		return $manager->searchItems( $search );
223
+		return $manager->searchItems($search);
224 224
 	}
225 225
 
226 226
 
@@ -231,32 +231,32 @@  discard block
 block discarded – undo
231 231
 	 * @param \stdClass $entry Object including "id" and "attributes" elements
232 232
 	 * @return \Aimeos\MShop\Common\Item\Iface New or updated item
233 233
 	 */
234
-	protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry )
234
+	protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry)
235 235
 	{
236
-		$targetId = ( isset( $entry->targetid ) ? $entry->targetid : null );
237
-		$refId = ( isset( $entry->refid ) ? $entry->refid : null );
236
+		$targetId = (isset($entry->targetid) ? $entry->targetid : null);
237
+		$refId = (isset($entry->refid) ? $entry->refid : null);
238 238
 
239
-		if( isset( $entry->id ) )
239
+		if (isset($entry->id))
240 240
 		{
241
-			$item = $manager->getItem( $entry->id );
242
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
243
-			$item = $manager->saveItem( $item );
241
+			$item = $manager->getItem($entry->id);
242
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
243
+			$item = $manager->saveItem($item);
244 244
 
245
-			if( isset( $entry->parentid ) && $targetId !== null ) {
246
-				$manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId );
245
+			if (isset($entry->parentid) && $targetId !== null) {
246
+				$manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId);
247 247
 			}
248 248
 		}
249 249
 		else
250 250
 		{
251 251
 			$item = $manager->createItem();
252
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
253
-			$manager->insertItem( $item, $targetId, $refId );
252
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
253
+			$manager->insertItem($item, $targetId, $refId);
254 254
 		}
255 255
 
256
-		if( isset( $entry->relationships ) ) {
257
-			$this->saveRelationships( $manager, $item, $entry->relationships );
256
+		if (isset($entry->relationships)) {
257
+			$this->saveRelationships($manager, $item, $entry->relationships);
258 258
 		}
259 259
 
260
-		return $manager->getItem( $item->getId() );
260
+		return $manager->getItem($item->getId());
261 261
 	}
262 262
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -182,8 +182,7 @@  discard block
 block discarded – undo
182 182
 			$view->data = $manager->searchItems( $search, [], $total );
183 183
 			$view->listItems = $this->getListItems( $view->data, $include );
184 184
 			$view->childItems = [];
185
-		}
186
-		else
185
+		} else
187 186
 		{
188 187
 			$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST;
189 188
 			if( in_array( 'catalog', $include ) ) {
@@ -245,8 +244,7 @@  discard block
 block discarded – undo
245 244
 			if( isset( $entry->parentid ) && $targetId !== null ) {
246 245
 				$manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId );
247 246
 			}
248
-		}
249
-		else
247
+		} else
250 248
 		{
251 249
 			$item = $manager->createItem();
252 250
 			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Catalog/StandardTest.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 		$this->context = \TestHelperJadm::getContext();
23 23
 		$this->view = $this->context->getView();
24 24
 
25
-		$this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard( $this->context, $this->view, $templatePaths, 'catalog' );
25
+		$this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard($this->context, $this->view, $templatePaths, 'catalog');
26 26
 	}
27 27
 
28 28
 
@@ -30,142 +30,142 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$params = array(
32 32
 			'filter' => array(
33
-				'==' => array( 'catalog.code' => 'cafe' )
33
+				'==' => array('catalog.code' => 'cafe')
34 34
 			),
35 35
 			'include' => 'text'
36 36
 		);
37
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
38
-		$this->view->addHelper( 'param', $helper );
37
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
38
+		$this->view->addHelper('param', $helper);
39 39
 
40
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
41
-		$result = json_decode( (string) $response->getBody(), true );
40
+		$response = $this->object->get($this->view->request(), $this->view->response());
41
+		$result = json_decode((string) $response->getBody(), true);
42 42
 
43 43
 
44
-		$this->assertEquals( 200, $response->getStatusCode() );
45
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
44
+		$this->assertEquals(200, $response->getStatusCode());
45
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
46 46
 
47
-		$this->assertEquals( 1, $result['meta']['total'] );
48
-		$this->assertEquals( 1, count( $result['data'] ) );
49
-		$this->assertEquals( 'catalog', $result['data'][0]['type'] );
50
-		$this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) );
51
-		$this->assertEquals( 6, count( $result['included'] ) );
47
+		$this->assertEquals(1, $result['meta']['total']);
48
+		$this->assertEquals(1, count($result['data']));
49
+		$this->assertEquals('catalog', $result['data'][0]['type']);
50
+		$this->assertEquals(6, count($result['data'][0]['relationships']['text']));
51
+		$this->assertEquals(6, count($result['included']));
52 52
 
53
-		$this->assertArrayNotHasKey( 'errors', $result );
53
+		$this->assertArrayNotHasKey('errors', $result);
54 54
 	}
55 55
 
56 56
 
57 57
 	public function testGetTree()
58 58
 	{
59 59
 		$params = array(
60
-			'id' => $this->getCatalogItem( 'root' )->getId(),
60
+			'id' => $this->getCatalogItem('root')->getId(),
61 61
 			'include' => 'catalog,text'
62 62
 		);
63
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
64
-		$this->view->addHelper( 'param', $helper );
63
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
64
+		$this->view->addHelper('param', $helper);
65 65
 
66
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
67
-		$result = json_decode( (string) $response->getBody(), true );
66
+		$response = $this->object->get($this->view->request(), $this->view->response());
67
+		$result = json_decode((string) $response->getBody(), true);
68 68
 
69
-		$this->assertEquals( 200, $response->getStatusCode() );
70
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
69
+		$this->assertEquals(200, $response->getStatusCode());
70
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
71 71
 
72
-		$this->assertEquals( 1, $result['meta']['total'] );
73
-		$this->assertEquals( 'catalog', $result['data']['type'] );
74
-		$this->assertEquals( 2, count( $result['data']['relationships']['catalog'] ) );
75
-		$this->assertEquals( 7, count( $result['included'] ) );
72
+		$this->assertEquals(1, $result['meta']['total']);
73
+		$this->assertEquals('catalog', $result['data']['type']);
74
+		$this->assertEquals(2, count($result['data']['relationships']['catalog']));
75
+		$this->assertEquals(7, count($result['included']));
76 76
 
77
-		$this->assertArrayNotHasKey( 'errors', $result );
77
+		$this->assertArrayNotHasKey('errors', $result);
78 78
 	}
79 79
 
80 80
 
81 81
 	public function testPatch()
82 82
 	{
83
-		$stub = $this->getCatalogMock( array( 'getItem', 'moveItem', 'saveItem' ) );
83
+		$stub = $this->getCatalogMock(array('getItem', 'moveItem', 'saveItem'));
84 84
 
85
-		$stub->expects( $this->once() )->method( 'moveItem' );
86
-		$stub->expects( $this->once() )->method( 'saveItem' )
87
-			->will( $this->returnValue( $stub->createItem() ) );
88
-		$stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator
89
-			->will( $this->returnValue( $stub->createItem() ) );
85
+		$stub->expects($this->once())->method('moveItem');
86
+		$stub->expects($this->once())->method('saveItem')
87
+			->will($this->returnValue($stub->createItem()));
88
+		$stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator
89
+			->will($this->returnValue($stub->createItem()));
90 90
 
91 91
 
92
-		$params = array( 'id' => '-1' );
93
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
94
-		$this->view->addHelper( 'param', $helper );
92
+		$params = array('id' => '-1');
93
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
94
+		$this->view->addHelper('param', $helper);
95 95
 
96 96
 		$body = '{"data": {"parentid": "1", "targetid": 2, "type": "catalog", "attributes": {"catalog.label": "test"}}}';
97
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
97
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
98 98
 
99
-		$response = $this->object->patch( $request, $this->view->response() );
100
-		$result = json_decode( (string) $response->getBody(), true );
99
+		$response = $this->object->patch($request, $this->view->response());
100
+		$result = json_decode((string) $response->getBody(), true);
101 101
 
102 102
 
103
-		$this->assertEquals( 200, $response->getStatusCode() );
104
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
103
+		$this->assertEquals(200, $response->getStatusCode());
104
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
105 105
 
106
-		$this->assertEquals( 1, $result['meta']['total'] );
107
-		$this->assertArrayHasKey( 'data', $result );
108
-		$this->assertEquals( 'catalog', $result['data']['type'] );
106
+		$this->assertEquals(1, $result['meta']['total']);
107
+		$this->assertArrayHasKey('data', $result);
108
+		$this->assertEquals('catalog', $result['data']['type']);
109 109
 
110
-		$this->assertArrayNotHasKey( 'included', $result );
111
-		$this->assertArrayNotHasKey( 'errors', $result );
110
+		$this->assertArrayNotHasKey('included', $result);
111
+		$this->assertArrayNotHasKey('errors', $result);
112 112
 	}
113 113
 
114 114
 
115 115
 	public function testPost()
116 116
 	{
117
-		$stub = $this->getCatalogMock( array( 'getItem', 'insertItem' ) );
117
+		$stub = $this->getCatalogMock(array('getItem', 'insertItem'));
118 118
 
119
-		$stub->expects( $this->any() )->method( 'getItem' )
120
-			->will( $this->returnValue( $stub->createItem() ) );
121
-		$stub->expects( $this->once() )->method( 'insertItem' );
119
+		$stub->expects($this->any())->method('getItem')
120
+			->will($this->returnValue($stub->createItem()));
121
+		$stub->expects($this->once())->method('insertItem');
122 122
 
123 123
 
124 124
 		$body = '{"data": {"type": "catalog", "attributes": {"catalog.code": "test", "catalog.label": "Test catalog"}}}';
125
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
125
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
126 126
 
127
-		$response = $this->object->post( $request, $this->view->response() );
128
-		$result = json_decode( (string) $response->getBody(), true );
127
+		$response = $this->object->post($request, $this->view->response());
128
+		$result = json_decode((string) $response->getBody(), true);
129 129
 
130 130
 
131
-		$this->assertEquals( 201, $response->getStatusCode() );
132
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
131
+		$this->assertEquals(201, $response->getStatusCode());
132
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
133 133
 
134
-		$this->assertEquals( 1, $result['meta']['total'] );
135
-		$this->assertArrayHasKey( 'data', $result );
136
-		$this->assertEquals( 'catalog', $result['data']['type'] );
134
+		$this->assertEquals(1, $result['meta']['total']);
135
+		$this->assertArrayHasKey('data', $result);
136
+		$this->assertEquals('catalog', $result['data']['type']);
137 137
 
138
-		$this->assertArrayNotHasKey( 'included', $result );
139
-		$this->assertArrayNotHasKey( 'errors', $result );
138
+		$this->assertArrayNotHasKey('included', $result);
139
+		$this->assertArrayNotHasKey('errors', $result);
140 140
 	}
141 141
 
142 142
 
143
-	protected function getCatalogItem( $code )
143
+	protected function getCatalogItem($code)
144 144
 	{
145
-		$manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context );
145
+		$manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context);
146 146
 		$search = $manager->createSearch();
147
-		$search->setConditions( $search->compare( '==', 'catalog.code', $code ) );
148
-		$items = $manager->searchItems( $search );
147
+		$search->setConditions($search->compare('==', 'catalog.code', $code));
148
+		$items = $manager->searchItems($search);
149 149
 
150
-		if( ( $item = reset( $items ) ) === false ) {
151
-			throw new \RuntimeException( sprintf( 'No catalog item with code "%1$s" found', $code ) );
150
+		if (($item = reset($items)) === false) {
151
+			throw new \RuntimeException(sprintf('No catalog item with code "%1$s" found', $code));
152 152
 		}
153 153
 
154 154
 		return $item;
155 155
 	}
156 156
 
157 157
 
158
-	protected function getCatalogMock( array $methods )
158
+	protected function getCatalogMock(array $methods)
159 159
 	{
160 160
 		$name = 'ClientJsonAdmStandard';
161
-		$this->context->getConfig()->set( 'mshop/catalog/manager/name', $name );
161
+		$this->context->getConfig()->set('mshop/catalog/manager/name', $name);
162 162
 
163
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Catalog\\Manager\\Standard' )
164
-			->setConstructorArgs( array( $this->context ) )
165
-			->setMethods( $methods )
163
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Catalog\\Manager\\Standard')
164
+			->setConstructorArgs(array($this->context))
165
+			->setMethods($methods)
166 166
 			->getMock();
167 167
 
168
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub );
168
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub);
169 169
 
170 170
 		return $stub;
171 171
 	}
Please login to merge, or discard this patch.
admin/jsonadm/templates/delete-default.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 ?>
12 12
 {
13 13
 	"meta": {
14
-		"total": <?= $this->get( 'total', 0 ); ?>
14
+		"total": <?= $this->get('total', 0); ?>
15 15
 
16
-		<?php if( $this->csrf()->name() != '' ) : ?>
16
+		<?php if ($this->csrf()->name() != '') : ?>
17 17
 			, "csrf": {
18 18
 				"name": "<?= $this->csrf()->name(); ?>",
19 19
 				"value": "<?= $this->csrf()->value(); ?>"
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 
23 23
 	}
24 24
 
25
-	<?php if( isset( $this->errors ) ) : ?>
25
+	<?php if (isset($this->errors)) : ?>
26 26
 
27
-		,"errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
27
+		,"errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
28 28
 
29 29
 	<?php endif; ?>
30 30
 
Please login to merge, or discard this patch.
admin/jsonadm/templates/post-default.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 ?>
12 12
 {
13 13
 	"meta": {
14
-		"total": <?= $this->get( 'total', 0 ); ?>
14
+		"total": <?= $this->get('total', 0); ?>
15 15
 
16
-		<?php if( $this->csrf()->name() != '' ) : ?>
16
+		<?php if ($this->csrf()->name() != '') : ?>
17 17
 			, "csrf": {
18 18
 				"name": "<?= $this->csrf()->name(); ?>",
19 19
 				"value": "<?= $this->csrf()->value(); ?>"
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 
23 23
 	}
24 24
 
25
-	<?php if( isset( $this->errors ) ) : ?>
25
+	<?php if (isset($this->errors)) : ?>
26 26
 
27
-		, "errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
27
+		, "errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
28 28
 
29
-	<?php elseif( isset( $this->data ) ) : ?>
29
+	<?php elseif (isset($this->data)) : ?>
30 30
 
31
-		, "data": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>
31
+		, "data": <?= $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>
32 32
 
33 33
 	<?php endif; ?>
34 34
 
Please login to merge, or discard this patch.
admin/jsonadm/templates/get-default.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  * @see admin/jsonadm/url/action
23 23
  * @see admin/jsonadm/url/config
24 24
  */
25
-$target = $this->config( 'admin/jsonadm/url/target' );
25
+$target = $this->config('admin/jsonadm/url/target');
26 26
 
27 27
 /** admin/jsonadm/url/controller
28 28
  * Name of the client whose action should be called
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @see admin/jsonadm/url/action
39 39
  * @see admin/jsonadm/url/config
40 40
  */
41
-$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' );
41
+$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm');
42 42
 
43 43
 /** admin/jsonadm/url/action
44 44
  * Name of the action that should create the output
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  * @see admin/jsonadm/url/controller
55 55
  * @see admin/jsonadm/url/config
56 56
  */
57
-$action = $this->config( 'admin/jsonadm/url/action', 'get' );
57
+$action = $this->config('admin/jsonadm/url/action', 'get');
58 58
 
59 59
 /** admin/jsonadm/url/config
60 60
  * Associative list of configuration options used for generating the URL
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
  * @see admin/jsonadm/url/controller
77 77
  * @see admin/jsonadm/url/action
78 78
  */
79
-$config = $this->config( 'admin/jsonadm/url/config', [] );
79
+$config = $this->config('admin/jsonadm/url/config', []);
80 80
 
81 81
 
82 82
 /** admin/jsonadm/partials/template-errors
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
  */
129 129
 
130 130
 
131
-$total = $this->get( 'total', 0 );
132
-$offset = max( $this->param( 'page/offset', 0 ), 0 );
133
-$limit = max( $this->param( 'page/limit', 25 ), 1 );
131
+$total = $this->get('total', 0);
132
+$offset = max($this->param('page/offset', 0), 0);
133
+$limit = max($this->param('page/limit', 25), 1);
134 134
 
135
-$first = ( $offset > 0 ? 0 : null );
136
-$prev = ( $offset - $limit >= 0 ? $offset - $limit : null );
137
-$next = ( $offset + $limit < $total ? $offset + $limit : null );
138
-$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null );
135
+$first = ($offset > 0 ? 0 : null);
136
+$prev = ($offset - $limit >= 0 ? $offset - $limit : null);
137
+$next = ($offset + $limit < $total ? $offset + $limit : null);
138
+$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null);
139 139
 
140 140
 
141
-$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' );
142
-$params = array_intersect_key( $this->param(), array_flip( $ref ) ) + ['id' => ''];
143
-$fields = $this->param( 'fields', [] );
141
+$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields');
142
+$params = array_intersect_key($this->param(), array_flip($ref)) + ['id' => ''];
143
+$fields = $this->param('fields', []);
144 144
 
145
-foreach( (array) $fields as $resource => $list ) {
146
-	$fields[$resource] = array_flip( explode( ',', $list ) );
145
+foreach ((array) $fields as $resource => $list) {
146
+	$fields[$resource] = array_flip(explode(',', $list));
147 147
 }
148 148
 
149 149
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	"meta": {
153 153
 		"total": <?= $total; ?>
154 154
 
155
-		<?php if( $this->csrf()->name() != '' ) : ?>
155
+		<?php if ($this->csrf()->name() != '') : ?>
156 156
 			, "csrf": {
157 157
 				"name": "<?= $this->csrf()->name(); ?>",
158 158
 				"value": "<?= $this->csrf()->value(); ?>"
@@ -163,42 +163,42 @@  discard block
 block discarded – undo
163 163
 
164 164
 	"links": {
165 165
 
166
-		<?php if( is_array( $this->get( 'data' ) ) ) : ?>
166
+		<?php if (is_array($this->get('data'))) : ?>
167 167
 
168
-			<?php if( $first !== null ) : ?>
168
+			<?php if ($first !== null) : ?>
169 169
 
170
-				"first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>",
170
+				"first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, [], $config); ?>",
171 171
 
172 172
 			<?php endif; ?>
173
-			<?php if( $prev !== null ) : ?>
173
+			<?php if ($prev !== null) : ?>
174 174
 
175
-				"prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>",
175
+				"prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, [], $config); ?>",
176 176
 
177 177
 			<?php endif; ?>
178
-			<?php if( $next !== null ) : ?>
178
+			<?php if ($next !== null) : ?>
179 179
 
180
-				"next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>",
180
+				"next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, [], $config); ?>",
181 181
 
182 182
 			<?php endif; ?>
183
-			<?php if( $last !== null ) : ?>
183
+			<?php if ($last !== null) : ?>
184 184
 
185
-				"last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>",
185
+				"last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, [], $config); ?>",
186 186
 
187 187
 			<?php endif; ?>
188 188
 		<?php endif; ?>
189 189
 
190
-		"self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>"
190
+		"self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, [], $config); ?>"
191 191
 	},
192 192
 
193
-	<?php if( isset( $this->errors ) ) : ?>
193
+	<?php if (isset($this->errors)) : ?>
194 194
 
195
-		"errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
195
+		"errors": <?= $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
196 196
 
197
-	<?php elseif( isset( $this->data ) ) : ?>
197
+	<?php elseif (isset($this->data)) : ?>
198 198
 
199
-		"data": <?= $this->partial( $this->config( $this->get( 'partial-data', 'admin/jsonadm/partials/template-data' ), 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ), 'childItems' => $this->get( 'childItems', [] ), 'listItems' => $this->get( 'listItems', [] ) ) ); ?>,
199
+		"data": <?= $this->partial($this->config($this->get('partial-data', 'admin/jsonadm/partials/template-data'), 'partials/data-standard.php'), array('data' => $this->get('data'), 'childItems' => $this->get('childItems', []), 'listItems' => $this->get('listItems', []))); ?>,
200 200
 
201
-		"included": <?= $this->partial( $this->config( $this->get( 'partial-included', 'admin/jsonadm/partials/template-included' ), 'partials/included-standard.php' ), array( 'childItems' => $this->get( 'childItems', [] ), 'refItems' => $this->get( 'refItems', [] ) ) ); ?>
201
+		"included": <?= $this->partial($this->config($this->get('partial-included', 'admin/jsonadm/partials/template-included'), 'partials/included-standard.php'), array('childItems' => $this->get('childItems', []), 'refItems' => $this->get('refItems', []))); ?>
202 202
 
203 203
 	<?php endif; ?>
204 204
 
Please login to merge, or discard this patch.
admin/jsonadm/templates/aggregate-default.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 
11
-$data = $this->get( 'data', [] );
11
+$data = $this->get('data', []);
12 12
 $entries = [];
13 13
 
14
-foreach( $data as $key => $value ) {
15
-	$entries[] = array( 'id' => $key, 'type' => 'aggregate', 'attributes' => $value );
14
+foreach ($data as $key => $value) {
15
+	$entries[] = array('id' => $key, 'type' => 'aggregate', 'attributes' => $value);
16 16
 }
17 17
 
18 18
 ?>
19 19
 {
20 20
 	"meta": {
21
-		"total": <?= count( $data ); ?>
21
+		"total": <?= count($data); ?>
22 22
 
23
-		<?php if( $this->csrf()->name() != '' ) : ?>
23
+		<?php if ($this->csrf()->name() != '') : ?>
24 24
 			, "csrf": {
25 25
 				"name": "<?= $this->csrf()->name(); ?>",
26 26
 				"value": "<?= $this->csrf()->value(); ?>"
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 
30 30
 	},
31 31
 
32
-	<?php if( isset( $this->errors ) ) : ?>
32
+	<?php if (isset($this->errors)) : ?>
33 33
 
34
-		"errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
34
+		"errors": <?= $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
35 35
 
36
-	<?php elseif( isset( $this->data ) ) : ?>
36
+	<?php elseif (isset($this->data)) : ?>
37 37
 
38
-		"data": <?= json_encode( $entries ); ?>
38
+		"data": <?= json_encode($entries); ?>
39 39
 
40 40
 	<?php endif; ?>
41 41
 }
Please login to merge, or discard this patch.
admin/jsonadm/templates/patch-default.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 ?>
12 12
 {
13 13
 	"meta": {
14
-		"total": <?= $this->get( 'total', 0 ); ?>
14
+		"total": <?= $this->get('total', 0); ?>
15 15
 
16
-		<?php if( $this->csrf()->name() != '' ) : ?>
16
+		<?php if ($this->csrf()->name() != '') : ?>
17 17
 			, "csrf": {
18 18
 				"name": "<?= $this->csrf()->name(); ?>",
19 19
 				"value": "<?= $this->csrf()->value(); ?>"
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 
23 23
 	}
24 24
 
25
-	<?php if( isset( $this->errors ) ) : ?>
25
+	<?php if (isset($this->errors)) : ?>
26 26
 
27
-		, "errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
27
+		, "errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
28 28
 
29
-	<?php elseif( isset( $this->data ) ) : ?>
29
+	<?php elseif (isset($this->data)) : ?>
30 30
 
31
-		, "data": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>
31
+		, "data": <?= $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>
32 32
 
33 33
 	<?php endif; ?>
34 34
 
Please login to merge, or discard this patch.