Completed
Push — master ( ebc049...f51047 )
by Aimeos
01:46
created
admin/jsonadm/src/Admin/JsonAdm/Locale/Site/Standard.php 1 patch
Spacing   +19 added lines, -19 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/locale/site/template-data
116 116
 		 * Relative path to the data partial template file for the locale site  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/locale/site/template-data' ) );
130
+		$this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/locale/site/template-data'));
131 131
 
132
-		return parent::get( $request, $response );
132
+		return parent::get($request, $response);
133 133
 	}
134 134
 
135 135
 
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
142 142
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
143 143
 	 */
144
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
144
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
145 145
 	{
146
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' );
147
-		$search = $this->initCriteria( $manager->createSearch(), $view->param() );
146
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale/site');
147
+		$search = $this->initCriteria($manager->createSearch(), $view->param());
148 148
 		$total = 1;
149 149
 
150
-		if( ( $id = $view->param( 'id' ) ) == null ) {
151
-			$view->data = $manager->searchItems( $search, [], $total );
150
+		if (($id = $view->param('id')) == null) {
151
+			$view->data = $manager->searchItems($search, [], $total);
152 152
 		} else {
153
-			$view->data = $manager->getTree( $id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $search );
153
+			$view->data = $manager->getTree($id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $search);
154 154
 		}
155 155
 
156 156
 		$view->childItems = [];
@@ -169,25 +169,25 @@  discard block
 block discarded – undo
169 169
 	 * @param \stdClass $entry Object including "id" and "attributes" elements
170 170
 	 * @return \Aimeos\MShop\Common\Item\Iface New or updated item
171 171
 	 */
172
-	protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry )
172
+	protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry)
173 173
 	{
174
-		if( isset( $entry->id ) )
174
+		if (isset($entry->id))
175 175
 		{
176
-			$item = $manager->getItem( $entry->id );
177
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
178
-			$item = $manager->saveItem( $item );
176
+			$item = $manager->getItem($entry->id);
177
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
178
+			$item = $manager->saveItem($item);
179 179
 		}
180 180
 		else
181 181
 		{
182 182
 			$item = $manager->createItem();
183
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
184
-			$manager->insertItem( $item );
183
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
184
+			$manager->insertItem($item);
185 185
 		}
186 186
 
187
-		if( isset( $entry->relationships ) ) {
188
-			$this->saveRelationships( $manager, $item, $entry->relationships );
187
+		if (isset($entry->relationships)) {
188
+			$this->saveRelationships($manager, $item, $entry->relationships);
189 189
 		}
190 190
 
191
-		return $manager->getItem( $item->getId() );
191
+		return $manager->getItem($item->getId());
192 192
 	}
193 193
 }
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Locale/Site/StandardTest.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -22,32 +22,32 @@  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\Locale\Site\Standard( $this->context, $this->view, $templatePaths, 'locale/site' );
25
+		$this->object = new \Aimeos\Admin\JsonAdm\Locale\Site\Standard($this->context, $this->view, $templatePaths, 'locale/site');
26 26
 	}
27 27
 
28 28
 
29 29
 	public function testGet()
