Standard::toArray()   F
last analyzed

Complexity

Conditions 16
Paths 1344

Size

Total Lines 88
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 16
eloc 42
c 4
b 0
f 0
nc 1344
nop 2
dl 0
loc 88
rs 1.4

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2025
6
 * @package Admin
7
 * @subpackage JQAdm
8
 */
9
10
11
namespace Aimeos\Admin\JQAdm\Order;
12
13
sprintf( 'sales' ); // for translation
14
sprintf( 'order' ); // for translation
15
16
17
/**
18
 * Default implementation of order JQAdm client.
19
 *
20
 * @package Admin
21
 * @subpackage JQAdm
22
 */
23
class Standard
24
	extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base
25
	implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface
26
{
27
	/** admin/jqadm/order/name
28
	 * Class name of the used order panel implementation
29
	 *
30
	 * Each default admin client can be replace by an alternative imlementation.
31
	 * To use this implementation, you have to set the last part of the class
32
	 * name as configuration value so the client factory knows which class it
33
	 * has to instantiate.
34
	 *
35
	 * For example, if the name of the default class is
36
	 *
37
	 *  \Aimeos\Admin\JQAdm\Order\Standard
38
	 *
39
	 * and you want to replace it with your own version named
40
	 *
41
	 *  \Aimeos\Admin\JQAdm\Order\Myfavorite
42
	 *
43
	 * then you have to set the this configuration option:
44
	 *
45
	 *  admin/jqadm/order/name = Myfavorite
46
	 *
47
	 * The value is the last part of your own class name and it's case sensitive,
48
	 * so take care that the configuration value is exactly named like the last
49
	 * part of the class name.
50
	 *
51
	 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
52
	 * characters are possible! You should always start the last part of the class
53
	 * name with an upper case character and continue only with lower case characters
54
	 * or numbers. Avoid chamel case names like "MyFavorite"!
55
	 *
56
	 * @param string Last part of the class name
57
	 * @since 2016.01
58
	 */
59
60
61
	/**
62
	 * Adds the required data used in the template
63
	 *
64
	 * @param \Aimeos\Base\View\Iface $view View object
65
	 * @return \Aimeos\Base\View\Iface View object with assigned parameters
66
	 */
67
	public function data( \Aimeos\Base\View\Iface $view ) : \Aimeos\Base\View\Iface
68
	{
69
		$codes = [];
70
71
		foreach( $this->context()->config()->get( 'common/countries', [] ) as $code ) {
72
			$codes[$code] = $view->translate( 'country', $code );
73
		}
74
75
		asort( $codes );
76
77
		$view->itemSubparts = $this->getSubClientNames();
78
		$view->countries = $codes;
79
		return $view;
80
	}
81
82
83
	/**
84
	 * Batch update of a resource
85
	 *
86
	 * @return string|null Output to display
87
	 */
88
	public function batch() : ?string
89
	{
90
		return $this->batchBase( 'order' );
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->batchBase('order') targeting Aimeos\Admin\JQAdm\Base::batchBase() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
91
	}
92
93
94
	/**
95
	 * Copies a resource
96
	 *
97
	 * @return string|null HTML output
98
	 */
99
	public function copy() : ?string
100
	{
101
		$context = $this->context();
102
		$view = $this->object()->data( $this->view() );
103
104
		try
105
		{
106
			if( ( $id = $view->param( 'id' ) ) === null )
107
			{
108
				$msg = $context->translate( 'admin', 'Required parameter "%1$s" is missing' );
109
				throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, 'id' ) );
110
			}
111
112
			$manager = \Aimeos\MShop::create( $context, 'order' );
113
			$refs = $context->config()->get( 'mshop/order/manager/subdomains', [] );
114
115
			$view->item = $manager->get( $id, $refs );
116
			$view->itemData = $this->toArray( $view->item, true );
117
			$view->itemBody = parent::copy();
118
		}
119
		catch( \Exception $e )
120
		{
121
			$this->report( $e, 'copy' );
122
		}
123
124
		return $this->render( $view );
125
	}
126
127
128
	/**
129
	 * Creates a new resource
130
	 *
131
	 * @return string|null HTML output
132
	 */
133
	public function create() : ?string
