Passed
Push — master ( c849da...40fa28 )
by Aimeos
03:59
created

Standard::getUrlUpdate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 74
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 74
rs 10
c 0
b 0
f 0

How to fix   Long Method   

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), 2015-2018
6
 * @package Client
7
 * @subpackage Html
8
 */
9
10
11
namespace Aimeos\Client\Html\Checkout\Standard\Process;
12
13
14
// Strings for translation
15
sprintf( 'process' );
16
17
18
/**
19
 * Default implementation of checkout process HTML client.
20
 *
21
 * @package Client
22
 * @subpackage Html
23
 */
24
class Standard
25
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
26
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
27
{
28
	/** client/html/checkout/standard/process/standard/subparts
29
	 * List of HTML sub-clients rendered within the checkout standard process section
30
	 *
31
	 * The output of the frontend is composed of the code generated by the HTML
32
	 * clients. Each HTML client can consist of serveral (or none) sub-clients
33
	 * that are responsible for rendering certain sub-parts of the output. The
34
	 * sub-clients can contain HTML clients themselves and therefore a
35
	 * hierarchical tree of HTML clients is composed. Each HTML client creates
36
	 * the output that is placed inside the container of its parent.
37
	 *
38
	 * At first, always the HTML code generated by the parent is printed, then
39
	 * the HTML code of its sub-clients. The order of the HTML sub-clients
40
	 * determines the order of the output of these sub-clients inside the parent
41
	 * container. If the configured list of clients is
42
	 *
43
	 *  array( "subclient1", "subclient2" )
44
	 *
45
	 * you can easily change the order of the output by reordering the subparts:
46
	 *
47
	 *  client/html/<clients>/subparts = array( "subclient1", "subclient2" )
48
	 *
49
	 * You can also remove one or more parts if they shouldn't be rendered:
50
	 *
51
	 *  client/html/<clients>/subparts = array( "subclient1" )
52
	 *
53
	 * As the clients only generates structural HTML, the layout defined via CSS
54
	 * should support adding, removing or reordering content by a fluid like
55
	 * design.
56
	 *
57
	 * @param array List of sub-client names
58
	 * @since 2014.03
59
	 * @category Developer
60
	 */
61
	private $subPartPath = 'client/html/checkout/standard/process/standard/subparts';
62
63
	/** client/html/checkout/standard/process/account/name
64
	 * Name of the account part used by the checkout standard process client implementation
65
	 *
66
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Checkout\Standard\Process\Account\Myname".
67
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
68
	 *
69
	 * @param string Last part of the client class name
70
	 * @since 2017.04
71
	 * @category Developer
72
	 */
73
74
	/** client/html/checkout/standard/process/address/name
75
	 * Name of the address part used by the checkout standard process client implementation
76
	 *
77
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Checkout\Standard\Process\Address\Myname".
78
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
79
	 *
80
	 * @param string Last part of the client class name
81
	 * @since 2017.04
82
	 * @category Developer
83
	 */
84
	private $subPartNames = array( 'account', 'address' );
85
86
87
	/**
88
	 * Returns the HTML code for insertion into the body.
89
	 *
90
	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
91
	 * @return string HTML code
92
	 */
93
	public function getBody( $uid = '' )
94
	{
95
		$view = $this->getView();
96
97
		if( $view->get( 'standardStepActive' ) !== 'process' ) {
98
			return '';
99
		}
100
101
		$html = '';
102
		foreach( $this->getSubClients() as $subclient ) {
103
			$html .= $subclient->setView( $view )->getBody( $uid );
104
		}
105
		$view->processBody = $html;
106
107
		/** client/html/checkout/standard/process/standard/template-body
108
		 * Relative path to the HTML body template of the checkout standard process client.
109
		 *
110
		 * The template file contains the HTML code and processing instructions
111
		 * to generate the result shown in the body of the frontend. The
112
		 * configuration string is the path to the template file relative
113
		 * to the templates directory (usually in client/html/templates).
114
		 *
115
		 * You can overwrite the template file configuration in extensions and
116
		 * provide alternative templates. These alternative templates should be
117
		 * named like the default one but with the string "standard" replaced by
118
		 * an unique name. You may use the name of your project for this. If
119
		 * you've implemented an alternative client class as well, "standard"
120
		 * should be replaced by the name of the new class.
121
		 *
122
		 * @param string Relative path to the template creating code for the HTML page body
123
		 * @since 2014.03
124
		 * @category Developer
125
		 * @see client/html/checkout/standard/process/standard/template-header
126
		 */
127
		$tplconf = 'client/html/checkout/standard/process/standard/template-body';
128
		$default = 'checkout/standard/process-body-standard';
129
130
		return $view->render( $view->config( $tplconf, $default ) );
131
	}
132
133
134
	/**
135
	 * Returns the HTML string for insertion into the header.
136
	 *
137
	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
138
	 * @return string|null String including HTML tags for the header on error
139
	 */
140
	public function getHeader( $uid = '' )
141
	{
142
		$view = $this->getView();
143
144
		if( $view->get( 'standardStepActive' ) !== 'process' ) {
145
			return '';
146
		}
147
148
		return parent::getHeader( $uid );
149
	}
150
151
152
	/**
153
	 * Returns the sub-client given by its name.
154
	 *
155
	 * @param string $type Name of the client type
156
	 * @param string|null $name Name of the sub-client (Default if null)
157
	 * @return \Aimeos\Client\Html\Iface Sub-client object
158
	 */
159
	public function getSubClient( $type, $name = null )
160
	{
161
		/** client/html/checkout/standard/process/decorators/excludes
162
		 * Excludes decorators added by the "common" option from the checkout standard process html client
163
		 *
164
		 * Decorators extend the functionality of a class by adding new aspects
165
		 * (e.g. log what is currently done), executing the methods of the underlying
166
		 * class only in certain conditions (e.g. only for logged in users) or
167
		 * modify what is returned to the caller.
168
		 *
169
		 * This option allows you to remove a decorator added via
170
		 * "client/html/common/decorators/default" before they are wrapped
171
		 * around the html client.
172
		 *
173
		 *  client/html/checkout/standard/process/decorators/excludes = array( 'decorator1' )
174
		 *
175
		 * This would remove the decorator named "decorator1" from the list of
176
		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
177
		 * "client/html/common/decorators/default" to the html client.
178
		 *
179
		 * @param array List of decorator names
180
		 * @since 2015.08
181
		 * @category Developer
182
		 * @see client/html/common/decorators/default
183
		 * @see client/html/checkout/standard/process/decorators/global
184
		 * @see client/html/checkout/standard/process/decorators/local
185
		 */
186
187
		/** client/html/checkout/standard/process/decorators/global
188
		 * Adds a list of globally available decorators only to the checkout standard process html client
189
		 *
190
		 * Decorators extend the functionality of a class by adding new aspects
191
		 * (e.g. log what is currently done), executing the methods of the underlying
192
		 * class only in certain conditions (e.g. only for logged in users) or
193
		 * modify what is returned to the caller.
194
		 *
195
		 * This option allows you to wrap global decorators
196
		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
197
		 *
198
		 *  client/html/checkout/standard/process/decorators/global = array( 'decorator1' )
199
		 *
200
		 * This would add the decorator named "decorator1" defined by
201
		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
202
		 *
203
		 * @param array List of decorator names
204
		 * @since 2015.08
205
		 * @category Developer
206
		 * @see client/html/common/decorators/default
207
		 * @see client/html/checkout/standard/process/decorators/excludes
208
		 * @see client/html/checkout/standard/process/decorators/local
209
		 */
210
211
		/** client/html/checkout/standard/process/decorators/local
212
		 * Adds a list of local decorators only to the checkout standard process html client
213
		 *
214
		 * Decorators extend the functionality of a class by adding new aspects
215
		 * (e.g. log what is currently done), executing the methods of the underlying
216
		 * class only in certain conditions (e.g. only for logged in users) or
217
		 * modify what is returned to the caller.
218
		 *
219
		 * This option allows you to wrap local decorators
220
		 * ("\Aimeos\Client\Html\Checkout\Decorator\*") around the html client.
221
		 *
222
		 *  client/html/checkout/standard/process/decorators/local = array( 'decorator2' )
223
		 *
224
		 * This would add the decorator named "decorator2" defined by
225
		 * "\Aimeos\Client\Html\Checkout\Decorator\Decorator2" only to the html client.
226
		 *
227
		 * @param array List of decorator names
228
		 * @since 2015.08
229
		 * @category Developer
230
		 * @see client/html/common/decorators/default
231
		 * @see client/html/checkout/standard/process/decorators/excludes
232
		 * @see client/html/checkout/standard/process/decorators/global
233
		 */
234
235
		return $this->createSubClient( 'checkout/standard/process/' . $type, $name );
236
	}
237
238
239
	/**
240
	 * Processes the input, e.g. store given order.
241
	 * A view must be available and this method doesn't generate any output
242
	 * besides setting view variables.
243
	 */
244
	public function process()
245
	{
246
		$view = $this->getView();
247
		$context = $this->getContext();
248
249
		if( $view->param( 'c_step' ) !== 'process'
250
			|| $view->get( 'standardErrorList', [] ) !== []
251
			|| $view->get( 'standardStepActive' ) !== null
252
		) {
253
			return;
254
		}
255
256
		try
257
		{
258
			$orderCntl = \Aimeos\Controller\Frontend::create( $context, 'order' );
259
			$basketCntl = \Aimeos\Controller\Frontend::create( $context, 'basket' );
260
261
262
			if( $view->param( 'cs_order', null ) !== null )
263
			{
264
				parent::process();
265
266
				$basket = $basketCntl->store();
267
				$orderItem = $orderCntl->add( $basket->getId(), ['order.type' => 'web'] )->store();
268
269
				$context->getSession()->set( 'aimeos/orderid', $orderItem->getId() );
270
			}
271
			elseif( $view->param( 'cp_payment', null ) !== null )
272
			{
273
				$parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL;
274
				$orderItem = $orderCntl->get( $context->getSession()->get( 'aimeos/orderid' ), false );
275
				$basket = $basketCntl->load( $orderItem->getBaseId(), $parts, false );
276
			}
277
			else
278
			{
279
				return;
280
			}
281
282
			if( ( $form = $this->processPayment( $basket, $orderItem ) ) !== null )
283
			{
284
				$view->standardUrlNext = $form->getUrl();
285
				$view->standardMethod = $form->getMethod();
286
				$view->standardProcessParams = $form->getValues();
287
				$view->standardUrlExternal = $form->getExternal();
288
				$view->standardHtml = $form->getHtml();
289
			}
290
			else // no payment service available
291
			{
292
				$orderCntl->save( $orderItem->setPaymentStatus( \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED ) );
293
				$view->standardUrlNext = $this->getUrlConfirm( $view, [], [] );
294
				$view->standardMethod = 'POST';
295
			}
296
		}
297
		catch( \Aimeos\Client\Html\Exception $e )
298
		{
299
			$error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) );
300
			$view->standardErrorList = array_merge($view->get( 'standardErrorList', [] ), $error);
301
		}