30 30
 	{
31 31
 		$params = array(
32
-			'id' => $this->getSiteItem( 'unittest' )->getId(),
32
+			'id' => $this->getSiteItem('unittest')->getId(),
33 33
 			'filter' => array(
34
-				'==' => array( 'locale.status' => 0 )
34
+				'==' => array('locale.status' => 0)
35 35
 			),
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( 'locale/site', $result['data']['type'] );
47
+		$this->assertEquals(1, $result['meta']['total']);
48
+		$this->assertEquals('locale/site', $result['data']['type']);
49 49
 
50
-		$this->assertArrayNotHasKey( 'errors', $result );
50
+		$this->assertArrayNotHasKey('errors', $result);
51 51
 	}
52 52
 
53 53
 
@@ -55,124 +55,124 @@  discard block
 block discarded – undo
55 55
 	{
56 56
 		$params = array(
57 57
 			'filter' => array(
58
-				'==' => array( 'locale.site.code' => 'unittest' )
58
+				'==' => array('locale.site.code' => 'unittest')
59 59
 			),
60 60
 		);
61
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
62
-		$this->view->addHelper( 'param', $helper );
61
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
62
+		$this->view->addHelper('param', $helper);
63 63
 
64
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
65
-		$result = json_decode( (string) $response->getBody(), true );
64
+		$response = $this->object->get($this->view->request(), $this->view->response());
65
+		$result = json_decode((string) $response->getBody(), true);
66 66
 
67 67
 
68
-		$this->assertEquals( 200, $response->getStatusCode() );
69
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
68
+		$this->assertEquals(200, $response->getStatusCode());
69
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
70 70
 
71
-		$this->assertEquals( 1, $result['meta']['total'] );
72
-		$this->assertEquals( 1, count( $result['data'] ) );
73
-		$this->assertEquals( 'locale/site', $result['data'][0]['type'] );
71
+		$this->assertEquals(1, $result['meta']['total']);
72
+		$this->assertEquals(1, count($result['data']));
73
+		$this->assertEquals('locale/site', $result['data'][0]['type']);
74 74
 
75
-		$this->assertArrayNotHasKey( 'errors', $result );
75
+		$this->assertArrayNotHasKey('errors', $result);
76 76
 	}
77 77
 
78 78
 
79 79
 	public function testPatch()
80 80
 	{
81
-		$stub = $this->getSiteMock( array( 'getItem', 'moveItem', 'saveItem' ) );
81
+		$stub = $this->getSiteMock(array('getItem', 'moveItem', 'saveItem'));
82 82
 		$item = $stub->createItem();
83 83
 
84
-		$stub->expects( $this->once() )->method( 'saveItem' )
85
-			->will( $this->returnValue( $stub->createItem() ) );
86
-		$stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator
87
-			->will( $this->returnValue( $item ) );
84
+		$stub->expects($this->once())->method('saveItem')
85
+			->will($this->returnValue($stub->createItem()));
86
+		$stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator
87
+			->will($this->returnValue($item));
88 88
 
89 89
 
90
-		$params = array( 'id' => '-1' );
91
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
92
-		$this->view->addHelper( 'param', $helper );
90
+		$params = array('id' => '-1');
91
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
92
+		$this->view->addHelper('param', $helper);
93 93
 
94 94
 		$body = '{"data": {"parentid": "1", "targetid": 2, "type": "locale/site", "attributes": {"locale.site.label": "test"}}}';
95
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
95
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
96 96
 
97
-		$response = $this->object->patch( $request, $this->view->response() );
98
-		$result = json_decode( (string) $response->getBody(), true );
97
+		$response = $this->object->patch($request, $this->view->response());
98
+		$result = json_decode((string) $response->getBody(), true);
99 99
 
100 100
 
101
-		$this->assertEquals( 200, $response->getStatusCode() );
102
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
101
+		$this->assertEquals(200, $response->getStatusCode());
102
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
103 103
 
104
-		$this->assertEquals( 1, $result['meta']['total'] );
105
-		$this->assertArrayHasKey( 'data', $result );
106
-		$this->assertEquals( 'locale/site', $result['data']['type'] );
104
+		$this->assertEquals(1, $result['meta']['total']);
105
+		$this->assertArrayHasKey('data', $result);
106
+		$this->assertEquals('locale/site', $result['data']['type']);
107 107
 
108
-		$this->assertArrayNotHasKey( 'included', $result );
109
-		$this->assertArrayNotHasKey( 'errors', $result );
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->getSiteMock( array( 'getItem', 'insertItem' ) );
115
+		$stub = $this->getSiteMock(array('getItem', 'insertItem'));
116 116
 		$item = $stub->createItem();
117 117
 
118
-		$stub->expects( $this->any() )->method( 'getItem' )
119
-			->will( $this->returnValue( $item ) );
120
-		$stub->expects( $this->once() )->method( 'insertItem' );
118
+		$stub->expects($this->any())->method('getItem')
119
+			->will($this->returnValue($item));
120
+		$stub->expects($this->once())->method('insertItem');
121 121
 
122 122
 
123 123
 		$body = '{"data": {"type": "locale/site", "attributes": {"locale.site.code": "unittest", "locale.site.label": "Unit test"}}}';
124
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
124
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
125 125
 
126
-		$response = $this->object->post( $request, $this->view->response() );
127
-		$result = json_decode( (string) $response->getBody(), true );
126
+		$response = $this->object->post($request, $this->view->response());
127
+		$result = json_decode((string) $response->getBody(), true);
128 128
 
129 129
 
130
-		$this->assertEquals( 201, $response->getStatusCode() );
131
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
130
+		$this->assertEquals(201, $response->getStatusCode());
131
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
132 132
 
133
-		$this->assertEquals( 1, $result['meta']['total'] );
134
-		$this->assertArrayHasKey( 'data', $result );
135
-		$this->assertEquals( 'locale/site', $result['data']['type'] );
133
+		$this->assertEquals(1, $result['meta']['total']);
134
+		$this->assertArrayHasKey('data', $result);
135
+		$this->assertEquals('locale/site', $result['data']['type']);
136 136
 
137
-		$this->assertArrayNotHasKey( 'included', $result );
138
-		$this->assertArrayNotHasKey( 'errors', $result );
137
+		$this->assertArrayNotHasKey('included', $result);
138
+		$this->assertArrayNotHasKey('errors', $result);
139 139
 	}
140 140
 
141 141
 
142
-	protected function getSiteItem( $code )
142
+	protected function getSiteItem($code)
143 143
 	{
144
-		$manager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $this->context )->getSubManager( 'site' );
144
+		$manager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->context)->getSubManager('site');
145 145
 		$search = $manager->createSearch();