134
	{
135
		$view = $this->object()->data( $this->view() );
136
137
		try
138
		{
139
			$data = $view->param( 'item', [] );
140
141
			if( !isset( $view->item ) ) {
142
				$view->item = \Aimeos\MShop::create( $this->context(), 'order' )->create();
143
			}
144
145
			$data['order.siteid'] = $view->item->getSiteId();
146
147
			$view->itemData = array_replace_recursive( $this->toArray( $view->item ), $data );
148
			$view->itemBody = parent::create();
149
		}
150
		catch( \Exception $e )
151
		{
152
			$this->report( $e, 'create' );
153
		}
154
155
		return $this->render( $view );
156
	}
157
158
159
	/**
160
	 * Exports a resource
161
	 *
162
	 * @return string Admin output to display
163
	 */
164
	public function export() : ?string
165
	{
166
		$view = $this->view();
167
		$context = $this->context();
168
169
		try
170
		{
171
			$params = $this->storeFilter( $view->param(), 'order' );
172
			$msg = ['sitecode' => $context->locale()->getSiteItem()->getCode()];
173
174
			if( isset( $params['filter'] ) ) {
175
				$msg['filter'] = $this->getCriteriaConditions( (array) $params['filter'] );
176
			}
177
178
			if( isset( $params['sort'] ) ) {
179
				$msg['sort'] = (array) $params['sort'];
180
			}
181
182
			$queue = $view->param( 'queue', 'order-export' );
183
			$mq = $context->queue( 'mq-admin', $queue );
184
			$mq->add( json_encode( $msg ) );
185
186
			$msg = $context->translate( 'admin', 'Your export will be available in a few minutes for download' );
187
			$view->info = $view->get( 'info', [] ) + ['order-item' => $msg];
188
		}
189
		catch( \Exception $e )
190
		{
191
			$this->report( $e, 'export' );
192
		}
193
194
		return $this->search();
195
	}
196
197
198
	/**
199
	 * Returns a single resource
200
	 *
201
	 * @return string|null HTML output
202
	 */
203
	public function get() : ?string
204
	{
205
		$context = $this->context();
206
		$view = $this->object()->data( $this->view() );
207
208
		try
209
		{
210
			if( ( $id = $view->param( 'id' ) ) === null )
211
			{
212
				$msg = $context->translate( 'admin', 'Required parameter "%1$s" is missing' );
213
				throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, 'id' ) );
214
			}
215
216
			$manager = \Aimeos\MShop::create( $context, 'order' );
217
			$refs = $context->config()->get( 'mshop/order/manager/subdomains', [] );
218
219
			$view->item = $manager->get( $id, $refs );
220
			$view->itemData = $this->toArray( $view->item );
221
			$view->itemBody = parent::get();
222
		}
223
		catch( \Exception $e )
224
		{
225
			$this->report( $e, 'get' );
226
		}
227
228
		return $this->render( $view );
229
	}
230
231
232
	/**
233
	 * Saves the data
234
	 *
235
	 * @return string|null HTML output
236
	 */
237
	public function save() : ?string
238
	{
239
		$view = $this->view();
240
241
		$manager = \Aimeos\MShop::create( $this->context(), 'order' );
242
		$manager->begin();
243
244
		try
245
		{
246
			$item = $this->fromArray( $view->param( 'item', [] ) );
247
			$view->item = $item->getId() ? $item : $manager->save( clone $item );
248
			$view->itemBody = parent::save();
249
250
			$manager->save( clone $view->item );
251
			$manager->update( $view->item ); // update stock, coupons, etc.
252
			$manager->commit();
253
254
			return $this->redirect( 'order', $view->param( 'next' ), $view->item->getId(), 'save' );
0 ignored issues
show
Bug introduced by
It seems like $view->item->getId() can also be of type Aimeos\Map; however, parameter $id of Aimeos\Admin\JQAdm\Base::redirect() does only seem to accept null|string, maybe add an additional type check? ( Ignorable by Annotation )

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

254
			return $this->redirect( 'order', $view->param( 'next' ), /** @scrutinizer ignore-type */ $view->item->getId(), 'save' );
Loading history...
255
		}
256
		catch( \Exception $e )
257
		{
258
			$manager->rollback();
259
			$this->report( $e, 'save' );
260
		}
261
262
		return $this->create();
263
	}
