Completed
Push — master ( 5d21ce...a446d4 )
by Aimeos
05:10
created
admin/jsonadm/templates/partials/locale/site/data-standard.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,32 +9,32 @@  discard block
 block discarded – undo
9 9
 
10 10
 
11 11
 $options = 0;
12
-if( defined( 'JSON_PRETTY_PRINT' ) ) {
12
+if (defined('JSON_PRETTY_PRINT')) {
13 13
 	$options = JSON_PRETTY_PRINT;
14 14
 }
15 15
 
16 16
 
17
-$fields = $this->param( 'fields', [] );
17
+$fields = $this->param('fields', []);
18 18
 
19
-foreach( (array) $fields as $resource => $list ) {
20
-	$fields[$resource] = array_flip( explode( ',', $list ) );
19
+foreach ((array) $fields as $resource => $list) {
20
+	$fields[$resource] = array_flip(explode(',', $list));
21 21
 }
22 22
 
23 23
 
24
-$build = function( \Aimeos\MShop\Locale\Item\Site\Iface $item ) use ( $fields )
24
+$build = function(\Aimeos\MShop\Locale\Item\Site\Iface $item) use ($fields)
25 25
 {
26 26
 	$id = $item->getId();
27 27
 	$type = $item->getResourceType();
28
-	$params = array( 'resource' => $type, 'id' => $id );
29
-	$attributes = $item->toArray( true );
28
+	$params = array('resource' => $type, 'id' => $id);
29
+	$attributes = $item->toArray(true);
30 30
 
31
-	$target = $this->config( 'admin/jsonadm/url/target' );
32
-	$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' );
33
-	$action = $this->config( 'admin/jsonadm/url/action', 'get' );
34
-	$config = $this->config( 'admin/jsonadm/url/config', [] );
31
+	$target = $this->config('admin/jsonadm/url/target');
32
+	$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm');
33
+	$action = $this->config('admin/jsonadm/url/action', 'get');
34
+	$config = $this->config('admin/jsonadm/url/config', []);
35 35
 
36
-	if( isset( $fields[$type] ) ) {
37
-		$attributes = array_intersect_key( $attributes, $fields[$type] );
36
+	if (isset($fields[$type])) {
37
+		$attributes = array_intersect_key($attributes, $fields[$type]);
38 38
 	}
39 39
 
40 40
 	$result = array(
@@ -42,34 +42,34 @@  discard block
 block discarded – undo
42 42
 		'type' => $type,
43 43
 		'attributes' => $attributes,
44 44
 		'links' => array(
45
-			'self' => $this->url( $target, $cntl, $action, $params, [], $config )
45
+			'self' => $this->url($target, $cntl, $action, $params, [], $config)
46 46
 		),
47 47
 		'relationships' => []
48 48
 	);
49 49
 
50
-	foreach( $item->getChildren() as $childItem )
50
+	foreach ($item->getChildren() as $childItem)
51 51
 	{
52 52
 		$type = $childItem->getResourceType();
53
-		$result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) );
53
+		$result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type));
54 54
 	}
55 55
 
56 56
 	return $result;
57 57
 };
58 58
 
59 59
 
60
-$data = $this->get( 'data', [] );
60
+$data = $this->get('data', []);
61 61
 
62
-if( is_array( $data ) )
62
+if (is_array($data))
63 63
 {
64 64
 	$response = [];
65 65
 
66
-	foreach( $data as $item ) {
67
-		$response[] = $build( $item );
66
+	foreach ($data as $item) {
67
+		$response[] = $build($item);
68 68
 	}
69 69
 }
70
-elseif( $data !== null )
70
+elseif ($data !== null)
71 71
 {
72
-	$response = $build( $data );
72
+	$response = $build($data);
73 73
 }
74 74
 else
75 75
 {
@@ -77,4 +77,4 @@  discard block
 block discarded – undo
77 77
 }
78 78
 
79 79
 
80
-echo json_encode( $response, $options );
81 80
\ No newline at end of file
81
+echo json_encode($response, $options);
82 82
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,12 +66,10 @@
 block discarded – undo
66 66
 	foreach( $data as $item ) {
67 67
 		$response[] = $build( $item );
68 68
 	}
69
-}
70
-elseif( $data !== null )
69
+} elseif( $data !== null )
71 70
 {
72 71
 	$response = $build( $data );
73
-}
74
-else
72
+} else
75 73
 {
76 74
 	$response = null;
77 75
 }