146
-		$search->setConditions( $search->compare( '==', 'locale.site.code', $code ) );
147
-		$items = $manager->searchItems( $search );
146
+		$search->setConditions($search->compare('==', 'locale.site.code', $code));
147
+		$items = $manager->searchItems($search);
148 148
 
149
-		if( ( $item = reset( $items ) ) === false ) {
150
-			throw new \RuntimeException( sprintf( 'No locale site item with code "%1$s" found', $code ) );
149
+		if (($item = reset($items)) === false) {
150
+			throw new \RuntimeException(sprintf('No locale site item with code "%1$s" found', $code));
151 151
 		}
152 152
 
153 153
 		return $item;
154 154
 	}
155 155
 
156 156
 
157
-	protected function getSiteMock( array $methods )
157
+	protected function getSiteMock(array $methods)
158 158
 	{
159 159
 		$name = 'AdminJsonAdmStandard';
160
-		$this->context->getConfig()->set( 'mshop/locale/manager/name', $name );
160
+		$this->context->getConfig()->set('mshop/locale/manager/name', $name);
161 161
 
162
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Standard' )
163
-			->setConstructorArgs( array( $this->context ) )
164
-			->setMethods( array( 'getSubManager' ) )
162
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Standard')
163
+			->setConstructorArgs(array($this->context))
164
+			->setMethods(array('getSubManager'))
165 165
 			->getMock();
166 166
 
167
-		$siteStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard' )
168
-			->setConstructorArgs( array( $this->context ) )
169
-			->setMethods( $methods )
167
+		$siteStub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard')
168
+			->setConstructorArgs(array($this->context))
169
+			->setMethods($methods)
170 170
 			->getMock();
171 171
 
172
-		$stub->expects( $this->once() )->method( 'getSubManager' )
173
-			->will( $this->returnValue( $siteStub ) );
172
+		$stub->expects($this->once())->method('getSubManager')
173
+			->will($this->returnValue($siteStub));
174 174
 
175
-		\Aimeos\MShop\Locale\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub );
175
+		\Aimeos\MShop\Locale\Manager\Factory::injectManager('\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub);
176 176
 
177 177
 		return $siteStub;
178 178
 	}
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Catalog/Standard.php 1 patch
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_ONE;
189
-			if( in_array( 'catalog', $include ) ) {
189
+			if (in_array('catalog', $include)) {
190 190
 				$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST;
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.
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( 2, 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(2, 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/tests/TestHelperJadm.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 	public static function bootstrap()
16 16
 	{
17 17
 		self::getAimeos();
18
-		\Aimeos\MShop\Factory::setCache( false );
19
-		\Aimeos\Admin\JsonAdm\Factory::setCache( false );
18
+		\Aimeos\MShop\Factory::setCache(false);
19
+		\Aimeos\Admin\JsonAdm\Factory::setCache(false);
20 20
 	}
21 21
 
22 22
 
23
-	public static function getContext( $site = 'unittest' )
23
+	public static function getContext($site = 'unittest')
24 24
 	{
25
-		if( !isset( self::$context[$site] ) ) {
26
-			self::$context[$site] = self::createContext( $site );
25
+		if (!isset(self::$context[$site])) {
26
+			self::$context[$site] = self::createContext($site);
27 27
 		}
28 28
 
29 29
 		return clone self::$context[$site];
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
 
33 33
 	public static function getAimeos()
34 34
 	{
35
-		if( !isset( self::$aimeos ) )
35
+		if (!isset(self::$aimeos))
36 36
 		{
37 37
 			require_once 'Bootstrap.php';
38
-			spl_autoload_register( 'Aimeos\\Bootstrap::autoload' );
38
+			spl_autoload_register('Aimeos\\Bootstrap::autoload');
39 39
 
40
-			$extdir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
41
-			self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), false );
40
+			$extdir = dirname(dirname(dirname(dirname(__FILE__))));
41
+			self::$aimeos = new \Aimeos\Bootstrap(array($extdir), false);
42 42
 		}
43 43
 
44 44
 		return self::$aimeos;
@@ -47,88 +47,88 @@  discard block
 block discarded – undo
47 47
 
48 48
 	public static function getJsonadmPaths()
49 49
 	{
50
-		return self::getAimeos()->getCustomPaths( 'admin/jsonadm/templates' );
50
+		return self::getAimeos()->getCustomPaths('admin/jsonadm/templates');
51 51
 	}
52 52
 
53 53
 
54
-	private static function createContext( $site )
54
+	private static function createContext($site)
55 55
 	{
56 56
 		$ctx = new \Aimeos\MShop\Context\Item\Standard();
57 57
 		$aimeos = self::getAimeos();
58 58
 
59 59
 
60
-		$paths = $aimeos->getConfigPaths( 'mysql' );
60
+		$paths = $aimeos->getConfigPaths('mysql');
61 61
 		$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
62 62
 		$file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser';
63 63
 
64
-		$conf = new \Aimeos\MW\Config\PHPArray( [], $paths );
65
-		$conf = new \Aimeos\MW\Config\Decorator\Memory( $conf );
66
-		$conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file );
67
-		$ctx->setConfig( $conf );
64
+		$conf = new \Aimeos\MW\Config\PHPArray([], $paths);
65
+		$conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
66
+		$conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file);
67
+		$ctx->setConfig($conf);
68 68
 
69 69
 
70
-		$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf );
71
-		$ctx->setDatabaseManager( $dbm );
70
+		$dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
71
+		$ctx->setDatabaseManager($dbm);
72 72
 
73 73
 
74
-		$logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG );
75
-		$ctx->setLogger( $logger );
74
+		$logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG);
75
+		$ctx->setLogger($logger);
76 76
 
77 77
 
78 78
 		$session = new \Aimeos\MW\Session\None();
79
-		$ctx->setSession( $session );
79
+		$ctx->setSession($session);
80 80
 
81 81
 
82
-		$i18n = new \Aimeos\MW\Translation\None( 'de' );
83
-		$ctx->setI18n( array( 'de' => $i18n ) );
82
+		$i18n = new \Aimeos\MW\Translation\None('de');
83
+		$ctx->setI18n(array('de' => $i18n));
84 84
 
85 85
 
86
-		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx );
87
-		$locale = $localeManager->bootstrap( $site, 'de', '', false );
88
-		$ctx->setLocale( $locale );
86
+		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
87
+		$locale = $localeManager->bootstrap($site, 'de', '', false);
88
+		$ctx->setLocale($locale);
89 89
 