302
		catch( \Aimeos\Controller\Frontend\Exception $e )
303
		{
304
			$error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
305
			$view->standardErrorList = array_merge($view->get( 'standardErrorList', [] ), $error);
306
		}
307
		catch( \Aimeos\MShop\Exception $e )
308
		{
309
			$error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
310
			$view->standardErrorList = array_merge($view->get( 'standardErrorList', [] ), $error);
311
		}
312
		catch( \Exception $e )
313
		{
314
			$error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
315
			$view->standardErrorList = array_merge($view->get( 'standardErrorList', [] ), $error);
316
			$this->logException( $e );
317
		}
318
	}
319
320
321
	/**
322
	 * Returns the form helper object for building the payment form in the frontend
323
	 *
324
	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Saved basket object including payment service object
325
	 * @param \Aimeos\MShop\Order\Item\Iface $orderItem Saved order item created for the basket object
326
	 * @return \Aimeos\MShop\Common\Helper\Form\Iface|null Form object with URL, parameters, etc.
327
	 * 	or null if no form data is required
328
	 */
329
	protected function processPayment( \Aimeos\MShop\Order\Item\Base\Iface $basket, \Aimeos\MShop\Order\Item\Iface $orderItem )
330
	{
331
		$view = $this->getView();
332
		$services = $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT );
