Issues (37)

src/Client/Html/Checkout/Update/Standard.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2015-2025
7
 * @package Client
8
 * @subpackage Html
9
 */
10
11
12
namespace Aimeos\Client\Html\Checkout\Update;
13
14
15
/**
16
 * Default implementation of update checkout HTML client.
17
 *
18
 * @package Client
19
 * @subpackage Html
20
 */
21
class Standard
22
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24
{
25
	/** client/html/checkout/update/name
26
	 * Class name of the used checkout update client implementation
27
	 *
28
	 * Each default HTML client can be replace by an alternative imlementation.
29
	 * To use this implementation, you have to set the last part of the class
30
	 * name as configuration value so the client factory knows which class it
31
	 * has to instantiate.
32
	 *
33
	 * For example, if the name of the default class is
34
	 *
35
	 *  \Aimeos\Client\Html\Checkout\Update\Standard
36
	 *
37
	 * and you want to replace it with your own version named
38
	 *
39
	 *  \Aimeos\Client\Html\Checkout\Update\Myupdate
40
	 *
41
	 * then you have to set the this configuration option:
42
	 *
43
	 *  client/html/checkout/update/name = Myupdate
44
	 *
45
	 * The value is the last part of your own class name and it's case sensitive,
46
	 * so take care that the configuration value is exactly named like the last
47
	 * part of the class name.
48
	 *
49
	 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
50
	 * characters are possible! You should always start the last part of the class
51
	 * name with an upper case character and continue only with lower case characters
52
	 * or numbers. Avoid chamel case names like "MyUpdate"!
53
	 *
54
	 * @param string Last part of the class name
55
	 */
56
57
58
	/**
59
	 * Processes the input, e.g. store given values.
60
	 *
61
	 * A view must be available and this method doesn't generate any output
62
	 * besides setting view variables.
63
	 */
64
	public function init()
65
	{
66
		$view = $this->view();
67
		$context = $this->context();
68
69
		try
70
		{
71
			$cntl = \Aimeos\Controller\Frontend::create( $context, 'service' );
72
			$cntl->updatePush( $view->request(), $view->response(), $view->param( 'code', '' ) );
73
		}
74
		catch( \Exception $e )
75
		{
76
			$view->response()->withStatus( 500, 'Error updating order status' );
77
			$view->response()->getBody()->write( $e->getMessage() );
78
79
			$body = (string) $view->request()->getBody();
80
			$str = "Updating order status failed: %1\$s\n%2\$s\n%3\$s";
81
			$msg = sprintf( $str, $e->getMessage(), print_r( $view->param(), true ), $body );
0 ignored issues
show
It seems like print_r($view->param(), true) can also be of type true; however, parameter $values of sprintf() does only seem to accept double|integer|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

81
			$msg = sprintf( $str, $e->getMessage(), /** @scrutinizer ignore-type */ print_r( $view->param(), true ), $body );
Loading history...
82
			$context->logger()->error( $msg, 'client/html' );
83
		}
84
	}
85
86
87
	/** client/html/checkout/update/template-body
88
	 * Relative path to the HTML body template of the checkout update client.
89
	 *
90
	 * The template file contains the HTML code and processing instructions
91
	 * to generate the result shown in the body of the frontend. The
92
	 * configuration string is the path to the template file relative
93
	 * to the templates directory (usually in templates/client/html).
94
	 *
95
	 * You can overwrite the template file configuration in extensions and
96
	 * provide alternative templates. These alternative templates should be
97
	 * named like the default one but suffixed by
98
	 * an unique name. You may use the name of your project for this. If
99
	 * you've implemented an alternative client class as well, it
100
	 * should be suffixed by the name of the new class.
101
	 *
102
	 * @param string Relative path to the template creating code for the HTML page body
103
	 * @see client/html/checkout/update/template-header
104
	 */
105
106
	/** client/html/checkout/update/template-header
107
	 * Relative path to the HTML header template of the checkout update client.
108
	 *
109
	 * The template file contains the HTML code and processing instructions
110
	 * to generate the HTML code that is inserted into the HTML page header
111
	 * of the rendered page in the frontend. The configuration string is the
112
	 * path to the template file relative to the templates directory (usually
113
	 * in templates/client/html).
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 suffixed 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, it
120
	 * should be suffixed by the name of the new class.
121
	 *
122
	 * @param string Relative path to the template creating code for the HTML page head
123
	 * @see client/html/checkout/update/template-body
124
	 */
125
126
	/** client/html/checkout/update/decorators/excludes
127
	 * Excludes decorators added by the "common" option from the checkout update html client
128
	 *
129
	 * Decorators extend the functionality of a class by adding new aspects
130
	 * (e.g. log what is currently done), executing the methods of the underlying
131
	 * class only in certain conditions (e.g. only for logged in users) or
132
	 * modify what is returned to the caller.
133
	 *
134
	 * This option allows you to remove a decorator added via
135
	 * "client/html/common/decorators/default" before they are wrapped
136
	 * around the html client.
137
	 *
138
	 *  client/html/checkout/update/decorators/excludes = array( 'decorator1' )
139
	 *
140
	 * This would remove the decorator named "decorator1" from the list of
141
	 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
142
	 * "client/html/common/decorators/default" to the html client.
143
	 *
144
	 * @param array List of decorator names
145
	 * @see client/html/common/decorators/default
146
	 * @see client/html/checkout/update/decorators/global
147
	 * @see client/html/checkout/update/decorators/local
148
	 */
149
150
	/** client/html/checkout/update/decorators/global
151
	 * Adds a list of globally available decorators only to the checkout update html client
152
	 *
153
	 * Decorators extend the functionality of a class by adding new aspects
154
	 * (e.g. log what is currently done), executing the methods of the underlying
155
	 * class only in certain conditions (e.g. only for logged in users) or
156
	 * modify what is returned to the caller.
157
	 *
158
	 * This option allows you to wrap global decorators
159
	 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
160
	 *
161
	 *  client/html/checkout/update/decorators/global = array( 'decorator1' )
162
	 *
163
	 * This would add the decorator named "decorator1" defined by
164
	 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
165
	 *
166
	 * @param array List of decorator names
167
	 * @see client/html/common/decorators/default
168
	 * @see client/html/checkout/update/decorators/excludes
169
	 * @see client/html/checkout/update/decorators/local
170
	 */
171
172
	/** client/html/checkout/update/decorators/local
173
	 * Adds a list of local decorators only to the checkout update html client
174
	 *
175
	 * Decorators extend the functionality of a class by adding new aspects
176
	 * (e.g. log what is currently done), executing the methods of the underlying
177
	 * class only in certain conditions (e.g. only for logged in users) or
178
	 * modify what is returned to the caller.
179
	 *
180
	 * This option allows you to wrap local decorators
181
	 * ("\Aimeos\Client\Html\Checkout\Decorator\*") around the html client.
182
	 *
183
	 *  client/html/checkout/update/decorators/local = array( 'decorator2' )
184
	 *
185
	 * This would add the decorator named "decorator2" defined by
186
	 * "\Aimeos\Client\Html\Checkout\Decorator\Decorator2" only to the html client.
187
	 *
188
	 * @param array List of decorator names
189
	 * @see client/html/common/decorators/default
190
	 * @see client/html/checkout/update/decorators/excludes
191
	 * @see client/html/checkout/update/decorators/global
192
	 */
193
}
194