90 90
 
91
-		$view = self::createView( $conf );
92
-		$ctx->setView( $view );
91
+		$view = self::createView($conf);
92
+		$ctx->setView($view);
93 93
 
94 94
 
95
-		$ctx->setEditor( 'core:admin/jsonadm' );
95
+		$ctx->setEditor('core:admin/jsonadm');
96 96
 
97 97
 		return $ctx;
98 98
 	}
99 99
 
100 100
 
101
-	protected static function createView( \Aimeos\MW\Config\Iface $config )
101
+	protected static function createView(\Aimeos\MW\Config\Iface $config)
102 102
 	{
103
-		$tmplpaths = self::getAimeos()->getCustomPaths( 'admin/jsonadm/templates' );
103
+		$tmplpaths = self::getAimeos()->getCustomPaths('admin/jsonadm/templates');
104 104
 
105
-		$view = new \Aimeos\MW\View\Standard( $tmplpaths );
105
+		$view = new \Aimeos\MW\View\Standard($tmplpaths);
106 106
 
107
-		$helper = new \Aimeos\MW\View\Helper\Access\All( $view );
108
-		$view->addHelper( 'access', $helper );
107
+		$helper = new \Aimeos\MW\View\Helper\Access\All($view);
108
+		$view->addHelper('access', $helper);
109 109
 
110
-		$trans = new \Aimeos\MW\Translation\None( 'de_DE' );
111
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans );
112
-		$view->addHelper( 'translate', $helper );
110
+		$trans = new \Aimeos\MW\Translation\None('de_DE');
111
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans);
112
+		$view->addHelper('translate', $helper);
113 113
 