333
334
		if( ( $service = reset( $services ) ) !== false )
335
		{
336
			$args = array( 'code' => $service->getCode() );
337
			$config = array( 'absoluteUri' => true, 'namespace' => false );
338
			$urls = array(
339
				'payment.url-self' => $this->getUrlSelf( $view, ['c_step' => 'process'], [] ),
340
				'payment.url-update' => $this->getUrlUpdate( $view, $args + ['orderid' => $orderItem->getId()], $config ),
341
				'payment.url-success' => $this->getUrlConfirm( $view, $args, $config ),
342
			);
343
344
			$params = $view->param();
345
			foreach( $service->getAttributeItems() as $item ) {
346
				$params[$item->getCode()] = $item->getValue();
347
			}
348
349
			$serviceCntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'service' );
350
			return $serviceCntl->process( $orderItem, $service->getServiceId(), $urls, $params );
351
		}
352
	}
353
354
355
	/**
356
	 * Returns the list of sub-client names configured for the client.
357
	 *
358
	 * @return array List of HTML client names
359
	 */
360
	protected function getSubClientNames()
361
	{
362
		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
363
	}
364
365
366
	/**
367
	 * Returns the URL to the confirm page.
368
	 *
369
	 * @param \Aimeos\MW\View\Iface $view View object
370
	 * @param array $params Parameters that should be part of the URL
371
	 * @param array $config Default URL configuration
372
	 * @return string URL string
373
	 */
