Completed
Push — master ( c22e8e...3fbe79 )
by Aimeos
02:22
created
admin/jsonadm/src/Admin/JsonAdm/Factory.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -154,7 +154,6 @@
 block discarded – undo
154 154
 	 * Creates the top level client
155 155
 	 *
156 156
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by clients
157
-	 * @param \Aimeos\MW\View\Iface $view View object
158 157
 	 * @param array $templatePaths List of file system paths where the templates are stored
159 158
 	 * @param string $path Name of the client separated by slashes, e.g "product/stock"
160 159
 	 * @param string|null $name Name of the JsonAdm client (default: "Standard")
Please login to merge, or discard this 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
-		if( ctype_alnum( $pname ) === false )
133
+		if (ctype_alnum($pname) === false)
134 134
 		{
135
-			$classname = is_string( $pname ) ? $classname : '<not a string>';
136
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
135
+			$classname = is_string($pname) ? $classname : '<not a string>';
136
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
137 137
 		}
138 138
 
139 139
 
140 140
 		$view = $context->getView();
141 141
 		$iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';
142
-		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\' . $pname;
142
+		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\' . $pname;
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
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance
162 162
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created
163 163
 	 */
164
-	protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context,
165
-		array $templatePaths, $path, $name = null )
164
+	protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context,
165
+		array $templatePaths, $path, $name = null)
166 166
 	{
167 167
 		/** admin/jsonadm/name
168 168
 		 * Class name of the used JSON API client implementation
@@ -197,21 +197,21 @@  discard block
 block discarded – undo
197 197
 		 * @since 2015.12
198 198
 		 * @category Developer
199 199
 		 */
200
-		if( $name === null ) {
201
-			$name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' );
200
+		if ($name === null) {
201
+			$name = $context->getConfig()->get('admin/jsonadm/name', 'Standard');
202 202
 		}
203 203
 
204
-		if( ctype_alnum( $name ) === false )
204
+		if (ctype_alnum($name) === false)
205 205
 		{
206
-			$classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
207
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
206
+			$classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>';
207
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname));
208 208
 		}
209 209
 
210 210
 		$view = $context->getView();
211 211
 		$iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';
212 212
 		$classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name;
213 213
 
214
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
214
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
215 215
 
216 216
 		/** admin/jsonadm/decorators/excludes
217 217
 		 * Excludes decorators added by the "common" option from the JSON API clients
@@ -291,6 +291,6 @@  discard block
 block discarded – undo
291 291
 		 * @see admin/jsonadm/decorators/global
292 292
 		 */
293 293
 
294
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
294
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
295 295
 	}
296 296
 }
Please login to merge, or discard this patch.