264
265
266
	/**
267
	 * Returns a list of resource according to the conditions
268
	 *
269
	 * @return string|null HTML output
270
	 */
271
	public function search() : ?string
272
	{
273
		$view = $this->view();
274
275
		try
276
		{
277
			$total = 0;
278
			$context = $this->context();
279
			$refs = $context->config()->get( 'mshop/order/manager/subdomains', [] );
280
281
			$manager = \Aimeos\MShop::create( $context, 'order' );
282
			$params = $this->storeFilter( $view->param(), 'order' );
283
284
			$search = $manager->filter( false, true )->order( '-order.id' );
285
			$search = $this->initCriteria( $search, $params );
286
287
			$view->items = $manager->search( $search, $refs, $total );
288
			$view->filterAttributes = $manager->getSearchAttributes( true );
289
			$view->filterOperators = $search->getOperators();
290
			$view->itemBody = parent::search();
291
			$view->total = $total;
292
		}
293
		catch( \Exception $e )
294
		{
295
			$this->report( $e, 'search' );
296
		}
297
298
		/** admin/jqadm/order/template-list
299
		 * Relative path to the HTML body template for the order list.
300
		 *
301
		 * The template file contains the HTML code and processing instructions
302
		 * to generate the result shown in the body of the frontend. The
303
		 * configuration string is the path to the template file relative
304
		 * to the templates directory (usually in templates/admin/jqadm).
305
		 *
306
		 * You can overwrite the template file configuration in extensions and
307
		 * provide alternative templates. These alternative templates should be
308
		 * named like the default one but with the string "default" replaced by
309
		 * an unique name. You may use the name of your project for this. If
310
		 * you've implemented an alternative client class as well, "default"
311
		 * should be replaced by the name of the new class.
312
		 *
313
		 * @param string Relative path to the template creating the HTML code
314
		 * @since 2016.04
315
		 */
316
		$tplconf = 'admin/jqadm/order/template-list';
317
		$default = 'order/list';
318
319
		return $view->render( $view->config( $tplconf, $default ) );
320
	}
321
322
323
	/**
324
	 * Returns the sub-client given by its name.
325
	 *
326
	 * @param string $type Name of the client type
327
	 * @param string|null $name Name of the sub-client (Default if null)
328
	 * @return \Aimeos\Admin\JQAdm\Iface Sub-client object
329
	 */
330
	public function getSubClient( string $type, ?string $name = null ) : \Aimeos\Admin\JQAdm\Iface
331
	{
332
		/** admin/jqadm/order/decorators/excludes
333
		 * Excludes decorators added by the "common" option from the order JQAdm client
334
		 *
335
		 * Decorators extend the functionality of a class by adding new aspects
336
		 * (e.g. log what is currently done), executing the methods of the underlying
337
		 * class only in certain conditions (e.g. only for logged in users) or
338
		 * modify what is returned to the caller.
339
		 *
340
		 * This option allows you to remove a decorator added via
341
		 * "client/jqadm/common/decorators/default" before they are wrapped
342
		 * around the JQAdm client.
343
		 *
344
		 *  admin/jqadm/order/decorators/excludes = array( 'decorator1' )
345
		 *
346
		 * This would remove the decorator named "decorator1" from the list of
347
		 * common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via
348
		 * "client/jqadm/common/decorators/default" to the JQAdm client.
349
		 *
350
		 * @param array List of decorator names
351
		 * @since 2016.01
352
		 * @see admin/jqadm/common/decorators/default
353
		 * @see admin/jqadm/order/decorators/global
354
		 * @see admin/jqadm/order/decorators/local
355
		 */
356
357
		/** admin/jqadm/order/decorators/global
358
		 * Adds a list of globally available decorators only to the order JQAdm client
359
		 *
360
		 * Decorators extend the functionality of a class by adding new aspects
361
		 * (e.g. log what is currently done), executing the methods of the underlying
362
		 * class only in certain conditions (e.g. only for logged in users) or
363
		 * modify what is returned to the caller.
364
		 *
365
		 * This option allows you to wrap global decorators
366
		 * ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client.
367
		 *
368
		 *  admin/jqadm/order/decorators/global = array( 'decorator1' )
369
		 *
370
		 * This would add the decorator named "decorator1" defined by
371
		 * "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client.
372
		 *
373
		 * @param array List of decorator names
374
		 * @since 2016.01
375
		 * @see admin/jqadm/common/decorators/default
376
		 * @see admin/jqadm/order/decorators/excludes
377
		 * @see admin/jqadm/order/decorators/local
378
		 */
379
380
		/** admin/jqadm/order/decorators/local
381
		 * Adds a list of local decorators only to the order JQAdm client
382
		 *
383
		 * Decorators extend the functionality of a class by adding new aspects
384
		 * (e.g. log what is currently done), executing the methods of the underlying
385
		 * class only in certain conditions (e.g. only for logged in users) or
386
		 * modify what is returned to the caller.
387
		 *
388
		 * This option allows you to wrap local decorators
389
		 * ("\Aimeos\Admin\JQAdm\Order\Decorator\*") around the JQAdm client.
390
		 *
391
		 *  admin/jqadm/order/decorators/local = array( 'decorator2' )
392
		 *
393
		 * This would add the decorator named "decorator2" defined by
394
		 * "\Aimeos\Admin\JQAdm\Order\Decorator\Decorator2" only to the JQAdm client.
395
		 *
396
		 * @param array List of decorator names
397
		 * @since 2016.01
398
		 * @see admin/jqadm/common/decorators/default
399
		 * @see admin/jqadm/order/decorators/excludes
400
		 * @see admin/jqadm/order/decorators/global
401
		 */
402
		return $this->createSubClient( 'order/' . $type, $name );
403
	}