114
-		$helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' );
115
-		$view->addHelper( 'url', $helper );
114
+		$helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'http://baseurl');
115
+		$view->addHelper('url', $helper);
116 116
 
117
-		$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' );
118
-		$view->addHelper( 'number', $helper );
117
+		$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', '');
118
+		$view->addHelper('number', $helper);
119 119
 
120
-		$helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' );
121
-		$view->addHelper( 'date', $helper );
120
+		$helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d');
121
+		$view->addHelper('date', $helper);
122 122
 
123
-		$config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'admin/jsonadm' ) );
124
-		$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config );
125
-		$view->addHelper( 'config', $helper );
123
+		$config = new \Aimeos\MW\Config\Decorator\Protect($config, array('admin/jsonadm'));
124
+		$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
125
+		$view->addHelper('config', $helper);
126 126
 
127
-		$helper = new \Aimeos\MW\View\Helper\Request\Standard( $view, new \Zend\Diactoros\ServerRequest() );
128
-		$view->addHelper( 'request', $helper );
127
+		$helper = new \Aimeos\MW\View\Helper\Request\Standard($view, new \Zend\Diactoros\ServerRequest());
128
+		$view->addHelper('request', $helper);
129 129
 
130
-		$helper = new \Aimeos\MW\View\Helper\Response\Standard( $view, new \Zend\Diactoros\Response() );
131
-		$view->addHelper( 'response', $helper );
130
+		$helper = new \Aimeos\MW\View\Helper\Response\Standard($view, new \Zend\Diactoros\Response());
131
+		$view->addHelper('response', $helper);
132 132
 
133 133
 		return $view;
134 134
 	}
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Factory.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 	 * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface)
34 34
 	 * @param string $path Path describing the client to clear, e.g. "product/lists/type"
35 35
 	 */