374
	protected function getUrlConfirm( \Aimeos\MW\View\Iface $view, array $params, array $config )
375
	{
376
		/** client/html/checkout/confirm/url/target
377
		 * Destination of the URL where the controller specified in the URL is known
378
		 *
379
		 * The destination can be a page ID like in a content management system or the
380
		 * module of a software development framework. This "target" must contain or know
381
		 * the controller that should be called by the generated URL.
382
		 *
383
		 * @param string Destination of the URL
384
		 * @since 2014.03
385
		 * @category Developer
386
		 * @see client/html/checkout/confirm/url/controller
387
		 * @see client/html/checkout/confirm/url/action
388
		 * @see client/html/checkout/confirm/url/config
389
		 */
390
		$target = $view->config( 'client/html/checkout/confirm/url/target' );
391
392
		/** client/html/checkout/confirm/url/controller
393
		 * Name of the controller whose action should be called
394
		 *
395
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
396
		 * that create parts of the output displayed in the generated HTML page. Controller
397
		 * names are usually alpha-numeric.
398
		 *
399
		 * @param string Name of the controller
400
		 * @since 2014.03
401
		 * @category Developer
402
		 * @see client/html/checkout/confirm/url/target
403
		 * @see client/html/checkout/confirm/url/action
404
		 * @see client/html/checkout/confirm/url/config
405
		 */
406
		$cntl = $view->config( 'client/html/checkout/confirm/url/controller', 'checkout' );
407
408
		/** client/html/checkout/confirm/url/action
409
		 * Name of the action that should create the output
410
		 *
411
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
412
		 * controller that create parts of the output displayed in the generated HTML page.
413
		 * Action names are usually alpha-numeric.
414
		 *
415
		 * @param string Name of the action
416
		 * @since 2014.03
417
		 * @category Developer
418
		 * @see client/html/checkout/confirm/url/target
419
		 * @see client/html/checkout/confirm/url/controller
420
		 * @see client/html/checkout/confirm/url/config
421
		 */
422
		$action = $view->config( 'client/html/checkout/confirm/url/action', 'confirm' );
423
424
		/** client/html/checkout/confirm/url/config
425
		 * Associative list of configuration options used for generating the URL
426
		 *
427
		 * You can specify additional options as key/value pairs used when generating
428
		 * the URLs, like
429
		 *
430
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
431
		 *
432
		 * The available key/value pairs depend on the application that embeds the e-commerce
433
		 * framework. This is because the infrastructure of the application is used for
434
		 * generating the URLs. The full list of available config options is referenced
435
		 * in the "see also" section of this page.
436
		 *
437
		 * @param string Associative list of configuration options
438
		 * @since 2014.03
439
		 * @category Developer
440
		 * @see client/html/checkout/confirm/url/target
441
		 * @see client/html/checkout/confirm/url/controller
442
		 * @see client/html/checkout/confirm/url/action
443
		 * @see client/html/url/config
444
		 */
445
		$config = $view->config( 'client/html/checkout/confirm/url/config', $config );
446
447
		return $view->url( $target, $cntl, $action, $params, [], $config );
448
	}