404
405
406
	/**
407
	 * Returns the allowed keys for updating the item of the given type
408
	 *
409
	 * @param string $type Type of the item, e.g. "order/product"
410
	 * @param array $entry Associative list of key/value pairs
411
	 * @return array Reduced list of key/value pairs
412
	 */
413
	protected function allowed( string $type, array $entry ) : array
414
	{
415
		if( $type === 'order/product' )
416
		{
417
			$allowed = array_flip( [
418
				'order.product.statusdelivery',
419
				'order.product.statuspayment',
420
				'order.product.qtyopen',
421
				'order.product.timeframe',
422
				'order.product.notes',
423
			] );
424
425
			return array_intersect_key( $entry, $allowed );
426
		}
427
428
		return [];
429
	}
430
431
432
	/**
433
	 * Modifies the used attributes from the passed list of order service attributes
434
	 *
435
	 * @param string $type Type of the attribute items, e.g. "order/service/attribute"
436
	 * @param \Aimeos\Map $attrItems List of attribute items
437
	 * @return \Aimeos\Map Modified list of attribute items
438
	 */
439
	protected function attributes( string $type, \Aimeos\Map $attrItems ) : \Aimeos\Map
440
	{
441
		return $attrItems;
442
	}
443
444
445
	/**
446
	 * Returns the excluded attributes from the passed list of order service attributes
447
	 *
448
	 * @param string $type Type of the attribute items, e.g. "order/service/attribute"
449
	 * @param \Aimeos\Map $attrItems List of attribute items
450
	 * @return \Aimeos\Map List of excluded attribute items
451
	 */
452
	protected function excluded( string $type, \Aimeos\Map $attrItems ) : \Aimeos\Map
453
	{
454
		return map();
455
	}
456
457
458
	/**
459
	 * Returns the list of sub-client names configured for the client.
460
	 *
461
	 * @return array List of JQAdm client names
462
	 */
463
	protected function getSubClientNames() : array
