Passed
Branch master (d032f7)
by Aimeos
05:30
created

Standard::getConfigAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2018
6
 * @package Admin
7
 * @subpackage JQAdm
8
 */
9
10
11
namespace Aimeos\Admin\JQAdm\Coupon;
12
13
sprintf( 'coupon' ); // for translation
14
15
16
/**
17
 * Default implementation of coupon JQAdm client.
18
 *
19
 * @package Admin
20
 * @subpackage JQAdm
21
 */
22
class Standard
23
	extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base
24
	implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface
25
{
26
	/**
27
	 * Copies a resource
28
	 *
29
	 * @return string HTML output
30
	 */
31
	public function copy()
32
	{
33
		$view = $this->getView();
34
		$context = $this->getContext();
35
36
		try
37
		{
38
			if( ( $id = $view->param( 'id' ) ) === null ) {
39
				throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Required parameter "%1$s" is missing', 'id' ) );
40
			}
41
42
			$manager = \Aimeos\MShop::create( $context, 'coupon' );
43
44
			$view->item = $manager->getItem( $id );
45
			$view->itemData = $this->toArray( $view->item, true );
46
			$view->itemSubparts = $this->getSubClientNames();
47
			$view->itemProviders = $this->getProviderNames();
48
			$view->itemDecorators = $this->getDecoratorNames();
49
			$view->itemAttributes = $this->getConfigAttributes( $view->item );
50
			$view->itemBody = '';
51
52
			foreach( $this->getSubClients() as $idx => $client )
53
			{
54
				$view->tabindex = ++$idx + 1;
55
				$view->itemBody .= $client->copy();
56
			}
57
		}
58
		catch( \Aimeos\MShop\Exception $e )
59
		{
60
			$error = array( 'coupon-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
61
			$view->errors = $view->get( 'errors', [] ) + $error;
62
			$this->logException( $e );
63
		}
64
		catch( \Exception $e )
65
		{
66
			$error = array( 'coupon-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() );
67
			$view->errors = $view->get( 'errors', [] ) + $error;
68
			$this->logException( $e );
69
		}
70
71
		return $this->render( $view );
72
	}
73
74
75
	/**
76
	 * Creates a new resource
77
	 *
78
	 * @return string HTML output
79
	 */
80
	public function create()
81
	{
82
		$view = $this->getView();
83
		$context = $this->getContext();
84
85
		try
86
		{
87
			$data = $view->param( 'item', [] );
88
89
			if( !isset( $view->item ) ) {
90
				$view->item = \Aimeos\MShop::create( $context, 'coupon' )->createItem();
91
			}
92
93
			$data['coupon.siteid'] = $view->item->getSiteId();
94
95
			$view->itemSubparts = $this->getSubClientNames();
96
			$view->itemDecorators = $this->getDecoratorNames();
97
			$view->itemProviders = $this->getProviderNames();
98
			$view->itemData = $data;
99
			$view->itemBody = '';
100
101
			foreach( $this->getSubClients() as $idx => $client )
102
			{
103
				$view->tabindex = ++$idx + 1;
104
				$view->itemBody .= $client->create();
105
			}
106
		}
107
		catch( \Aimeos\MShop\Exception $e )
108
		{
109
			$error = array( 'coupon-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
110
			$view->errors = $view->get( 'errors', [] ) + $error;
111
			$this->logException( $e );
112
		}
113
		catch( \Exception $e )
114
		{
115
			$error = array( 'coupon-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() );
116
			$view->errors = $view->get( 'errors', [] ) + $error;
117
			$this->logException( $e );
118
		}
119
120
		return $this->render( $view );
121
	}
122
123
124
	/**
125
	 * Deletes a resource
126
	 *
127
	 * @return string|null HTML output
128
	 */
129
	public function delete()
130
	{
131
		$view = $this->getView();
132
		$context = $this->getContext();
133
134
		$manager = \Aimeos\MShop::create( $context, 'coupon' );
135
		$manager->begin();
136
137
		try
138
		{
139
			if( ( $id = $view->param( 'id' ) ) === null ) {
140
				throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Required parameter "%1$s" is missing', 'id' ) );
141
			}
142
143
			$view->item = $manager->getItem( $id );
144
145
			foreach( $this->getSubClients() as $client ) {
146
				$client->delete();
147
			}
148
149
			$manager->deleteItem( $id );
150
			$manager->commit();
151
152
			$this->nextAction( $view, 'search', 'coupon', null, 'delete' );
153
			return;
154
		}
155
		catch( \Aimeos\MShop\Exception $e )
156
		{
157
			$error = array( 'coupon-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
158
			$view->errors = $view->get( 'errors', [] ) + $error;
159
			$this->logException( $e );
160
		}
161
		catch( \Exception $e )
162
		{
163
			$error = array( 'coupon-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() );
164
			$view->errors = $view->get( 'errors', [] ) + $error;
165
			$this->logException( $e );
166
		}
167
168
		$manager->rollback();
169
170
		return $this->search();
171
	}
172
173
174
	/**
175
	 * Returns a single resource
176
	 *
177
	 * @return string HTML output
178
	 */
179
	public function get()
180
	{
181
		$view = $this->getView();
182
		$context = $this->getContext();
183
184
		try
185
		{
186
			if( ( $id = $view->param( 'id' ) ) === null ) {
187
				throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Required parameter "%1$s" is missing', 'id' ) );
188
			}
189
190
			$manager = \Aimeos\MShop::create( $context, 'coupon' );
191
192
			$view->item = $manager->getItem( $id );
193
			$view->itemData = $this->toArray( $view->item );
194
			$view->itemSubparts = $this->getSubClientNames();
195
			$view->itemDecorators = $this->getDecoratorNames();
196
			$view->itemProviders = $this->getProviderNames();
197
			$view->itemAttributes = $this->getConfigAttributes( $view->item );
198
			$view->itemBody = '';
199
200
			foreach( $this->getSubClients() as $idx => $client )
201
			{
202
				$view->tabindex = ++$idx + 1;
203
				$view->itemBody .= $client->get();
204
			}
205
		}
206
		catch( \Aimeos\MShop\Exception $e )
207
		{
208
			$error = array( 'coupon-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
209
			$view->errors = $view->get( 'errors', [] ) + $error;
210
			$this->logException( $e );
211
		}
212
		catch( \Exception $e )
213
		{
214
			$error = array( 'coupon-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() );
215
			$view->errors = $view->get( 'errors', [] ) + $error;
216
			$this->logException( $e );
217
		}
218
219
		return $this->render( $view );
220
	}
221
222
223
	/**
224
	 * Saves the data
225
	 *
226
	 * @return string HTML output
227
	 */
228
	public function save()
229
	{
230
		$view = $this->getView();
231
		$context = $this->getContext();
232
233
		$manager = \Aimeos\MShop::create( $context, 'coupon' );
234
		$manager->begin();
235
236
		try
237
		{
238
			$item = $this->fromArray( $view->param( 'item', [] ) );
239
			$view->item = $item->getId() ? $item : $manager->saveItem( $item );
240
			$view->itemBody = '';
241
242
			foreach( $this->getSubClients() as $client ) {
243
				$view->itemBody .= $client->save();
244
			}
245
246
			$manager->saveItem( clone $view->item );
247
			$manager->commit();
248
249
			$this->nextAction( $view, $view->param( 'next' ), 'coupon', $view->item->getId(), 'save' );
250
			return;
251
		}
252
		catch( \Aimeos\Admin\JQAdm\Exception $e )
253
		{
254
			// fall through to create
255
		}
256
		catch( \Aimeos\MShop\Exception $e )
257
		{
258
			$error = array( 'coupon-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
259
			$view->errors = $view->get( 'errors', [] ) + $error;
260
			$this->logException( $e );
261
		}
262
		catch( \Exception $e )
263
		{
264
			$error = array( 'coupon-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() );
265
			$view->errors = $view->get( 'errors', [] ) + $error;
266
			$this->logException( $e );
267
		}
268
269
		$manager->rollback();
270
271
		return $this->create();
272
	}
273
274
275
	/**
276
	 * Returns a list of resource according to the conditions
277
	 *
278
	 * @return string HTML output
279
	 */
280
	public function search()
281
	{
282
		$view = $this->getView();
283
		$context = $this->getContext();
284
285
		try
286
		{
287
			$total = 0;
288
			$params = $this->storeSearchParams( $view->param(), 'coupon' );
289
			$manager = \Aimeos\MShop::create( $context, 'coupon' );
290
			$search = $this->initCriteria( $manager->createSearch(), $params );
291
292
			$view->items = $manager->searchItems( $search, [], $total );
293
			$view->filterAttributes = $manager->getSearchAttributes( true );
294
			$view->filterOperators = $search->getOperators();
295
			$view->total = $total;
296
			$view->itemBody = '';
297
298
			foreach( $this->getSubClients() as $client ) {
299
				$view->itemBody .= $client->search();
300
			}
301
		}
302
		catch( \Aimeos\MShop\Exception $e )
303
		{
304
			$error = array( 'coupon-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
305
			$view->errors = $view->get( 'errors', [] ) + $error;
306
			$this->logException( $e );
307
		}
308
		catch( \Exception $e )
309
		{
310
			$error = array( 'coupon-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() );
311
			$view->errors = $view->get( 'errors', [] ) + $error;
312
			$this->logException( $e );
313
		}
314
315
		/** admin/jqadm/coupon/template-list
316
		 * Relative path to the HTML body template for the coupon list.
317
		 *
318
		 * The template file contains the HTML code and processing instructions
319
		 * to generate the result shown in the body of the frontend. The
320
		 * configuration string is the path to the template file relative
321
		 * to the templates directory (usually in admin/jqadm/templates).
322
		 *
323
		 * You can overwrite the template file configuration in extensions and
324
		 * provide alternative templates. These alternative templates should be
325
		 * named like the default one but with the string "default" replaced by
326
		 * an unique name. You may use the name of your project for this. If
327
		 * you've implemented an alternative client class as well, "default"
328
		 * should be replaced by the name of the new class.
329
		 *
330
		 * @param string Relative path to the template creating the HTML code
331
		 * @since 2016.04
332
		 * @category Developer
333
		 */
334
		$tplconf = 'admin/jqadm/coupon/template-list';
335
		$default = 'coupon/list-standard';
336
337
		return $view->render( $view->config( $tplconf, $default ) );
338
	}
339
340
341
	/**
342
	 * Returns the sub-client given by its name.
343
	 *
344
	 * @param string $type Name of the client type
345
	 * @param string|null $name Name of the sub-client (Default if null)
346
	 * @return \Aimeos\Admin\JQAdm\Iface Sub-client object
347
	 */
348
	public function getSubClient( $type, $name = null )
349
	{
350
		/** admin/jqadm/coupon/decorators/excludes
351
		 * Excludes decorators added by the "common" option from the coupon JQAdm client
352
		 *
353
		 * Decorators extend the functionality of a class by adding new aspects
354
		 * (e.g. log what is currently done), executing the methods of the underlying
355
		 * class only in certain conditions (e.g. only for logged in users) or
356
		 * modify what is returned to the caller.
357
		 *
358
		 * This option allows you to remove a decorator added via
359
		 * "client/jqadm/common/decorators/default" before they are wrapped
360
		 * around the JQAdm client.
361
		 *
362
		 *  admin/jqadm/coupon/decorators/excludes = array( 'decorator1' )
363
		 *
364
		 * This would remove the decorator named "decorator1" from the list of
365
		 * common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via
366
		 * "client/jqadm/common/decorators/default" to the JQAdm client.
367
		 *
368
		 * @param array List of decorator names
369
		 * @since 2017.07
370
		 * @category Developer
371
		 * @see admin/jqadm/common/decorators/default
372
		 * @see admin/jqadm/coupon/decorators/global
373
		 * @see admin/jqadm/coupon/decorators/local
374
		 */
375
376
		/** admin/jqadm/coupon/decorators/global
377
		 * Adds a list of globally available decorators only to the coupon JQAdm client
378
		 *
379
		 * Decorators extend the functionality of a class by adding new aspects
380
		 * (e.g. log what is currently done), executing the methods of the underlying
381
		 * class only in certain conditions (e.g. only for logged in users) or
382
		 * modify what is returned to the caller.
383
		 *
384
		 * This option allows you to wrap global decorators
385
		 * ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client.
386
		 *
387
		 *  admin/jqadm/coupon/decorators/global = array( 'decorator1' )
388
		 *
389
		 * This would add the decorator named "decorator1" defined by
390
		 * "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client.
391
		 *
392
		 * @param array List of decorator names
393
		 * @since 2017.07
394
		 * @category Developer
395
		 * @see admin/jqadm/common/decorators/default
396
		 * @see admin/jqadm/coupon/decorators/excludes
397
		 * @see admin/jqadm/coupon/decorators/local
398
		 */
399
400
		/** admin/jqadm/coupon/decorators/local
401
		 * Adds a list of local decorators only to the coupon JQAdm client
402
		 *
403
		 * Decorators extend the functionality of a class by adding new aspects
404
		 * (e.g. log what is currently done), executing the methods of the underlying
405
		 * class only in certain conditions (e.g. only for logged in users) or
406
		 * modify what is returned to the caller.
407
		 *
408
		 * This option allows you to wrap local decorators
409
		 * ("\Aimeos\Admin\JQAdm\Coupon\Decorator\*") around the JQAdm client.
410
		 *
411
		 *  admin/jqadm/coupon/decorators/local = array( 'decorator2' )
412
		 *
413
		 * This would add the decorator named "decorator2" defined by
414
		 * "\Aimeos\Admin\JQAdm\Coupon\Decorator\Decorator2" only to the JQAdm client.
415
		 *
416
		 * @param array List of decorator names
417
		 * @since 2017.07
418
		 * @category Developer
419
		 * @see admin/jqadm/common/decorators/default
420
		 * @see admin/jqadm/coupon/decorators/excludes
421
		 * @see admin/jqadm/coupon/decorators/global
422
		 */
423
		return $this->createSubClient( 'coupon/' . $type, $name );
424
	}
425
426
427
	/**
428
	 * Returns the backend configuration attributes of the provider and decorators
429
	 *
430
	 * @param \Aimeos\MShop\Coupon\Item\Iface $item Coupon item incl. provider/decorator property
431
	 * @return \Aimeos\MW\Common\Critera\Attribute\Iface[] List of configuration attributes
432
	 */
433
	public function getConfigAttributes( \Aimeos\MShop\Coupon\Item\Iface $item )
434
	{
435
		$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon' );
436
437
		try {
438
			return $manager->getProvider( $item, '' )->getConfigBE();
1 ignored issue
show
Bug introduced by
The method getProvider() does not exist on Aimeos\MShop\Common\Manager\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\MShop\Common\Manager\Decorator\Iface or Aimeos\MShop\Service\Manager\Lists\Type\Iface or Aimeos\MShop\Price\Manager\Iface or Aimeos\MShop\Attribute\Manager\Type\Iface or Aimeos\MShop\Price\Manager\Lists\Type\Iface or Aimeos\MShop\Media\Manager\Type\Iface or Aimeos\MShop\Coupon\Manager\Code\Iface or Aimeos\MShop\Order\Manager\Base\Coupon\Iface or Aimeos\MShop\Product\Manager\Iface or Aimeos\MShop\Supplier\Manager\Iface or Aimeos\MShop\Common\Manager\Property\Iface or Aimeos\MShop\Customer\Manager\Property\Iface or Aimeos\MShop\Order\Manager\Base\Service\Iface or Aimeos\MShop\Order\Manager\Base\Iface or Aimeos\MShop\Price\Manager\Lists\Iface or Aimeos\MShop\Supplier\Manager\Lists\Type\Iface or Aimeos\MShop\Order\Manag...Service\Attribute\Iface or Aimeos\MShop\Service\Manager\Lists\Iface or Aimeos\MShop\Tag\Manager\Type\Iface or Aimeos\MShop\Text\Manager\Lists\Iface or Aimeos\MShop\Price\Manager\Type\Iface or Aimeos\MShop\Locale\Manager\Currency\Iface or Aimeos\MShop\Order\Manag...Product\Attribute\Iface or Aimeos\MShop\Media\Manager\Lists\Type\Iface or Aimeos\MShop\Catalog\Manager\Lists\Iface or Aimeos\MShop\Tag\Manager\Iface or Aimeos\MShop\Attribute\Manager\Iface or Aimeos\MShop\Common\Manager\Lists\Iface or Aimeos\MShop\Attribute\Manager\Property\Type\Iface or Aimeos\MShop\Service\Manager\Type\Iface or Aimeos\MShop\Product\Manager\Lists\Iface or Aimeos\MShop\Customer\Manager\Property\Type\Iface or Aimeos\MShop\Order\Manager\Iface or Aimeos\MShop\Customer\Manager\Iface or Aimeos\MShop\Media\Manager\Iface or Aimeos\MShop\Customer\Manager\Lists\Type\Iface or Aimeos\MShop\Attribute\Manager\Lists\Iface or Aimeos\MShop\Product\Manager\Property\Type\Iface or Aimeos\MShop\Media\Manager\Lists\Iface or Aimeos\MShop\Order\Manager\Base\Address\Iface or Aimeos\MShop\Catalog\Manager\Iface or Aimeos\MShop\Locale\Manager\Site\Iface or Aimeos\MShop\Product\Manager\Type\Iface or Aimeos\MShop\Supplier\Manager\Lists\Iface or Aimeos\MShop\Stock\Manager\Type\Iface or Aimeos\MShop\Text\Manager\Iface or Aimeos\MShop\Common\Manager\Type\Iface or Aimeos\MAdmin\Job\Manager\Iface or Aimeos\MShop\Customer\Manager\Group\Iface or Aimeos\MShop\Product\Manager\Lists\Type\Iface or Aimeos\MShop\Text\Manager\Lists\Type\Iface or Aimeos\MShop\Text\Manager\Type\Iface or Aimeos\MShop\Order\Manager\Status\Iface or Aimeos\MShop\Common\Manager\Address\Iface or Aimeos\MShop\Plugin\Manager\Type\Iface or Aimeos\MShop\Stock\Manager\Iface or Aimeos\MShop\Attribute\Manager\Property\Iface or Aimeos\MShop\Subscription\Manager\Iface or Aimeos\MShop\Media\Manager\Property\Type\Iface or Aimeos\MShop\Product\Manager\Property\Iface or Aimeos\MShop\Locale\Manager\Language\Iface or Aimeos\MShop\Media\Manager\Property\Iface or Aimeos\MShop\Attribute\Manager\Lists\Type\Iface or Aimeos\MAdmin\Log\Manager\Iface or Aimeos\MShop\Locale\Manager\Iface or Aimeos\MAdmin\Cache\Manager\Iface or Aimeos\MShop\Order\Manager\Base\Product\Iface or Aimeos\MShop\Customer\Manager\Lists\Iface or Aimeos\MShop\Catalog\Manager\Lists\Type\Iface or Aimeos\MShop\Index\Manager\Iface or Aimeos\MShop\Index\Manager\Attribute\Iface or Aimeos\MShop\Index\Manager\Text\Iface or Aimeos\MShop\Index\Manager\Supplier\Iface or Aimeos\MShop\Index\Manager\Catalog\Iface or Aimeos\MShop\Index\Manager\Price\Iface or Aimeos\MShop\Supplier\Manager\Address\Iface or Aimeos\MShop\Customer\Manager\Address\Iface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

438
			return $manager->/** @scrutinizer ignore-call */ getProvider( $item, '' )->getConfigBE();
Loading history...
439
		} catch( \Aimeos\MShop\Exception $e ) {
440
			return [];
441
		}
442
	}
443
444
445
	/**
446
	 * Returns the list of sub-client names configured for the client.
447
	 *
448
	 * @return array List of JQAdm client names
449
	 */
450
	protected function getSubClientNames()
451
	{
452
		/** admin/jqadm/coupon/standard/subparts
453
		 * List of JQAdm sub-clients rendered within the coupon section
454
		 *
455
		 * The output of the frontend is composed of the code generated by the JQAdm
456
		 * clients. Each JQAdm client can consist of serveral (or none) sub-clients
457
		 * that are responsible for rendering certain sub-parts of the output. The
458
		 * sub-clients can contain JQAdm clients themselves and therefore a
459
		 * hierarchical tree of JQAdm clients is composed. Each JQAdm client creates
460
		 * the output that is placed inside the container of its parent.
461
		 *
462
		 * At first, always the JQAdm code generated by the parent is printed, then
463
		 * the JQAdm code of its sub-clients. The order of the JQAdm sub-clients
464
		 * determines the order of the output of these sub-clients inside the parent
465
		 * container. If the configured list of clients is
466
		 *
467
		 *  array( "subclient1", "subclient2" )
468
		 *
469
		 * you can easily change the order of the output by reordering the subparts:
470
		 *
471
		 *  admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" )
472
		 *
473
		 * You can also remove one or more parts if they shouldn't be rendered:
474
		 *
475
		 *  admin/jqadm/<clients>/subparts = array( "subclient1" )
476
		 *
477
		 * As the clients only generates structural JQAdm, the layout defined via CSS
478
		 * should support adding, removing or reordering content by a fluid like
479
		 * design.
480
		 *
481
		 * @param array List of sub-client names
482
		 * @since 2017.07
483
		 * @category Developer
484
		 */
485
		return $this->getContext()->getConfig()->get( 'admin/jqadm/coupon/standard/subparts', [] );
486
	}
487
488
489
	/**
490
	 * Returns the names of the available coupon decorators
491
	 *
492
	 * @return string[] List of decorator class names
493
	 */
494
	protected function getDecoratorNames()
495
	{
496
		$ds = DIRECTORY_SEPARATOR;
497
		return $this->getClassNames( 'MShop' . $ds . 'Coupon' . $ds . 'Provider' . $ds . 'Decorator' );
498
	}
499
500
501
	/**
502
	 * Returns the names of the available coupon providers
503
	 *
504
	 * @return string[] List of provider class names
505
	 */
506
	protected function getProviderNames()
507
	{
508
		$ds = DIRECTORY_SEPARATOR;
509
		return $this->getClassNames( 'MShop' . $ds . 'Coupon' . $ds . 'Provider' );
510
	}
511
512
513
	/**
514
	 * Creates new and updates existing items using the data array
515
	 *
516
	 * @param string[] Data array
0 ignored issues
show
Bug introduced by
The type Aimeos\Admin\JQAdm\Coupon\Data was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
517
	 * @return \Aimeos\MShop\Coupon\Item\Iface New coupon item object
518
	 */
519
	protected function fromArray( array $data )
520
	{
521
		$conf = [];
522
523
		if( isset( $data['config']['key'] ) )
524
		{
525
			foreach( (array) $data['config']['key'] as $idx => $key )
526
			{
527
				if( trim( $key ) !== '' && isset( $data['config']['val'][$idx] ) )
528
				{
529
					if( ( $val = json_decode( $data['config']['val'][$idx] ) ) === null ) {
530
						$conf[$key] = $data['config']['val'][$idx];
531
					} else {
532
						$conf[$key] = $val;
533
					}
534
				}
535
			}
536
		}
537
538
		$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon' );
539
540
		if( isset( $data['coupon.id'] ) && $data['coupon.id'] != '' ) {
541
			$item = $manager->getItem( $data['coupon.id'] );
542
		} else {
543
			$item = $manager->createItem();
544
		}
545
546
		$item->fromArray( $data );
547
		$item->setConfig( $conf );
0 ignored issues
show
Bug introduced by
The method setConfig() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

547
		$item->/** @scrutinizer ignore-call */ 
548
         setConfig( $conf );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method setConfig() does not exist on Aimeos\MShop\Common\Item\Iface. It seems like you code against a sub-type of Aimeos\MShop\Common\Item\Iface such as Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Service\Item\Iface or Aimeos\MShop\Locale\Item\Site\Iface or Aimeos\MShop\Coupon\Item\Iface or Aimeos\MShop\Common\Item\Lists\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Plugin\Item\Iface or Aimeos\MShop\Catalog\Item\Standard or Aimeos\MShop\Plugin\Item\Standard or Aimeos\MShop\Locale\Item\Site\Standard or Aimeos\MShop\Common\Item\Lists\Standard or Aimeos\MShop\Service\Item\Standard or Aimeos\MShop\Coupon\Item\Standard or Aimeos\MShop\Product\Item\Standard or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Service\Item\Iface or Aimeos\MShop\Coupon\Item\Iface or Aimeos\MShop\Common\Item\Lists\Iface or Aimeos\MShop\Plugin\Item\Iface or Aimeos\MShop\Locale\Item\Site\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Service\Item\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Product\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

547
		$item->/** @scrutinizer ignore-call */ 
548
         setConfig( $conf );
Loading history...
548
549
		return $item;
550
	}
551
552
553
	/**
554
	 * Constructs the data array for the view from the given item
555
	 *
556
	 * @param \Aimeos\MShop\Coupon\Item\Iface $item Coupon item object
557
	 * @return string[] Multi-dimensional associative list of item data
558
	 */
559
	protected function toArray( \Aimeos\MShop\Coupon\Item\Iface $item, $copy = false )
560
	{
561
		$config = $item->getConfig();
562
		$data = $item->toArray( true );
563
		$data['config'] = [];
564
565
		if( $copy === true )
566
		{
567
			$data['coupon.siteid'] = $this->getContext()->getLocale()->getSiteId();
568
			$data['coupon.id'] = '';
569
		}
570
571
		ksort( $config );
572
573
		foreach( $config as $key => $value )
574
		{
575
			$data['config']['key'][] = $key;
576
			$data['config']['val'][] = $value;
577
		}
578
579
		return $data;
580
	}
581
582
583
	/**
584
	 * Returns the rendered template including the view data
585
	 *
586
	 * @param \Aimeos\MW\View\Iface $view View object with data assigned
587
	 * @return string HTML output
588
	 */
589
	protected function render( \Aimeos\MW\View\Iface $view )
590
	{
591
		/** admin/jqadm/coupon/template-item
592
		 * Relative path to the HTML body template for the coupon item.
593
		 *
594
		 * The template file contains the HTML code and processing instructions
595
		 * to generate the result shown in the body of the frontend. The
596
		 * configuration string is the path to the template file relative
597
		 * to the templates directory (usually in admin/jqadm/templates).
598
		 *
599
		 * You can overwrite the template file configuration in extensions and
600
		 * provide alternative templates. These alternative templates should be
601
		 * named like the default one but with the string "default" replaced by
602
		 * an unique name. You may use the name of your project for this. If
603
		 * you've implemented an alternative client class as well, "default"
604
		 * should be replaced by the name of the new class.
605
		 *
606
		 * @param string Relative path to the template creating the HTML code
607
		 * @since 2016.04
608
		 * @category Developer
609
		 */
610
		$tplconf = 'admin/jqadm/coupon/template-item';
611
		$default = 'coupon/item-standard';
612
613
		return $view->render( $view->config( $tplconf, $default ) );
614
	}
615
}
616