Please login to merge, or discard this patch.
admin/jsonadm/templates/put-default.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@
 block discarded – undo
10 10
 
11 11
 ?>
12 12
 {
13
-	<?php if( isset( $this->errors ) ) : ?>
13
+	<?php if (isset($this->errors)) : ?>
14 14
 
15
-		"errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
15
+		"errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
16 16
 
17 17
 	<?php endif; ?>
18 18
 
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/FactoryTest.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 		$context = \TestHelperJadm::getContext();
17 17
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
18 18
 
19
-		$client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
20
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
21
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Order\\Standard', $client );
19
+		$client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order');
20
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client);
21
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Order\\Standard', $client);
22 22
 	}
23 23
 
24 24
 
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 		$context = \TestHelperJadm::getContext();
28 28
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
29 29
 
30
-		$client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
31
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
32
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Order\\Base\\Standard', $client );
30
+		$client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base');
31
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client);
32
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Order\\Base\\Standard', $client);
33 33
 	}
34 34
 
35 35
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 		$context = \TestHelperJadm::getContext();
39 39
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
40 40
 
41
-		$client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'stock/type' );
42
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
43
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Standard', $client );
41
+		$client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'stock/type');
42
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client);
43
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Standard', $client);
44 44
 	}
45 45
 
46 46
 
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 		$context = \TestHelperJadm::getContext();
50 50
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
51 51
 
52
-		$client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '' );
53
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
54
-		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Standard', $client );
52
+		$client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '');
53
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client);
54
+		$this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Standard', $client);
55 55
 	}
56 56
 
57 57
 
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 		$context = \TestHelperJadm::getContext();
61 61
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
62 62
 
63
-		$this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' );
64
-		\Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '%^' );
63
+		$this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception');
64
+		\Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '%^');
65 65
 	}
66 66
 
67 67
 
@@ -70,68 +70,68 @@  discard block
 block discarded – undo
70 70
 		$context = \TestHelperJadm::getContext();
71 71
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
72 72
 
73
-		$this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' );
74
-		\Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '', '%^' );
73
+		$this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception');
74
+		\Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '', '%^');
75 75
 	}
76 76
 
77 77
 
78 78
 	public function testClear()
79 79
 	{
80
-		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true );
80
+		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true);
81 81
 
82 82
 		$context = \TestHelperJadm::getContext();
83 83
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
84 84
 
85
-		$client1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
85
+		$client1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order');
86 86
 		\Aimeos\Admin\JsonAdm\Factory::clear();
87
-		$client2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
87
+		$client2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order');
88 88
 
89
-		\Aimeos\Admin\JsonAdm\Factory::setCache( $cache );
89
+		\Aimeos\Admin\JsonAdm\Factory::setCache($cache);
90 90
 
91
-		$this->assertNotSame( $client1, $client2 );
91
+		$this->assertNotSame($client1, $client2);
92 92
 	}
93 93
 
94 94
 
95 95
 	public function testClearSite()
96 96
 	{
97
-		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true );
97
+		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true);
98 98
 
99 99
 		$context = \TestHelperJadm::getContext();
100 100
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
101 101
 
102
-		$cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
103
-		$cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
104
-		\Aimeos\Admin\JsonAdm\Factory::clear( (string) $context );
102
+		$cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order');
103
+		$cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base');
104
+		\Aimeos\Admin\JsonAdm\Factory::clear((string) $context);
105 105
 
106
-		$cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
107
-		$cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
106
+		$cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order');
107
+		$cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base');
108 108
 
109
-		\Aimeos\Admin\JsonAdm\Factory::setCache( $cache );
109
+		\Aimeos\Admin\JsonAdm\Factory::setCache($cache);
110 110
 