464
	{
465
		/** admin/jqadm/order/subparts
466
		 * List of JQAdm sub-clients rendered within the order section
467
		 *
468
		 * The output of the frontend is composed of the code generated by the JQAdm
469
		 * clients. Each JQAdm client can consist of serveral (or none) sub-clients
470
		 * that are responsible for rendering certain sub-parts of the output. The
471
		 * sub-clients can contain JQAdm clients themselves and therefore a
472
		 * hierarchical tree of JQAdm clients is composed. Each JQAdm client creates
473
		 * the output that is placed inside the container of its parent.
474
		 *
475
		 * At first, always the JQAdm code generated by the parent is printed, then
476
		 * the JQAdm code of its sub-clients. The order of the JQAdm sub-clients
477
		 * determines the order of the output of these sub-clients inside the parent
478
		 * container. If the configured list of clients is
479
		 *
480
		 *  array( "subclient1", "subclient2" )
481
		 *
482
		 * you can easily change the order of the output by reordering the subparts:
483
		 *
484
		 *  admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" )
485
		 *
486
		 * You can also remove one or more parts if they shouldn't be rendered:
487
		 *
488
		 *  admin/jqadm/<clients>/subparts = array( "subclient1" )
489
		 *
490
		 * As the clients only generates structural JQAdm, the layout defined via CSS
491
		 * should support adding, removing or reordering content by a fluid like
492
		 * design.
493
		 *
494
		 * @param array List of sub-client names
495
		 * @since 2016.01
496
		 */
497
		return $this->context()->config()->get( 'admin/jqadm/order/subparts', [] );
498
	}
499
500
501
	/**
502
	 * Creates new and updates existing items using the data array
503
	 *
504
	 * @param array $data Data array
505
	 * @return \Aimeos\MShop\Order\Item\Iface New order item object
506
	 */
507
	protected function fromArray( array $data ) : \Aimeos\MShop\Order\Item\Iface
508
	{
509
		$context = $this->context();
510
		$manager = \Aimeos\MShop::create( $context, 'order' );
511
512
		if( isset( $data['order.id'] ) ) {
513
			$refs = $context->config()->get( 'mshop/order/manager/subdomains', [] );
514
			$item = $manager->get( $data['order.id'], $refs )->off();
515
		} else {
516
			$item = $manager->create()->off();
517
		}
518
519
		$item->fromArray( $data, true );
520
521
		foreach( $item->getProducts() as $pos => $product )
522
		{
523
			$list = $this->allowed( 'order/product', $data['product'][$pos] );
524
			$product->fromArray( $list );
525
		}
526
527
		foreach( $item->getAddresses() as $type => $addresses )
528
		{
529
			foreach( $addresses as $pos => $address )
530
			{
531
				if( isset( $data['address'][$type][$pos] ) ) {
532
					$list = (array) $data['address'][$type][$pos];
533
					$item->addAddress( $address->fromArray( $list, true ), $type, $pos );
534
				} else {
535
					$item->deleteAddress( $type, $pos );
536
				}
537
			}
538
		}
539
540
		foreach( $item->getServices() as $type => $services )
541
		{
542
			foreach( $services as $service )
543
			{
544
				$list = [];
545
				$serviceId = $service->getId();
546
				$attrItems = $this->attributes( 'order/service/attribute', $service->getAttributeItems() );
547
				$excluded = $this->excluded( 'order/service/attribute', $service->getAttributeItems() );
548
549
				foreach( $data['service'][$type][$serviceId] ?? [] as $entry )
550
				{
551
					if( !( $value = $entry['order.service.attribute.value'] ?? '' ) ) {
552
						continue;
553
					}
554
555
					$entry = array_filter( $entry );
556
					$entry['order.service.attribute.value'] = json_decode( $value, true ) ?? $value;
557
					$id = $entry['order.service.attribute.id'] ?? '';
558
559
					$attrItem = $attrItems[$id] ?? $manager->createServiceAttribute();
0 ignored issues
show
Bug introduced by
The method createServiceAttribute() does not exist on Aimeos\MShop\Common\Manager\Iface. Did you maybe mean create()? ( Ignorable by Annotation )

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

559
					$attrItem = $attrItems[$id] ?? $manager->/** @scrutinizer ignore-call */ createServiceAttribute();

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...
560
					$list[] = $attrItem->setType( $type )->fromArray( $entry, true );
561
				}
562
563
				$service->setAttributeItems( $excluded->merge( $list ) );
564
			}
565
		}
566
567
		return $item;
568
	}
569
570
571
	/**
572
	 * Constructs the data array for the view from the given item
573
	 *
574
	 * @param \Aimeos\MShop\Order\Item\Iface $item Order item object
575
	 * @return string[] Multi-dimensional associative list of item data
576
	 */
577
	protected function toArray( \Aimeos\MShop\Order\Item\Iface $item, bool $copy = false ) : array