449
450
451
	/**
452
	 * Returns the URL to the current page.
453
	 *
454
	 * @param \Aimeos\MW\View\Iface $view View object
455
	 * @param array $params Parameters that should be part of the URL
456
	 * @param array $config Default URL configuration
457
	 * @return string URL string
458
	 */
459
	protected function getUrlSelf( \Aimeos\MW\View\Iface $view, array $params, array $config )
460
	{
461
		/** client/html/checkout/standard/url/target
462
		 * Destination of the URL where the controller specified in the URL is known
463
		 *
464
		 * The destination can be a page ID like in a content management system or the
465
		 * module of a software development framework. This "target" must contain or know
466
		 * the controller that should be called by the generated URL.
467
		 *
468
		 * @param string Destination of the URL
469
		 * @since 2014.03
470
		 * @category Developer
471
		 * @see client/html/checkout/standard/url/controller
472
		 * @see client/html/checkout/standard/url/action
473
		 * @see client/html/checkout/standard/url/config
474
		 */
475
		$target = $view->config( 'client/html/checkout/standard/url/target' );
476
477
		/** client/html/checkout/standard/url/controller
478
		 * Name of the controller whose action should be called
479
		 *
480
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
481
		 * that create parts of the output displayed in the generated HTML page. Controller
482
		 * names are usually alpha-numeric.
483
		 *
484
		 * @param string Name of the controller
485
		 * @since 2014.03
486
		 * @category Developer
487
		 * @see client/html/checkout/standard/url/target
488
		 * @see client/html/checkout/standard/url/action
489
		 * @see client/html/checkout/standard/url/config
490
		 */
491
		$cntl = $view->config( 'client/html/checkout/standard/url/controller', 'checkout' );
492
493
		/** client/html/checkout/standard/url/action
494
		 * Name of the action that should create the output
495
		 *
496
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
497
		 * controller that create parts of the output displayed in the generated HTML page.
498
		 * Action names are usually alpha-numeric.
499
		 *
500
		 * @param string Name of the action
501
		 * @since 2014.03
502
		 * @category Developer
503
		 * @see client/html/checkout/standard/url/target
504
		 * @see client/html/checkout/standard/url/controller
505
		 * @see client/html/checkout/standard/url/config
506
		 */
507
		$action = $view->config( 'client/html/checkout/standard/url/action', 'index' );
508
509
		/** client/html/checkout/standard/url/config
510
		 * Associative list of configuration options used for generating the URL
511
		 *
512
		 * You can specify additional options as key/value pairs used when generating
513
		 * the URLs, like
514
		 *
515
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
516
		 *
517
		 * The available key/value pairs depend on the application that embeds the e-commerce
518
		 * framework. This is because the infrastructure of the application is used for
519
		 * generating the URLs. The full list of available config options is referenced
520
		 * in the "see also" section of this page.
521
		 *
522
		 * @param string Associative list of configuration options
523
		 * @since 2014.03
524
		 * @category Developer
525
		 * @see client/html/checkout/standard/url/target
526
		 * @see client/html/checkout/standard/url/controller
527
		 * @see client/html/checkout/standard/url/action
528
		 * @see client/html/url/config
529
		 */
530
		$config = $view->config( 'client/html/checkout/standard/url/config', $config );
531
532
		return $view->url( $target, $cntl, $action, $params, [], $config );
533
	}
534
535
536
	/**
537
	 * Returns the URL to the update page.
538
	 *
539
	 * @param \Aimeos\MW\View\Iface $view View object
540
	 * @param array $params Parameters that should be part of the URL
541
	 * @param array $config Default URL configuration
542
	 * @return string URL string
543
	 */
