Completed
Push — master ( ac109f...19c432 )
by Aimeos
05:47
created
client/jsonapi/templates/error-default.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 {
2
-<?php if( isset( $this->errors ) ) : ?>
3
-	"errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?>
2
+<?php if (isset($this->errors)) : ?>
3
+	"errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?>
4 4
 <?php endif; ?>
5 5
 
6 6
 }
Please login to merge, or discard this patch.
client/jsonapi/templates/catalog/get-default.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -8,38 +8,38 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 
11
-$target = $this->config( 'client/jsonapi/url/target' );
12
-$cntl = $this->config( 'client/jsonapi/url/controller', 'jsonapi' );
13
-$action = $this->config( 'client/jsonapi/url/action', 'get' );
14
-$config = $this->config( 'client/jsonapi/url/config', array() );
11
+$target = $this->config('client/jsonapi/url/target');
12
+$cntl = $this->config('client/jsonapi/url/controller', 'jsonapi');
13
+$action = $this->config('client/jsonapi/url/action', 'get');
14
+$config = $this->config('client/jsonapi/url/config', array());
15 15
 
16 16
 
17 17
 $view = $this;
18 18
 $enc = $this->encoder();
19 19
 
20
-$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' );
21
-$params = array_intersect_key( $this->param(), array_flip( $ref ) );
20
+$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields');
21
+$params = array_intersect_key($this->param(), array_flip($ref));
22 22
 
23
-$offset = max( $this->param( 'page/offset', 0 ), 0 );
24
-$limit = max( $this->param( 'page/limit', 100 ), 1 );
23
+$offset = max($this->param('page/offset', 0), 0);
24
+$limit = max($this->param('page/limit', 100), 1);
25 25
 
26 26
 
27
-$map = $this->get( 'itemMap', array() );
28
-$fields = $this->param( 'fields', array() );
27
+$map = $this->get('itemMap', array());
28
+$fields = $this->param('fields', array());
29 29
 