578
	{
579
		$siteId = $this->context()->locale()->getSiteId();
580
		$data = $item->toArray( true );
581
582
		if( $item->getCustomerId() )
583
		{
584
			try {
585
				$data += \Aimeos\MShop::create( $this->context(), 'customer' )->get( $item->getCustomerId() )->toArray();
586
			} catch( \Exception $e ) {};
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
587
		}
588
589
590
		if( $copy === true )
591
		{
592
			$data['order.siteid'] = $siteId;
593
			$data['order.id'] = '';
594
		}
595
596
		foreach( $item->getAddresses() as $type => $addresses )
597
		{
598
			foreach( $addresses as $pos => $addrItem )
599
			{
600
				$data['address'][$type][$pos] = $addrItem->toArray( true );
601
602
				if( $copy === true )
603
				{
604
					$data['address'][$type][$pos]['order.address.siteid'] = $siteId;
605
					$data['address'][$type][$pos]['order.address.id'] = '';
606
				}
607
			}
608
		}
609
610
		foreach( $item->getProducts() as $pos => $productItem )
611
		{
612
			$data['product'][$pos] = $productItem->toArray( true );
613
			$data['product'][$pos]['attributes'] = [];
614
615
			foreach( $productItem->getAttributeItems() as $attrItem )
616
			{
617
				$entry = $attrItem->toArray( true );
618
619
				if( $copy === true )
620
				{
621
					$entry['order.product.attribute.siteid'] = $siteId;
622
					$entry['order.product.attribute.id'] = '';
623
				}
624
625
				$data['product'][$pos]['attributes'][] = $entry;
626
			}
627
628
			if( $copy === true )
629
			{
630
				$data['product'][$pos]['order.product.siteid'] = $siteId;
631
				$data['product'][$pos]['order.product.id'] = '';
632
			}
633
		}
634
635
		foreach( $item->getServices() as $type => $services )
636
		{
637
			foreach( $services as $serviceItem )
638
			{
639
				$serviceId = $serviceItem->getId();
640
				$data['service'][$type][$serviceId] = $serviceItem->toArray( true );
641
				$data['service'][$type][$serviceId]['attributes'] = [];
642
643
				foreach( $this->attributes( 'order/service/attribute', $serviceItem->getAttributeItems() ) as $attrItem )
644
				{
645
					$entry = $attrItem->toArray( true );
646
647
					if( $copy === true )
648
					{
649
						$entry['order.service.attribute.siteid'] = $siteId;
650
						$entry['order.service.attribute.id'] = '';
651
					}
652
653
					$data['service'][$type][$serviceId]['attributes'][] = $entry;
654
				}
655
656
				if( $copy === true )
657
				{
658
					$data['service'][$type][$serviceId]['order.service.siteid'] = $siteId;
659
					$data['service'][$type][$serviceId]['order.service.id'] = '';
660
				}
661
			}
662
		}
663
664
		return $data;
665
	}
666
667
668
	/**
669
	 * Returns the rendered template including the view data
670
	 *
671
	 * @param \Aimeos\Base\View\Iface $view View object with data assigned
672
	 * @return string HTML output
673
	 */
674
	protected function render( \Aimeos\Base\View\Iface $view ) : string
675
	{
676
		/** admin/jqadm/order/template-item
677
		 * Relative path to the HTML body template for the order item.
678
		 *
679
		 * The template file contains the HTML code and processing instructions
680
		 * to generate the result shown in the body of the frontend. The
681
		 * configuration string is the path to the template file relative
682
		 * to the templates directory (usually in templates/admin/jqadm).
683
		 *
684
		 * You can overwrite the template file configuration in extensions and
685
		 * provide alternative templates. These alternative templates should be
686
		 * named like the default one but with the string "default" replaced by
687
		 * an unique name. You may use the name of your project for this. If
688
		 * you've implemented an alternative client class as well, "default"
689
		 * should be replaced by the name of the new class.
690
		 *
691
		 * @param string Relative path to the template creating the HTML code
692
		 * @since 2016.04
693
		 */
694
		$tplconf = 'admin/jqadm/order/template-item';
695
		$default = 'order/item';
696
697
		return $view->render( $view->config( $tplconf, $default ) );
698
	}
699
}
700