111
-		$this->assertNotSame( $cntlA1, $cntlA2 );
112
-		$this->assertNotSame( $cntlB1, $cntlB2 );
111
+		$this->assertNotSame($cntlA1, $cntlA2);
112
+		$this->assertNotSame($cntlB1, $cntlB2);
113 113
 	}
114 114
 
115 115
 
116 116
 	public function testClearSpecific()
117 117
 	{
118
-		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true );
118
+		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true);
119 119
 
120 120
 		$context = \TestHelperJadm::getContext();
121 121
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
122 122
 
123
-		$cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
124
-		$cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
123
+		$cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order');
124
+		$cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base');
125 125
 
126
-		\Aimeos\Admin\JsonAdm\Factory::clear( (string) $context, 'order' );
126
+		\Aimeos\Admin\JsonAdm\Factory::clear((string) $context, 'order');
127 127
 
128
-		$cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
129
-		$cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
128
+		$cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order');
129
+		$cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base');
130 130
 
131
-		\Aimeos\Admin\JsonAdm\Factory::setCache( $cache );
131
+		\Aimeos\Admin\JsonAdm\Factory::setCache($cache);
132 132
 
133
-		$this->assertNotSame( $cntlA1, $cntlA2 );
134
-		$this->assertSame( $cntlB1, $cntlB2 );
133
+		$this->assertNotSame($cntlA1, $cntlA2);
134
+		$this->assertSame($cntlB1, $cntlB2);
135 135
 	}
136 136
 
137 137
 }
138 138
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Factory.php 1 patch
Spacing   +38 added lines, -38 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,14 +65,14 @@  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] ) ) {
75
-			self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name );
74
+		if (self::$cache === false || !isset(self::$clients[$id][$path])) {
75
+			self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name);
76 76
 		}
77 77
 
78 78
 		return self::$clients[$id][$path];
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @param boolean $value True to enable caching, false to disable it.
86 86
 	 * @return boolean Previous cache setting
87 87
 	 */
88
-	static public function setCache( $value )
88
+	static public function setCache($value)
89 89
 	{
90 90
 		$old = self::$cache;
91 91
 		self::$cache = (boolean) $value;
@@ -104,49 +104,49 @@  discard block
 block discarded – undo
104 104
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
105 105
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid
106 106
 	 */
107
-	protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context,
108
-		array $templatePaths, $path, $name )
107
+	protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context,
108
+		array $templatePaths, $path, $name)
109 109
 	{
110
-		if( empty( $path ) ) {
111
-			return self::createClientRoot( $context, $templatePaths, $path, $name );
110
+		if (empty($path)) {
111
+			return self::createClientRoot($context, $templatePaths, $path, $name);
112 112
 		}
113 113
 
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
 
134 134
 		$view = $context->getView();
135 135
 		$iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';
136
-		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\' . $pname;
136
+		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\' . $pname;
137 137
 
138
-		if( ctype_alnum( $pname ) === false )
138
+		if (ctype_alnum($pname) === false)
139 139
 		{
140
-			$classname = is_string( $pname ) ? $classname : '<not a string>';
141
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
140
+			$classname = is_string($pname) ? $classname : '<not a string>';
141
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
142 142
 		}
143 143
 
144
-		if( class_exists( $classname ) === false ) {
145
-			return self::createClientRoot( $context, $templatePaths, $path, $name );
144
+		if (class_exists($classname) === false) {
145
+			return self::createClientRoot($context, $templatePaths, $path, $name);
146 146
 		}
147 147
 
148
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
149
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
148
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
149
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
150 150
 	}
151 151
 
152 152
 
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
161 161
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created
162 162
 	 */
163
-	protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context,
164
-		array $templatePaths, $path, $name = null )
163
+	protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context,
164
+		array $templatePaths, $path, $name = null)
165 165
 	{
166 166
 		/** admin/jsonadm/name
167 167
 		 * Class name of the used JSON API client implementation
@@ -196,21 +196,21 @@  discard block
 block discarded – undo
196 196
 		 * @since 2015.12
197 197
 		 * @category Developer
198 198
 		 */
199
-		if( $name === null ) {
200
-			$name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' );
199
+		if ($name === null) {
200
+			$name = $context->getConfig()->get('admin/jsonadm/name', 'Standard');
201 201
 		}
202 202
 
203
-		if( ctype_alnum( $name ) === false )
203
+		if (ctype_alnum($name) === false)
204 204
 		{
205
-			$classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
206
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
205
+			$classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
206
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
207 207
 		}
208 208
 
209 209
 		$view = $context->getView();
210 210
 		$iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';
211 211
 		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name;
212 212
 
213
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
213
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
214 214
 
215 215
 		/** admin/jsonadm/decorators/excludes
216 216
 		 * Excludes decorators added by the "common" option from the JSON API clients
@@ -290,6 +290,6 @@  discard block
 block discarded – undo
290 290
 		 * @see admin/jsonadm/decorators/global
291 291
 		 */
292 292
 
293
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
293
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
294 294
 	}
295 295
 }