544
	protected function getUrlUpdate( \Aimeos\MW\View\Iface $view, array $params, array $config )
545
	{
546
		/** client/html/checkout/update/url/target
547
		 * Destination of the URL where the controller specified in the URL is known
548
		 *
549
		 * The destination can be a page ID like in a content management system or the
550
		 * module of a software development framework. This "target" must contain or know
551
		 * the controller that should be called by the generated URL.
552
		 *
553
		 * @param string Destination of the URL
554
		 * @since 2014.03
555
		 * @category Developer
556
		 * @see client/html/checkout/update/url/controller
557
		 * @see client/html/checkout/update/url/action
558
		 * @see client/html/checkout/update/url/config
559
		 */
560
		$target = $view->config( 'client/html/checkout/update/url/target' );
561
562
		/** client/html/checkout/update/url/controller
563
		 * Name of the controller whose action should be called
564
		 *
565
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
566
		 * that create parts of the output displayed in the generated HTML page. Controller
567
		 * names are usually alpha-numeric.
568
		 *
569
		 * @param string Name of the controller
570
		 * @since 2014.03
571
		 * @category Developer
572
		 * @see client/html/checkout/update/url/target
573
		 * @see client/html/checkout/update/url/action
574
		 * @see client/html/checkout/update/url/config
575
		 */
576
		$cntl = $view->config( 'client/html/checkout/update/url/controller', 'checkout' );
577
578
		/** client/html/checkout/update/url/action
579
		 * Name of the action that should create the output
580
		 *
581
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
582
		 * controller that create parts of the output displayed in the generated HTML page.
583
		 * Action names are usually alpha-numeric.
584
		 *
585
		 * @param string Name of the action
586
		 * @since 2014.03
587
		 * @category Developer
588
		 * @see client/html/checkout/update/url/target
589
		 * @see client/html/checkout/update/url/controller
590
		 * @see client/html/checkout/update/url/config
591
		 */
592
		$action = $view->config( 'client/html/checkout/update/url/action', 'update' );
593
594
		/** client/html/checkout/update/url/config
595
		 * Associative list of configuration options used for generating the URL
596
		 *
597
		 * You can specify additional options as key/value pairs used when generating
598
		 * the URLs, like
599
		 *
600
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
601
		 *
602
		 * The available key/value pairs depend on the application that embeds the e-commerce
603
		 * framework. This is because the infrastructure of the application is used for
604
		 * generating the URLs. The full list of available config options is referenced
605
		 * in the "see also" section of this page.
606
		 *
607
		 * @param string Associative list of configuration options
608
		 * @since 2014.03
609
		 * @category Developer
610
		 * @see client/html/checkout/update/url/target
611
		 * @see client/html/checkout/update/url/controller
612
		 * @see client/html/checkout/update/url/action
613
		 * @see client/html/url/config
614
		 */
615
		$config = $view->config( 'client/html/checkout/update/url/config', $config );
616
617
		return $view->url( $target, $cntl, $action, $params, [], $config );
618
	}
619
620
621
	/**
622
	 * Tests if one of the products is a subscription
623
	 *
624
	 * @param \Aimeos\MShop\Order\Item\Base\Product\Iface[] $products Ordered products
625
	 * @return boolean True if at least one product is a subscription, false if not
626
	 */
627
	protected function isSubscription( array $products )
628
	{
629
		foreach( $products as $orderProduct )
630
		{
631
			if( $orderProduct->getAttributeItem( 'interval', 'config' ) ) {
632
				return true;
633
			}
634
		}
635
636
		return false;
637
	}
638
639
640
	/**
641
	 * Sets the necessary parameter values in the view.
642
	 *
643
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
644
	 * @param array &$tags Result array for the list of tags that are associated to the output
645
	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
646
	 * @return \Aimeos\MW\View\Iface Modified view object
647
	 */
648
	public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expire = null )
649
	{
650
		$view->standardUrlPayment = $this->getUrlSelf( $view, array( 'c_step' => 'payment' ), [] );
651
652
		return parent::addData( $view, $tags, $expire );
653
	}
654
}
655