36
-	static public function clear( $id = null, $path = null )
36
+	static public function clear($id = null, $path = null)
37 37
 	{
38
-		if( $id !== null )
38
+		if ($id !== null)
39 39
 		{
40
-			if( $path !== null ) {
40
+			if ($path !== null) {
41 41
 				self::$clients[$id][$path] = null;
42 42
 			} else {
43 43
 				self::$clients[$id] = [];
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
66 66
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid
67 67
 	 */
68
-	static public function createClient( \Aimeos\MShop\Context\Item\Iface $context,
69
-		array $templatePaths, $path, $name = null )
68
+	static public function createClient(\Aimeos\MShop\Context\Item\Iface $context,
69
+		array $templatePaths, $path, $name = null)
70 70
 	{
71
-		$path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) );
71
+		$path = strtolower(trim($path, "/ \n\t\r\0\x0B"));
72 72
 		$id = (string) $context;
73 73
 
74
-		if( self::$cache === false || !isset( self::$clients[$id][$path] ) )
74
+		if (self::$cache === false || !isset(self::$clients[$id][$path]))
75 75
 		{
76
-			if( empty( $path ) ) {
77
-				self::$clients[$id][$path] = self::createClientRoot( $context, $templatePaths, $path, $name );
76
+			if (empty($path)) {
77
+				self::$clients[$id][$path] = self::createClientRoot($context, $templatePaths, $path, $name);
78 78
 			} else {
79
-				self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name );
79
+				self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name);
80 80
 			}
81 81
 		}
82 82
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
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,51 +109,51 @@  discard block
 block discarded – undo
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 115
 		$pname = $name;
116
-		$parts = explode( '/', $path );
116
+		$parts = explode('/', $path);
117 117
 
118
-		foreach( $parts as $key => $part )
118
+		foreach ($parts as $key => $part)
119 119
 		{
120
-			if( ctype_alnum( $part ) === false )
120
+			if (ctype_alnum($part) === false)
121 121
 			{
122
-				$msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path );
123
-				throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 );
122
+				$msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path);
123
+				throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400);
124 124
 			}
125 125
 
126
-			$parts[$key] = ucwords( $part );
126
+			$parts[$key] = ucwords($part);
127 127
 		}
128 128
 
129
-		if( $pname === null ) {
130
-			$pname = $context->getConfig()->get( 'admin/jsonadm/' . $path . '/name', 'Standard' );
129
+		if ($pname === null) {
130
+			$pname = $context->getConfig()->get('admin/jsonadm/' . $path . '/name', 'Standard');
131 131
 		}
132 132
 
133 133
 		$view = $context->getView();
134 134
 		$config = $context->getConfig();
135 135
 
136
-		if( $view->access( $config->get( 'admin/jsonadm/resource/' . $path . '/groups', [] ) ) !== true ) {
137
-			throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Not allowed to access JQAdm "%1$s" client', $path ) );
136
+		if ($view->access($config->get('admin/jsonadm/resource/' . $path . '/groups', [])) !== true) {
137
+			throw new \Aimeos\Admin\JQAdm\Exception(sprintf('Not allowed to access JQAdm "%1$s" client', $path));
138 138
 		}
139 139
 
140 140
 
141 141
 		$view = $context->getView();
142 142
 		$iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';
143
-		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\' . $pname;
143
+		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\' . $pname;
144 144
 
145
-		if( ctype_alnum( $pname ) === false )
145
+		if (ctype_alnum($pname) === false)
146 146
 		{
147
-			$classname = is_string( $pname ) ? $classname : '<not a string>';
148
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
147
+			$classname = is_string($pname) ? $classname : '<not a string>';
148
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
149 149
 		}
150 150
 
151
-		if( class_exists( $classname ) === false ) {
152
-			return self::createClientRoot( $context, $templatePaths, $path, $name );
151
+		if (class_exists($classname) === false) {
152
+			return self::createClientRoot($context, $templatePaths, $path, $name);
153 153
 		}
154 154
 
155
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
156
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
155
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
156
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
157 157
 	}
158 158
 
159 159
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
168 168
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created
169 169
 	 */
170
-	protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context,
171
-		array $templatePaths, $path, $name = null )
170
+	protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context,
171
+		array $templatePaths, $path, $name = null)
172 172
 	{
173 173
 		/** admin/jsonadm/name
174 174
 		 * Class name of the used JSON API client implementation
@@ -203,21 +203,21 @@  discard block
 block discarded – undo
203 203
 		 * @since 2015.12
204 204
 		 * @category Developer
205 205
 		 */
206
-		if( $name === null ) {
207
-			$name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' );
206
+		if ($name === null) {
207
+			$name = $context->getConfig()->get('admin/jsonadm/name', 'Standard');
208 208
 		}
209 209
 
210
-		if( ctype_alnum( $name ) === false )
210
+		if (ctype_alnum($name) === false)
211 211
 		{
212
-			$classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
213
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
212
+			$classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
213
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
214 214
 		}
215 215
 
216 216
 		$view = $context->getView();
217 217
 		$iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';
218 218
 		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name;
219 219
 
220
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
220
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
221 221
 
222 222
 		/** admin/jsonadm/decorators/excludes
223 223
 		 * Excludes decorators added by the "common" option from the JSON API clients
@@ -297,6 +297,6 @@  discard block
 block discarded – undo
297 297
 		 * @see admin/jsonadm/decorators/global
298 298
 		 */
299 299
 
300
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
300
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
301 301
 	}
302 302
 }
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Service/Config/StandardTest.php 1 patch
Spacing   +12 added lines, -12 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\Service\Config\Standard( $this->context, $this->view, $templatePaths, 'service/config' );
25
+		$this->object = new \Aimeos\Admin\JsonAdm\Service\Config\Standard($this->context, $this->view, $templatePaths, 'service/config');
26 26
 	}
