Standard   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 81
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A data() 0 35 1
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\Catalog\Stock;
13
14
15
/**
16
 * Default implementation of catalog stock HTML clients.
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/catalog/stock/name
26
	 * Class name of the used catalog stock 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\Catalog\Stock\Standard
36
	 *
37
	 * and you want to replace it with your own version named
38
	 *
39
	 *  \Aimeos\Client\Html\Catalog\Stock\Mystock
40
	 *
41
	 * then you have to set the this configuration option:
42
	 *
43
	 *  client/html/catalog/stock/name = Mystock
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 "MyStock"!
53
	 *
54
	 * @param string Last part of the class name
55
	 * @since 2014.03
56
	 */
57
58
59
	/**
60
	 * Sets the necessary parameter values in the view.
61
	 *
62
	 * @param \Aimeos\Base\View\Iface $view The view object which generates the HTML output
63
	 * @param array &$tags Result array for the list of tags that are associated to the output
64
	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
65
	 * @return \Aimeos\Base\View\Iface Modified view object
66
	 */
67
	public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], ?string &$expire = null ) : \Aimeos\Base\View\Iface
68
	{
69
		$stockItemsByProducts = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $stockItemsByProducts is dead and can be removed.
Loading history...
70
		$context = $this->context();
71
		$prodIds = (array) $view->param( 'st_pid', [] );
72
73
		/** client/html/catalog/stock/sort
74
		 * Sortation key if stock levels for different types exist
75
		 *
76
		 * Products can be shipped from several warehouses with a different
77
		 * stock level for each one. The stock levels for each warehouse will
78
		 * be shown in the product detail page. To get a consistent sortation
79
		 * of this list, the configured key will be used by the stock manager.
80
		 *
81
		 * Possible keys for sorting are ("-stock.type" for descending order):
82
		 *
83
		 * * stock.productid
84
		 * * stock.stocklevel
85
		 * * stock.type
86
		 * * stock.dateback
87
		 *
88
		 * @param array List of key/value pairs for sorting
89
		 * @since 2017.01
90
		 * @see client/html/catalog/stock/level/low
91
		 */
92
		$sort = $context->config()->get( 'client/html/catalog/stock/sort', 'stock.type' );
93
		$type = $context->locale()->getSiteItem()->getConfigValue( 'stocktype' );
94
95
		$view->stockProductIds = $prodIds;
96
		$view->stockItemsByProducts = \Aimeos\Controller\Frontend::create( $context, 'stock' )
97
			->product( $prodIds )->type( $type )->sort( $sort )
98
			->search()
99
			->groupBy( 'stock.productid' );
100
101
		return parent::data( $view, $tags, $expire );
102
	}
103
104
105
	/** client/html/catalog/stock/template-body
106
	 * Relative path to the HTML body template of the catalog stock client.
107
	 *
108
	 * The template file contains the HTML code and processing instructions
109
	 * to generate the result shown in the body of the frontend. The
110
	 * configuration string is the path to the template file relative
111
	 * to the templates directory (usually in templates/client/html).
112
	 *
113
	 * You can overwrite the template file configuration in extensions and
114
	 * provide alternative templates. These alternative templates should be
115
	 * named like the default one but suffixed by
116
	 * an unique name. You may use the name of your project for this. If
117
	 * you've implemented an alternative client class as well, it
118
	 * should be suffixed by the name of the new class.
119
	 *
120
	 * @param string Relative path to the template creating code for the HTML page body
121
	 * @since 2014.03
122
	 * @see client/html/catalog/stock/template-header
123
	 */
124
125
	/** client/html/catalog/stock/template-header
126
	 * Relative path to the HTML header template of the catalog stock client.
127
	 *
128
	 * The template file contains the HTML code and processing instructions
129
	 * to generate the HTML code that is inserted into the HTML page header
130
	 * of the rendered page in the frontend. The configuration string is the
131
	 * path to the template file relative to the templates directory (usually
132
	 * in templates/client/html).
133
	 *
134
	 * You can overwrite the template file configuration in extensions and
135
	 * provide alternative templates. These alternative templates should be
136
	 * named like the default one but suffixed by
137
	 * an unique name. You may use the name of your project for this. If
138
	 * you've implemented an alternative client class as well, it
139
	 * should be suffixed by the name of the new class.
140
	 *
141
	 * @param string Relative path to the template creating code for the HTML page head
142
	 * @since 2014.03
143
	 * @see client/html/catalog/stock/template-body
144
	 */
145
146
	/** client/html/catalog/stock/decorators/excludes
147
	 * Excludes decorators added by the "common" option from the catalog stock html client
148
	 *
149
	 * Decorators extend the functionality of a class by adding new aspects
150
	 * (e.g. log what is currently done), executing the methods of the underlying
151
	 * class only in certain conditions (e.g. only for logged in users) or
152
	 * modify what is returned to the caller.
153
	 *
154
	 * This option allows you to remove a decorator added via
155
	 * "client/html/common/decorators/default" before they are wrapped
156
	 * around the html client.
157
	 *
158
	 *  client/html/catalog/stock/decorators/excludes = array( 'decorator1' )
159
	 *
160
	 * This would remove the decorator named "decorator1" from the list of
161
	 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
162
	 * "client/html/common/decorators/default" to the html client.
163
	 *
164
	 * @param array List of decorator names
165
	 * @see client/html/common/decorators/default
166
	 * @see client/html/catalog/stock/decorators/global
167
	 * @see client/html/catalog/stock/decorators/local
168
	 */
169
170
	/** client/html/catalog/stock/decorators/global
171
	 * Adds a list of globally available decorators only to the catalog stock html client
172
	 *
173
	 * Decorators extend the functionality of a class by adding new aspects
174
	 * (e.g. log what is currently done), executing the methods of the underlying
175
	 * class only in certain conditions (e.g. only for logged in users) or
176
	 * modify what is returned to the caller.
177
	 *
178
	 * This option allows you to wrap global decorators
179
	 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
180
	 *
181
	 *  client/html/catalog/stock/decorators/global = array( 'decorator1' )
182
	 *
183
	 * This would add the decorator named "decorator1" defined by
184
	 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
185
	 *
186
	 * @param array List of decorator names
187
	 * @see client/html/common/decorators/default
188
	 * @see client/html/catalog/stock/decorators/excludes
189
	 * @see client/html/catalog/stock/decorators/local
190
	 */
191
192
	/** client/html/catalog/stock/decorators/local
193
	 * Adds a list of local decorators only to the catalog stock html client
194
	 *
195
	 * Decorators extend the functionality of a class by adding new aspects
196
	 * (e.g. log what is currently done), executing the methods of the underlying
197
	 * class only in certain conditions (e.g. only for logged in users) or
198
	 * modify what is returned to the caller.
199
	 *
200
	 * This option allows you to wrap local decorators
201
	 * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
202
	 *
203
	 *  client/html/catalog/stock/decorators/local = array( 'decorator2' )
204
	 *
205
	 * This would add the decorator named "decorator2" defined by
206
	 * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
207
	 *
208
	 * @param array List of decorator names
209
	 * @see client/html/common/decorators/default
210
	 * @see client/html/catalog/stock/decorators/excludes
211
	 * @see client/html/catalog/stock/decorators/global
212
	 */
213
}
214