30
-foreach( (array) $fields as $resource => $list ) {
31
-	$fields[$resource] = array_flip( explode( ',', $list ) );
30
+foreach ((array) $fields as $resource => $list) {
31
+	$fields[$resource] = array_flip(explode(',', $list));
32 32
 }
33 33
 
34 34
 
35
-$entryFcn = function( \Aimeos\MShop\Catalog\Item\Iface $item ) use ( $fields, $view, $target, $cntl, $action, $config )
35
+$entryFcn = function(\Aimeos\MShop\Catalog\Item\Iface $item) use ($fields, $view, $target, $cntl, $action, $config)
36 36
 {
37 37
 	$attributes = $item->toArray();
38 38
 	$type = $item->getResourceType();
39
-	$params = array( 'resource' => $type, 'id' => $item->getId() );
39
+	$params = array('resource' => $type, 'id' => $item->getId());
40 40
 
41
-	if( isset( $fields[$type] ) ) {
42
-		$attributes = array_intersect_key( $attributes, $fields[$type] );
41
+	if (isset($fields[$type])) {
42
+		$attributes = array_intersect_key($attributes, $fields[$type]);
43 43
 	}
44 44
 
45 45
 	$entry = array(
@@ -47,24 +47,24 @@  discard block
 block discarded – undo
47 47
 		'type' => $item->getResourceType(),
48 48
 		'links' => array(
49 49
 			'self' => array(
50
-				'href' => $view->url( $target, $cntl, $action, $params, array(), $config ),
51
-				'allow' => array( 'GET' ),
50
+				'href' => $view->url($target, $cntl, $action, $params, array(), $config),
51
+				'allow' => array('GET'),
52 52
 			),
53 53
 		),
54 54
 		'attributes' => $attributes,
55 55
 	);
56 56
 
57
-	foreach( $item->getChildren() as $catItem ) {
58
-		$entry['relationships']['catalog']['data'][] = array( 'id' => $catItem->getId(), 'type' => 'catalog' );
57
+	foreach ($item->getChildren() as $catItem) {
58
+		$entry['relationships']['catalog']['data'][] = array('id' => $catItem->getId(), 'type' => 'catalog');
59 59
 	}
60 60
 
61
-	if( $item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface )
61
+	if ($item instanceof \Aimeos\MShop\Common\Item\ListRef\Iface)
62 62
 	{
63
-		foreach( $item->getListItems() as $listItem )
63
+		foreach ($item->getListItems() as $listItem)
64 64
 		{
65 65
 			$domain = $listItem->getDomain();
66 66
 
67
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
67
+			if (($refItem = $listItem->getRefItem()) !== null) {
68 68
 				$entry['attributes'][$domain][] = $refItem->toArray() + $listItem->toArray();
69 69
 			}
70 70
 
@@ -78,31 +78,31 @@  discard block
 block discarded – undo
78 78
 ?>
79 79
 {
80 80
 	"meta": {
81
-		"total": <?php echo ( isset( $this->items ) ? 1 : 0 ); ?>
81
+		"total": <?php echo (isset($this->items) ? 1 : 0); ?>
82 82
 
83 83
 	},
84 84
 
85 85
 	"links": {
86
-		"self": "<?php echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>"
86
+		"self": "<?php echo $this->url($target, $cntl, $action, $params, array(), $config); ?>"
87 87
 	},
88 88
 
89
-	<?php if( isset( $this->errors ) ) : ?>
89
+	<?php if (isset($this->errors)) : ?>
90 90
 
91
-		"errors": <?php echo json_encode( $this->errors, JSON_PRETTY_PRINT ); ?>
91
+		"errors": <?php echo json_encode($this->errors, JSON_PRETTY_PRINT); ?>
92 92
 
93
-	<?php elseif( isset( $this->items ) ) : ?>
93
+	<?php elseif (isset($this->items)) : ?>
94 94
 
95 95
 		<?php
96 96
 			$included = array();
97 97
 
98
-			foreach( $this->items->getChildren() as $catItem ) {
99
-				$included[] = $entryFcn( $catItem );
98
+			foreach ($this->items->getChildren() as $catItem) {
99
+				$included[] = $entryFcn($catItem);
100 100
 			}
101 101
 		 ?>
102 102
 
103
-		"data": <?php echo json_encode( $entryFcn( $this->items ) ); ?>,
103
+		"data": <?php echo json_encode($entryFcn($this->items)); ?>,
104 104
 
105
-		"included": <?php echo json_encode( $included ); ?>
105
+		"included": <?php echo json_encode($included); ?>
106 106
 
107 107
 	<?php endif; ?>
108 108
 
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Catalog/Standard.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
32 32
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
33 33
 	 */
34
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
34
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
35 35
 	{
36 36
 		$view = $this->getView();
37 37
 
38 38
 		try
39 39
 		{
40
-			$response = $this->getItem( $view, $request, $response );
40
+			$response = $this->getItem($view, $request, $response);
41 41
 			$status = 200;
42 42
 		}
43
-		catch( \Aimeos\MShop\Exception $e )
43
+		catch (\Aimeos\MShop\Exception $e)
44 44
 		{
45 45
 			$status = 404;
46
-			$view->errors = array( array(
47
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
46
+			$view->errors = array(array(
47
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
48 48
 				'detail' => $e->getTraceAsString(),
49
-			) );
49
+			));
50 50
 		}
51
-		catch( \Exception $e )
51
+		catch (\Exception $e)
52 52
 		{
53 53
 			$status = 500;
54
-			$view->errors = array( array(
54
+			$view->errors = array(array(
55 55
 				'title' => $e->getMessage(),
56 56
 				'detail' => $e->getTraceAsString(),
57
-			) );
57
+			));
58 58
 		}
59 59
 
60 60
 		/** client/jsonapi/catalog/standard/template-get
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 		$tplconf = 'client/jsonapi/catalog/standard/template-get';
80 80
 		$default = 'catalog/get-default.php';
81 81
 
82
-		$body = $view->render( $view->config( $tplconf, $default ) );
82
+		$body = $view->render($view->config($tplconf, $default));
83 83
 
84
-		return $response->withHeader( 'Allow', 'GET' )
85
-			->withHeader( 'Content-Type', 'application/vnd.api+json' )
86
-			->withBody( $view->response()->createStreamFromString( $body ) )
87
-			->withStatus( $status );
84
+		return $response->withHeader('Allow', 'GET')
85
+			->withHeader('Content-Type', 'application/vnd.api+json')
86
+			->withBody($view->response()->createStreamFromString($body))
87
+			->withStatus($status);
88 88
 	}
89 89
 
90 90
 
@@ -96,32 +96,32 @@  discard block
 block discarded – undo
96 96
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
97 97
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
98 98
 	 */
99
-	protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
99
+	protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
100 100
 	{
101 101
 		$map = array();
102
-		$catId = $view->param( 'id' );
103
-		$ref = $view->param( 'include', array() );
102
+		$catId = $view->param('id');
103
+		$ref = $view->param('include', array());
104 104
 		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
105 105
 
106
-		if( $catId == '' ) {
106
+		if ($catId == '') {
107 107
 			$catId = null;
108 108
 		}
109 109
 
110
-		if( is_string( $ref ) ) {
111
-			$ref = explode( ',', $ref );
110
+		if (is_string($ref)) {
111
+			$ref = explode(',', $ref);
112 112
 		}
113 113
 
114
-		if( in_array( 'catalog', $ref, true ) ) {
114
+		if (in_array('catalog', $ref, true)) {
115 115
 			$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST;
116 116
 		}
117 117
 
118 118
 		$context = $this->getContext();
119
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
119
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'catalog');
120 120
 
121 121
 		$filter = $cntl->createFilter();
122
-		$filter = $this->initCriteria( $filter, $view->param() );
122
+		$filter = $this->initCriteria($filter, $view->param());
123 123
 
124
-		$view->items = $cntl->getTree( $catId, $ref, $level, $filter );
124
+		$view->items = $cntl->getTree($catId, $ref, $level, $filter);
125 125
 
126 126
 		return $response;
127 127
 	}
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Catalog/Factory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @return \Aimeos\Client\JsonApi\Iface JSON API client
32 32
 	 * @throws \Aimeos\Client\JsonApi\Exception If requested client implementation couldn't be found or initialisation fails
33 33
 	 */
34
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null )
34
+	public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null)
35 35
 	{
36
-		if( ctype_alnum( $path ) === false )
36
+		if (ctype_alnum($path) === false)
37 37
 		{
38
-			$path = ( is_string( $path ) ? $path : '<not a string>' );
39
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid client "%1$s"', $path ), 400 );
38
+			$path = (is_string($path) ? $path : '<not a string>');
39
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid client "%1$s"', $path), 400);
40 40
 		}
41 41
 
42 42
 		/** client/jsonapi/catalog/name
@@ -72,23 +72,23 @@  discard block
 block discarded – undo
72 72
 		 * @since 2017.03
73 73
 		 * @category Developer
74 74
 		 */
75
-		if( $name === null ) {
76
-			$name = $context->getConfig()->get( 'client/jsonapi/catalog/name', 'Standard' );
75
+		if ($name === null) {
76
+			$name = $context->getConfig()->get('client/jsonapi/catalog/name', 'Standard');
77 77
 		}
78 78
 
79
-		if( ctype_alnum( $name ) === false )
79
+		if (ctype_alnum($name) === false)
80 80
 		{
81
-			$classname = is_string( $name ) ? '\\Aimeos\\Client\\JsonApi\\Catalog\\' . $name : '<not a string>';
82
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
81
+			$classname = is_string($name) ? '\\Aimeos\\Client\\JsonApi\\Catalog\\' . $name : '<not a string>';
82
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
83 83
 		}
84 84
 
85 85
 		$view = $context->getView();
86 86
 		$iface = '\\Aimeos\\Client\\JsonApi\\Iface';
87 87
 		$classname = '\\Aimeos\\Client\\JsonApi\\Catalog\\' . $name;
88 88
 
89
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
89
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
90 90
 
91
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
91
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
92 92
 	}
93 93
 
94 94
 }
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Common/Decorator/Base.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 	 * @param array $templatePaths List of file system paths where the templates are stored
37 37
 	 * @param string $path Name of the client, e.g "product"
38 38
 	 */
39
-	public function __construct( \Aimeos\Client\JsonApi\Iface $client,
40
-		\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path )
39
+	public function __construct(\Aimeos\Client\JsonApi\Iface $client,
40
+		\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path)
41 41
 	{
42
-		parent::__construct( $context, $view, $templatePaths, $path );
42
+		parent::__construct($context, $view, $templatePaths, $path);
43 43
 
44 44
 		$this->client = $client;
45 45
 	}
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 * @return mixed Returns the value of the called method
54 54
 	 * @throws \Aimeos\Client\JsonApi\Exception If method call failed
55 55
 	 */
56
-	public function __call( $name, array $param )
56
+	public function __call($name, array $param)
57 57
 	{
58
-		return @call_user_func_array( array( $this->client, $name ), $param );
58
+		return @call_user_func_array(array($this->client, $name), $param);
59 59
 	}
60 60
 
61 61
 
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
67 67
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
68 68
 	 */
69
-	public function delete( ServerRequestInterface $request, ResponseInterface $response )
69
+	public function delete(ServerRequestInterface $request, ResponseInterface $response)
70 70
 	{
71
-		return $this->client->delete( $request, $response );
71
+		return $this->client->delete($request, $response);
72 72
 	}
73 73
 
74 74
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
80 80
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
81 81
 	 */
82
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
82
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
83 83
 	{
84
-		return $this->client->get( $request, $response );
84
+		return $this->client->get($request, $response);
85 85
 	}
86 86
 
87 87
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
94 94
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
95 95
 	 */
96
-	public function patch( ServerRequestInterface $request, ResponseInterface $response )
96
+	public function patch(ServerRequestInterface $request, ResponseInterface $response)
97 97
 	{
98
-		return $this->client->patch( $request, $response );
98
+		return $this->client->patch($request, $response);
99 99
 	}
100 100
 
101 101
 
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
108 108
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
109 109
 	 */
110
-	public function post( ServerRequestInterface $request, ResponseInterface $response )
110
+	public function post(ServerRequestInterface $request, ResponseInterface $response)
111 111
 	{
112
-		return $this->client->post( $request, $response );
112
+		return $this->client->post($request, $response);
113 113
 	}
114 114
 
115 115
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
122 122
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
123 123
 	 */
124
-	public function put( ServerRequestInterface $request, ResponseInterface $response )
124
+	public function put(ServerRequestInterface $request, ResponseInterface $response)
125 125
 	{
126
-		return $this->client->put( $request, $response );
126
+		return $this->client->put($request, $response);
127 127
 	}
128 128
 
129 129
 
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 	 * @param string|null $prefix Form parameter prefix when nesting parameters is required
137 137
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
138 138
 	 */
139
-	public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null )
139
+	public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null)
140 140
 	{
141
-		return $this->client->options( $request, $response, $prefix );
141
+		return $this->client->options($request, $response, $prefix);
142 142
 	}
143 143
 
144 144
 
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Common/Decorator/Iface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,6 +29,6 @@
 block discarded – undo
29 29
 	 * @param array $templatePaths List of file system paths where the templates are stored
30 30
 	 * @param string $path Name of the client separated by slashes, e.g "product/stock"
31 31
 	 */
32
-	public function __construct( \Aimeos\Client\JsonApi\Iface $client,
33
-		\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path );
32
+	public function __construct(\Aimeos\Client\JsonApi\Iface $client,
33
+		\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path);
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Stock/Standard.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -31,35 +31,35 @@  discard block
 block discarded – undo
31 31
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
32 32
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
33 33
 	 */
34
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
34
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
35 35
 	{
36 36
 		$view = $this->getView();
37 37
 
38 38
 		try
39 39
 		{
40
-			if( $view->param( 'id' ) != '' ) {
41
-				$response = $this->getItem( $view, $request, $response );
40
+			if ($view->param('id') != '') {
41
+				$response = $this->getItem($view, $request, $response);
42 42
 			} else {
43
-				$response = $this->getItems( $view, $request, $response );
43
+				$response = $this->getItems($view, $request, $response);
44 44
 			}
45 45
 
46 46
 			$status = 200;
47 47
 		}
48
-		catch( \Aimeos\MShop\Exception $e )
48
+		catch (\Aimeos\MShop\Exception $e)
49 49
 		{
50 50
 			$status = 404;
51
-			$view->errors = array( array(
52
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
51
+			$view->errors = array(array(
52
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
53 53
 				'detail' => $e->getTraceAsString(),
54
-			) );
54
+			));
55 55
 		}
56
-		catch( \Exception $e )
56
+		catch (\Exception $e)
57 57
 		{
58 58
 			$status = 500;
59
-			$view->errors = array( array(
59
+			$view->errors = array(array(
60 60
 				'title' => $e->getMessage(),
61 61
 				'detail' => $e->getTraceAsString(),
62
-			) );
62
+			));
63 63
 		}
64 64
 
65 65
 		/** client/jsonapi/stock/standard/template-get
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 		$tplconf = 'client/jsonapi/stock/standard/template-get';
85 85
 		$default = 'stock/get-default.php';
86 86
 
87
-		$body = $view->render( $view->config( $tplconf, $default ) );
87
+		$body = $view->render($view->config($tplconf, $default));
88 88
 
89
-		return $response->withHeader( 'Allow', 'GET' )
90
-			->withHeader( 'Content-Type', 'application/vnd.api+json' )
91
-			->withBody( $view->response()->createStreamFromString( $body ) )
92
-			->withStatus( $status );
89
+		return $response->withHeader('Allow', 'GET')
90
+			->withHeader('Content-Type', 'application/vnd.api+json')
91
+			->withBody($view->response()->createStreamFromString($body))
92
+			->withStatus($status);
93 93
 	}
94 94
 
95 95
 
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
102 102
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
103 103
 	 */
104
-	protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
104
+	protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
105 105
 	{
106 106
 		$context = $this->getContext();
107
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'stock' );
107
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'stock');
108 108
 
109
-		$view->items = $cntl->getItem( $view->param( 'id' ) );
109
+		$view->items = $cntl->getItem($view->param('id'));
110 110
 		$view->total = 1;
111 111
 
112 112
 		return $response;
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
122 122
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
123 123
 	 */
124
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
124
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
125 125
 	{
126 126
 		$total = 0;
127
-		$params = $view->param( 'filter', [] );
128
-		unset( $params['s_prodcode'], $params['s_typecode'] );
127
+		$params = $view->param('filter', []);
128
+		unset($params['s_prodcode'], $params['s_typecode']);
129 129
 
130
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'stock' );
130
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'stock');
131 131
 
132 132
 		$filter = $cntl->createFilter();
133
-		$filter = $this->initCriteria( $filter, ['filter' => $params] );
134
-		$filter = $cntl->addFilterCodes( $filter, $view->param( 'filter/s_prodcode', array() ) );
135
-		$filter = $cntl->addFilterTypes( $filter, $view->param( 'filter/s_typecode', array() ) );
133
+		$filter = $this->initCriteria($filter, ['filter' => $params]);
134
+		$filter = $cntl->addFilterCodes($filter, $view->param('filter/s_prodcode', array()));
135
+		$filter = $cntl->addFilterTypes($filter, $view->param('filter/s_typecode', array()));
136 136
 
137
-		$view->items = $cntl->searchItems( $filter, $total );
137
+		$view->items = $cntl->searchItems($filter, $total);
138 138
 		$view->total = $total;
139 139
 
140 140
 		return $response;
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Stock/Factory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @return \Aimeos\Client\JsonApi\Iface JSON API client
32 32
 	 * @throws \Aimeos\Client\JsonApi\Exception If requested client implementation couldn't be found or initialisation fails
33 33
 	 */
34
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null )
34
+	public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null)
35 35
 	{
36
-		if( ctype_alnum( $path ) === false )
36
+		if (ctype_alnum($path) === false)
37 37
 		{
38
-			$path = ( is_string( $path ) ? $path : '<not a string>' );
39
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid client "%1$s"', $path ), 400 );
38
+			$path = (is_string($path) ? $path : '<not a string>');
39
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid client "%1$s"', $path), 400);
40 40
 		}
41 41
 
42 42
 		/** client/jsonapi/stock/name
@@ -72,23 +72,23 @@  discard block
 block discarded – undo
72 72
 		 * @since 2017.03
73 73
 		 * @category Developer
74 74
 		 */
75
-		if( $name === null ) {
76
-			$name = $context->getConfig()->get( 'client/jsonapi/stock/name', 'Standard' );
75
+		if ($name === null) {
76
+			$name = $context->getConfig()->get('client/jsonapi/stock/name', 'Standard');
77 77
 		}
78 78
 
79
-		if( ctype_alnum( $name ) === false )
79
+		if (ctype_alnum($name) === false)
80 80
 		{
81
-			$classname = is_string( $name ) ? '\\Aimeos\\Client\\JsonApi\\Stock\\' . $name : '<not a string>';
82
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
81
+			$classname = is_string($name) ? '\\Aimeos\\Client\\JsonApi\\Stock\\' . $name : '<not a string>';
82
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
83 83
 		}
84 84
 
85 85
 		$view = $context->getView();
86 86
 		$iface = '\\Aimeos\\Client\\JsonApi\\Iface';
87 87
 		$classname = '\\Aimeos\\Client\\JsonApi\\Stock\\' . $name;
88 88
 
89
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
89
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
90 90
 
91
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
91
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
92 92
 	}
93 93
 
94 94
 }
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Product/Standard.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -31,40 +31,40 @@  discard block
 block discarded – undo
31 31
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
32 32
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
33 33
 	 */
34
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
34
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
35 35
 	{
36 36
 		$view = $this->getView();
37 37
 
38 38
 		try
39 39
 		{
40
-			if( $view->param( 'aggregate' ) != '' ) {
41
-				$response = $this->aggregate( $view, $request, $response );
42
-			} elseif( $view->param( 'id' ) != '' ) {
43
-				$response = $this->getItem( $view, $request, $response );
40
+			if ($view->param('aggregate') != '') {
41
+				$response = $this->aggregate($view, $request, $response);
42
+			} elseif ($view->param('id') != '') {
43
+				$response = $this->getItem($view, $request, $response);
44 44
 			} else {
45
-				$response = $this->getItems( $view, $request, $response );
45
+				$response = $this->getItems($view, $request, $response);
46 46
 			}
47 47
 
48 48
 			$status = 200;
49 49
 		}
50
-		catch( \Aimeos\MShop\Exception $e )
50
+		catch (\Aimeos\MShop\Exception $e)
51 51
 		{
52 52
 			$status = 404;
53
-			$view->errors = array( array(
54
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
53
+			$view->errors = array(array(
54
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
55 55
 				'detail' => $e->getTraceAsString(),
56
-			) );
56
+			));
57 57
 		}
58
-		catch( \Exception $e )
58
+		catch (\Exception $e)
59 59
 		{
60 60
 			$status = 500;
61
-			$view->errors = array( array(
61
+			$view->errors = array(array(
62 62
 				'title' => $e->getMessage(),
63 63
 				'detail' => $e->getTraceAsString(),
64
-			) );
64
+			));
65 65
 		}
66 66
 
67
-		if( $view->param( 'aggregate' ) != '' )
67
+		if ($view->param('aggregate') != '')
68 68
 		{
69 69
 			/** client/jsonapi/product/standard/template-aggregate
70 70
 			 * Relative path to the product aggregate JSON API template
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 			$default = 'product/get-default.php';
114 114
 		}
115 115
 
116
-		$body = $view->render( $view->config( $tplconf, $default ) );
116
+		$body = $view->render($view->config($tplconf, $default));
117 117
 
118
-		return $response->withHeader( 'Allow', 'GET' )
119
-			->withHeader( 'Content-Type', 'application/vnd.api+json' )
120
-			->withBody( $view->response()->createStreamFromString( $body ) )
121
-			->withStatus( $status );
118
+		return $response->withHeader('Allow', 'GET')
119
+			->withHeader('Content-Type', 'application/vnd.api+json')
120
+			->withBody($view->response()->createStreamFromString($body))
121
+			->withStatus($status);
122 122
 	}
123 123
 
124 124
 
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
131 131
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
132 132
 	 */
133
-	protected function aggregate( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
133
+	protected function aggregate(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
134 134
 	{
135
-		$key = $view->param( 'aggregate' );
136
-		$size = $view->param( 'page/limit', 10000 );
137
-		$start = $view->param( 'page/offset', 0 );
135
+		$key = $view->param('aggregate');
136
+		$size = $view->param('page/limit', 10000);
137
+		$start = $view->param('page/offset', 0);
138 138
 
139
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'product' );
140
-		$filter = $this->getFilter( $view, null, '+', $start, $size );
139
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'product');
140
+		$filter = $this->getFilter($view, null, '+', $start, $size);
141 141
 
142
-		$view->data = $cntl->aggregate( $filter, $key );
142
+		$view->data = $cntl->aggregate($filter, $key);
143 143
 
144 144
 		return $response;
145 145
 	}
@@ -153,25 +153,25 @@  discard block
 block discarded – undo
153 153
 	 * @param string $domain Domain name of the items that should be returned
154 154
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as keys and attribute items as values
155 155
 	 */
156
-	protected function getDomainItems( array $productItems, array $ref, $domain )
156
+	protected function getDomainItems(array $productItems, array $ref, $domain)
157 157
 	{
158 158
 		$ids = array();
159 159
 
160
-		foreach( $productItems as $item ) {
161
-			$ids = array_merge( $ids, array_keys( $item->getRefItems( $domain ) ) );
160
+		foreach ($productItems as $item) {
161
+			$ids = array_merge($ids, array_keys($item->getRefItems($domain)));
162 162
 		}
163 163
 
164
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain );
164
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain);
165 165
 
166
-		$search = $manager->createSearch( true );
166
+		$search = $manager->createSearch(true);
167 167
 		$expr = array(
168
-			$search->compare( '==', $domain . '.id', $ids ),
168
+			$search->compare('==', $domain . '.id', $ids),
169 169
 			$search->getConditions(),
170 170
 		);
171
-		$search->setConditions( $search->combine( '&&', $expr ) );
172
-		$search->setSlice( 0, 0x7fffffff );
171
+		$search->setConditions($search->combine('&&', $expr));
172
+		$search->setSlice(0, 0x7fffffff);
173 173
 
174
-		return $manager->searchItems( $search, $ref );
174
+		return $manager->searchItems($search, $ref);
175 175
 	}
176 176
 
177 177
 
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
 	 * @param integer $size Slize size
186 186
 	 * @return \Aimeos\MW\Criteria\Iface Initialize search filter
187 187
 	 */
188
-	protected function getFilter( \Aimeos\MW\View\Iface $view, $sort, $direction, $start, $size )
188
+	protected function getFilter(\Aimeos\MW\View\Iface $view, $sort, $direction, $start, $size)
189 189
 	{
190
-		$listtype = $view->param( 'filter/f_listtype', 'default' );
191
-		$attrIds = $view->param( 'filter/f_attrid', array() );
192
-		$optIds = $view->param( 'filter/f_optid', array() );
193
-		$oneIds = $view->param( 'filter/f_oneid', array() );
190
+		$listtype = $view->param('filter/f_listtype', 'default');
191
+		$attrIds = $view->param('filter/f_attrid', array());
192
+		$optIds = $view->param('filter/f_optid', array());
193
+		$oneIds = $view->param('filter/f_oneid', array());
194 194
 
195 195
 		$context = $this->getContext();
196
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'product' );
196
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'product');
197 197
 
198
-		$filter = $cntl->createFilter( $sort, $direction, $start, $size, $listtype );
199
-		$filter = $cntl->addFilterAttribute( $filter, $attrIds, $optIds, $oneIds );
198
+		$filter = $cntl->createFilter($sort, $direction, $start, $size, $listtype);
199
+		$filter = $cntl->addFilterAttribute($filter, $attrIds, $optIds, $oneIds);
200 200
 
201
-		if( ( $catid = $view->param( 'filter/f_catid' ) ) !== null )
201
+		if (($catid = $view->param('filter/f_catid')) !== null)
202 202
 		{
203 203
 			$default = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
204 204
 
@@ -228,19 +228,19 @@  discard block
 block discarded – undo
228 228
 			 * @since 2017.03
229 229
 			 * @category Developer
230 230
 			 */
231
-			$level = $context->getConfig()->get( 'client/jsonapi/product/levels', $default );
231
+			$level = $context->getConfig()->get('client/jsonapi/product/levels', $default);
232 232
 
233
-			$filter = $cntl->addFilterCategory( $filter, $catid, $level, $sort, $direction, $listtype );
233
+			$filter = $cntl->addFilterCategory($filter, $catid, $level, $sort, $direction, $listtype);
234 234
 		}
235 235
 
236
-		if( ( $search = $view->param( 'filter/f_search' ) ) !== null ) {
237
-			$filter = $cntl->addFilterText( $filter, $search, $sort, $direction, $listtype );
236
+		if (($search = $view->param('filter/f_search')) !== null) {
237
+			$filter = $cntl->addFilterText($filter, $search, $sort, $direction, $listtype);
238 238
 		}
239 239
 
240
-		$params = $view->param( 'filter', [] );
241
-		unset( $params['f_attrid'], $params['f_optid'], $params['f_oneid'] );
242
-		unset( $params['f_listtype'], $params['f_catid'], $params['f_search'] );
243
-		$filter = $this->initCriteriaConditions( $filter, ['filter' => $params] );
240
+		$params = $view->param('filter', []);
241
+		unset($params['f_attrid'], $params['f_optid'], $params['f_oneid']);
242
+		unset($params['f_listtype'], $params['f_catid'], $params['f_search']);
243
+		$filter = $this->initCriteriaConditions($filter, ['filter' => $params]);
244 244
 
245 245
 		return $filter;
246 246
 	}
@@ -254,28 +254,28 @@  discard block
 block discarded – undo
254 254
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
255 255
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
256 256
 	 */
257
-	protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
257
+	protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
258 258
 	{
259 259
 		$map = array();
260
-		$ref = $view->param( 'include', array() );
260
+		$ref = $view->param('include', array());
261 261
 
262
-		if( is_string( $ref ) ) {
263
-			$ref = explode( ',', $ref );
262
+		if (is_string($ref)) {
263
+			$ref = explode(',', $ref);
264 264
 		}
265 265
 
266
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'product' );
266
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'product');
267 267
 
268
-		$view->items = $cntl->getItem( $view->param( 'id' ), $ref );
268
+		$view->items = $cntl->getItem($view->param('id'), $ref);
269 269
 		$view->total = 1;
270 270
 
271
-		if( in_array( 'product', $ref, true ) ) {
272
-			$map['product'] = $this->getDomainItems( array( $view->items ), $ref, 'product' );
271
+		if (in_array('product', $ref, true)) {
272
+			$map['product'] = $this->getDomainItems(array($view->items), $ref, 'product');
273 273
 		}
274 274
 
275
-		if( in_array( 'attribute', $ref, true ) )
275
+		if (in_array('attribute', $ref, true))
276 276
 		{
277
-			$productItems = ( isset( $map['product'] ) ? array_merge( array( $view->items ), $map['product'] ) : array() );
278
-			$map['attribute'] = $this->getDomainItems( $productItems, $ref, 'attribute' );
277
+			$productItems = (isset($map['product']) ? array_merge(array($view->items), $map['product']) : array());
278
+			$map['attribute'] = $this->getDomainItems($productItems, $ref, 'attribute');
279 279
 		}
280 280
 
281 281
 		$view->itemMap = $map;
@@ -292,41 +292,41 @@  discard block
 block discarded – undo
292 292
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
293 293
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
294 294
 	 */
295
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
295
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
296 296
 	{
297 297
 		$total = 0;
298 298
 		$map = array();
299
-		$direction  = '+';
299
+		$direction = '+';
300 300
 
301
-		$ref = $view->param( 'include', array() );
302
-		$size = $view->param( 'page/limit', 48 );
303
-		$start = $view->param( 'page/offset', 0 );
304
-		$sort = $view->param( 'sort', 'relevance' );
301
+		$ref = $view->param('include', array());
302
+		$size = $view->param('page/limit', 48);
303
+		$start = $view->param('page/offset', 0);
304
+		$sort = $view->param('sort', 'relevance');
305 305
 
306
-		if( is_string( $ref ) ) {
307
-			$ref = explode( ',', $ref );
306
+		if (is_string($ref)) {
307
+			$ref = explode(',', $ref);
308 308
 		}
309 309
 
310
-		if( $sort[0] === '-' )
310
+		if ($sort[0] === '-')
311 311
 		{
312
-			$sort = substr( $sort, 1 );
312
+			$sort = substr($sort, 1);
313 313
 			$direction = '-';
314 314
 		}
315 315
 
316
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'product' );
317
-		$filter = $this->getFilter( $view, $sort, $direction, $start, $size );
316
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'product');
317
+		$filter = $this->getFilter($view, $sort, $direction, $start, $size);
318 318
 
319
-		$view->items = $cntl->searchItems( $filter, $ref, $total );
319
+		$view->items = $cntl->searchItems($filter, $ref, $total);
320 320
 		$view->total = $total;
321 321
 
322
-		if( in_array( 'product', $ref, true ) ) {
323
-			$map['product'] = $this->getDomainItems( $view->items, $ref, 'product' );
322
+		if (in_array('product', $ref, true)) {
323
+			$map['product'] = $this->getDomainItems($view->items, $ref, 'product');
324 324
 		}
325 325
 
326
-		if( in_array( 'attribute', $ref, true ) )
326
+		if (in_array('attribute', $ref, true))
327 327
 		{
328
-			$productItems = ( isset( $map['product'] ) ? array_merge( $view->items, $map['product'] ) : array() );
329
-			$map['attribute'] = $this->getDomainItems( $productItems, $ref, 'attribute' );
328
+			$productItems = (isset($map['product']) ? array_merge($view->items, $map['product']) : array());
329
+			$map['attribute'] = $this->getDomainItems($productItems, $ref, 'attribute');
330 330
 		}
331 331
 
332 332
 		$view->itemMap = $map;
Please login to merge, or discard this patch.