27 27
 
28 28
 
@@ -32,20 +32,20 @@  discard block
 block discarded – undo
32 32
 			'id' => 'DirectDebit,Category',
33 33
 			'type' => 'payment',
34 34
 		);
35
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
36
-		$this->view->addHelper( 'param', $helper );
35
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
36
+		$this->view->addHelper('param', $helper);
37 37
 
38
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
39
-		$result = json_decode( (string) $response->getBody(), true );
38
+		$response = $this->object->get($this->view->request(), $this->view->response());
39
+		$result = json_decode((string) $response->getBody(), true);
40 40
 
41
-		$this->assertEquals( 200, $response->getStatusCode() );
42
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
41
+		$this->assertEquals(200, $response->getStatusCode());
42
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
43 43
 
44
-		$this->assertEquals( 2, $result['meta']['total'] );
45
-		$this->assertInternalType( 'array', $result['data'] );
46
-		$this->assertEquals( 'category.include', $result['data'][0]['id'] );
47
-		$this->assertEquals( 'category.exclude', $result['data'][1]['id'] );
44
+		$this->assertEquals(2, $result['meta']['total']);
45
+		$this->assertInternalType('array', $result['data']);
46
+		$this->assertEquals('category.include', $result['data'][0]['id']);
47
+		$this->assertEquals('category.exclude', $result['data'][1]['id']);
48 48
 
49
-		$this->assertArrayNotHasKey( 'errors', $result );
49
+		$this->assertArrayNotHasKey('errors', $result);
50 50
 	}
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Service/Config/Standard.php 1 patch
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/service/config/template-get
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 		$tplconf = 'admin/jsonadm/service/config/template-get';
159 159
 		$default = 'config-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,16 +174,16 @@  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(), 'service' );
184
-		$item = $manager->createItem()->setProvider( $id );
183
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service');
184
+		$item = $manager->createItem()->setProvider($id);
185 185
 
186
-		$view->configItems = $manager->getProvider( $item, $view->param( 'type', 'payment' ) )->getConfigBE();
186
+		$view->configItems = $manager->getProvider($item, $view->param('type', 'payment'))->getConfigBE();
187 187
 
188 188
 		return $response;
189 189
 	}
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Plugin/Config/Standard.php 1 patch
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/plugin/config/template-get
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 		$tplconf = 'admin/jsonadm/plugin/config/template-get';
159 159
 		$default = 'config-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,16 +174,16 @@  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(), 'plugin' );
184
-		$item = $manager->createItem()->setProvider( $id );
183
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'plugin');
184
+		$item = $manager->createItem()->setProvider($id);
185 185
 
186
-		$view->configItems = $manager->getProvider( $item, 'order' )->getConfigBE();
186
+		$view->configItems = $manager->getProvider($item, 'order')->getConfigBE();
187 187
 
188 188
 		return $response;
189 189
 	}
Please login to merge, or discard this patch.