Please login to merge, or discard this patch.
admin/jsonadm/templates/options-default.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,32 +8,32 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 
11
-$target = $this->config( 'admin/jsonadm/url/target' );
12
-$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' );
13
-$action = $this->config( 'admin/jsonadm/url/action', 'get' );
14
-$config = $this->config( 'admin/jsonadm/url/config', [] );
11
+$target = $this->config('admin/jsonadm/url/target');
12
+$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm');
13
+$action = $this->config('admin/jsonadm/url/action', 'get');
14
+$config = $this->config('admin/jsonadm/url/config', []);
15 15
 
16 16
 
17 17
 $resources = $attributes = [];
18
-$site = $this->param( 'site', 'default' );
18
+$site = $this->param('site', 'default');
19 19
 
20
-foreach( $this->get( 'resources', [] ) as $resource ) {
21
-	$resources[$resource] = $this->url( $target, $cntl, $action, ['site' => $site, 'resource' => $resource], [], $config );
20
+foreach ($this->get('resources', []) as $resource) {
21
+	$resources[$resource] = $this->url($target, $cntl, $action, ['site' => $site, 'resource' => $resource], [], $config);
22 22
 }
23 23
 
24
-foreach( $this->get( 'attributes', [] ) as $attr ) {
25
-	$attributes[$attr->getCode()] = $attr->toArray( true );
24
+foreach ($this->get('attributes', []) as $attr) {
25
+	$attributes[$attr->getCode()] = $attr->toArray(true);
26 26
 }
27 27
 
28 28
 
29 29
 ?>
30 30
 {
31 31
 	"meta": {
32
-		"prefix": <?= json_encode( $this->get( 'prefix' ) ); ?>,
33
-		"resources": <?= json_encode( $resources ); ?>,
34
-		"attributes": <?= json_encode( $attributes ); ?>
32
+		"prefix": <?= json_encode($this->get('prefix')); ?>,
33
+		"resources": <?= json_encode($resources); ?>,
34
+		"attributes": <?= json_encode($attributes); ?>
35 35
 
36
-		<?php if( $this->csrf()->name() != '' ) : ?>
36
+		<?php if ($this->csrf()->name() != '') : ?>
37 37
 			, "csrf": {
38 38
 				"name": "<?= $this->csrf()->name(); ?>",
39 39
 				"value": "<?= $this->csrf()->value(); ?>"
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 		<?php endif; ?>
42 42
 	}
43 43
 
44
-	<?php if( isset( $this->errors ) ) : ?>
44
+	<?php if (isset($this->errors)) : ?>
45 45
 
46
-		,"errors": <?= $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
46
+		,"errors": <?= $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
47 47
 
48 48
 	<?php endif; ?>
49 49
 
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Locale/Site/StandardTest.php 1 patch
Spacing   +75 added lines, -75 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\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
 
@@ -30,153 +30,153 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$params = array(
32 32
 			'filter' => array(
33
-				'==' => array( 'locale.site.code' => 'unittest' )
33
+				'==' => array('locale.site.code' => 'unittest')
34 34
 			),
35 35
 		);
36
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
37
-		$this->view->addHelper( 'param', $helper );
36
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
37
+		$this->view->addHelper('param', $helper);
38 38
 
39
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
40
-		$result = json_decode( (string) $response->getBody(), true );
39
+		$response = $this->object->get($this->view->request(), $this->view->response());
40
+		$result = json_decode((string) $response->getBody(), true);
41 41
 
42 42
 
43
-		$this->assertEquals( 200, $response->getStatusCode() );
44
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
43
+		$this->assertEquals(200, $response->getStatusCode());
44
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
45 45
 
46
-		$this->assertEquals( 1, $result['meta']['total'] );
47
-		$this->assertEquals( 1, count( $result['data'] ) );
48
-		$this->assertEquals( 'locale/site', $result['data'][0]['type'] );
49
-		$this->assertEquals( 0, count( $result['included'] ) );
46
+		$this->assertEquals(1, $result['meta']['total']);
47
+		$this->assertEquals(1, count($result['data']));
48
+		$this->assertEquals('locale/site', $result['data'][0]['type']);
49
+		$this->assertEquals(0, count($result['included']));
50 50
 
51
-		$this->assertArrayNotHasKey( 'errors', $result );
51
+		$this->assertArrayNotHasKey('errors', $result);
52 52
 	}
53 53
 
54 54
 
55 55
 	public function testGetTree()
56 56
 	{
57 57
 		$params = array(
58
-			'id' => $this->getSiteItem( 'unittest' )->getId(),
58
+			'id' => $this->getSiteItem('unittest')->getId(),
59 59
 			'filter' => array(
60
-				'==' => array( 'locale.status' => 0 )
60
+				'==' => array('locale.status' => 0)
61 61
 			),
62 62
 			'include' => 'locale/site'
63 63
 		);
64
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
65
-		$this->view->addHelper( 'param', $helper );
64
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
65
+		$this->view->addHelper('param', $helper);
66 66
 
67
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
68
-		$result = json_decode( (string) $response->getBody(), true );
67
+		$response = $this->object->get($this->view->request(), $this->view->response());
68
+		$result = json_decode((string) $response->getBody(), true);
69 69
 
70 70
 
71
-		$this->assertEquals( 200, $response->getStatusCode() );
72
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
71
+		$this->assertEquals(200, $response->getStatusCode());
72
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
73 73
 
74
-		$this->assertEquals( 1, $result['meta']['total'] );
75
-		$this->assertEquals( 'locale/site', $result['data']['type'] );
76
-		$this->assertEquals( 0, count( $result['included'] ) );
74
+		$this->assertEquals(1, $result['meta']['total']);
75
+		$this->assertEquals('locale/site', $result['data']['type']);
76
+		$this->assertEquals(0, count($result['included']));
77 77
 
78
-		$this->assertArrayNotHasKey( 'errors', $result );
78
+		$this->assertArrayNotHasKey('errors', $result);
79 79
 	}
80 80
 
81 81
 
82 82
 	public function testPatch()
83 83
 	{
84
-		$stub = $this->getSiteMock( array( 'getItem', 'moveItem', 'saveItem' ) );
84
+		$stub = $this->getSiteMock(array('getItem', 'moveItem', 'saveItem'));
85 85
 		$item = $stub->createItem();
86 86
 
87
-		$stub->expects( $this->once() )->method( 'moveItem' );
88
-		$stub->expects( $this->once() )->method( 'saveItem' )
89
-			->will( $this->returnValue( $stub->createItem() ) );
90
-		$stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator
91
-			->will( $this->returnValue( $item ) );
87
+		$stub->expects($this->once())->method('moveItem');
88
+		$stub->expects($this->once())->method('saveItem')
89
+			->will($this->returnValue($stub->createItem()));
90
+		$stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator
91
+			->will($this->returnValue($item));
92 92
 
93 93
 
94
-		$params = array( 'id' => '-1' );
95
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
96
-		$this->view->addHelper( 'param', $helper );
94
+		$params = array('id' => '-1');
95
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
96
+		$this->view->addHelper('param', $helper);
97 97
 
98 98
 		$body = '{"data": {"parentid": "1", "targetid": 2, "type": "locale/site", "attributes": {"locale.site.label": "test"}}}';
99
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
99
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
100 100
 
101
-		$response = $this->object->patch( $request, $this->view->response() );
102
-		$result = json_decode( (string) $response->getBody(), true );
101
+		$response = $this->object->patch($request, $this->view->response());
102
+		$result = json_decode((string) $response->getBody(), true);
103 103
 
104 104
 
105
-		$this->assertEquals( 200, $response->getStatusCode() );
106
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
105
+		$this->assertEquals(200, $response->getStatusCode());
106
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
107 107
 
108
-		$this->assertEquals( 1, $result['meta']['total'] );
109
-		$this->assertArrayHasKey( 'data', $result );
110
-		$this->assertEquals( 'locale/site', $result['data']['type'] );
108
+		$this->assertEquals(1, $result['meta']['total']);
109
+		$this->assertArrayHasKey('data', $result);
110
+		$this->assertEquals('locale/site', $result['data']['type']);
111 111
 
112
-		$this->assertArrayNotHasKey( 'included', $result );
113
-		$this->assertArrayNotHasKey( 'errors', $result );
112
+		$this->assertArrayNotHasKey('included', $result);
113
+		$this->assertArrayNotHasKey('errors', $result);
114 114
 	}
115 115
 
116 116
 
117 117
 	public function testPost()
118 118
 	{
119
-		$stub = $this->getSiteMock( array( 'getItem', 'insertItem' ) );
119
+		$stub = $this->getSiteMock(array('getItem', 'insertItem'));
120 120
 		$item = $stub->createItem();
121 121
 
122
-		$stub->expects( $this->any() )->method( 'getItem' )
123
-			->will( $this->returnValue( $item ) );
124
-		$stub->expects( $this->once() )->method( 'insertItem' );
122
+		$stub->expects($this->any())->method('getItem')
123
+			->will($this->returnValue($item));
124
+		$stub->expects($this->once())->method('insertItem');
125 125
 
126 126
 
127 127
 		$body = '{"data": {"type": "locale/site", "attributes": {"locale.site.code": "unittest", "locale.site.label": "Unit test"}}}';
128
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
128
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
129 129
 
130
-		$response = $this->object->post( $request, $this->view->response() );
131
-		$result = json_decode( (string) $response->getBody(), true );
130
+		$response = $this->object->post($request, $this->view->response());
131
+		$result = json_decode((string) $response->getBody(), true);
132 132
 
133 133
 
134
-		$this->assertEquals( 201, $response->getStatusCode() );
135
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
134
+		$this->assertEquals(201, $response->getStatusCode());
135
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
136 136
 
137
-		$this->assertEquals( 1, $result['meta']['total'] );
138
-		$this->assertArrayHasKey( 'data', $result );
139
-		$this->assertEquals( 'locale/site', $result['data']['type'] );
137
+		$this->assertEquals(1, $result['meta']['total']);
138
+		$this->assertArrayHasKey('data', $result);
139
+		$this->assertEquals('locale/site', $result['data']['type']);
140 140
 
141
-		$this->assertArrayNotHasKey( 'included', $result );
142
-		$this->assertArrayNotHasKey( 'errors', $result );
141
+		$this->assertArrayNotHasKey('included', $result);
142
+		$this->assertArrayNotHasKey('errors', $result);
143 143
 	}
144 144
 
145 145
 
146
-	protected function getSiteItem( $code )
146
+	protected function getSiteItem($code)
147 147
 	{
148
-		$manager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $this->context )->getSubManager( 'site' );
148
+		$manager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->context)->getSubManager('site');
149 149
 		$search = $manager->createSearch();
150
-		$search->setConditions( $search->compare( '==', 'locale.site.code', $code ) );
151
-		$items = $manager->searchItems( $search );
150
+		$search->setConditions($search->compare('==', 'locale.site.code', $code));
151
+		$items = $manager->searchItems($search);
152 152
 
153
-		if( ( $item = reset( $items ) ) === false ) {
154
-			throw new \RuntimeException( sprintf( 'No locale site item with code "%1$s" found', $code ) );
153
+		if (($item = reset($items)) === false) {
154
+			throw new \RuntimeException(sprintf('No locale site item with code "%1$s" found', $code));
155 155
 		}
156 156
 
157 157
 		return $item;
158 158
 	}
159 159
 
160 160
 
161
-	protected function getSiteMock( array $methods )
161
+	protected function getSiteMock(array $methods)
162 162
 	{
163 163
 		$name = 'ClientJsonAdmStandard';
164
-		$this->context->getConfig()->set( 'mshop/locale/manager/name', $name );
164
+		$this->context->getConfig()->set('mshop/locale/manager/name', $name);
165 165
 
166
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Standard' )
167
-			->setConstructorArgs( array( $this->context ) )
168
-			->setMethods( array( 'getSubManager' ) )
166
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Standard')
167
+			->setConstructorArgs(array($this->context))
168
+			->setMethods(array('getSubManager'))
169 169
 			->getMock();
170 170
 
171
-		$siteStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard' )
172
-			->setConstructorArgs( array( $this->context ) )
173
-			->setMethods( $methods )
171
+		$siteStub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard')
172
+			->setConstructorArgs(array($this->context))
173
+			->setMethods($methods)
174 174
 			->getMock();
175 175
 
176
-		$stub->expects( $this->once() )->method( 'getSubManager' )
177
-			->will( $this->returnValue( $siteStub ) );
176
+		$stub->expects($this->once())->method('getSubManager')
177
+			->will($this->returnValue($siteStub));
178 178
 
179
-		\Aimeos\MShop\Locale\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub );
179
+		\Aimeos\MShop\Locale\Manager\Factory::injectManager('\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub);
180 180
 
181 181
 		return $siteStub;
182 182
 	}
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Coupon/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\Coupon\Config\Standard( $this->context, $this->view, $templatePaths, 'coupon/config' );
25
+		$this->object = new \Aimeos\Admin\JsonAdm\Coupon\Config\Standard($this->context, $this->view, $templatePaths, 'coupon/config');
26 26
 	}
27 27
 
28 28
 
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 		$params = array(
32 32
 			'id' => 'Example,Required,BasketValues',
33 33
 		);
34
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
35
-		$this->view->addHelper( 'param', $helper );
34
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
35
+		$this->view->addHelper('param', $helper);
36 36
 
37
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
38
-		$result = json_decode( (string) $response->getBody(), true );
37
+		$response = $this->object->get($this->view->request(), $this->view->response());
38
+		$result = json_decode((string) $response->getBody(), true);
39 39
 
40
-		$this->assertEquals( 200, $response->getStatusCode() );
41
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
40
+		$this->assertEquals(200, $response->getStatusCode());
41
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
42 42
 
43
-		$this->assertEquals( 2, $result['meta']['total'] );
44
-		$this->assertInternalType( 'array', $result['data'] );
45
-		$this->assertEquals( 'basketvalues.total-value-min', $result['data'][0]['id'] );
46
-		$this->assertEquals( 'basketvalues.total-value-max', $result['data'][1]['id'] );
43
+		$this->assertEquals(2, $result['meta']['total']);
44
+		$this->assertInternalType('array', $result['data']);
45
+		$this->assertEquals('basketvalues.total-value-min', $result['data'][0]['id']);
46
+		$this->assertEquals('basketvalues.total-value-max', $result['data'][1]['id']);
47 47
 
48
-		$this->assertArrayNotHasKey( 'errors', $result );
48
+		$this->assertArrayNotHasKey('errors', $result);
49 49
 	}
50 50
 }
51 51
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Coupon/Config/Standard.php 2 patches
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.
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 = '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,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.
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.