| Total Complexity | 55 |
| Total Lines | 555 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Standard often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Standard, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | class Standard |
||
| 22 | extends \Aimeos\Client\Html\Basket\Base |
||
| 23 | implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
||
| 24 | { |
||
| 25 | /** client/html/basket/standard/standard/subparts |
||
| 26 | * List of HTML sub-clients rendered within the basket standard section |
||
| 27 | * |
||
| 28 | * The output of the frontend is composed of the code generated by the HTML |
||
| 29 | * clients. Each HTML client can consist of serveral (or none) sub-clients |
||
| 30 | * that are responsible for rendering certain sub-parts of the output. The |
||
| 31 | * sub-clients can contain HTML clients themselves and therefore a |
||
| 32 | * hierarchical tree of HTML clients is composed. Each HTML client creates |
||
| 33 | * the output that is placed inside the container of its parent. |
||
| 34 | * |
||
| 35 | * At first, always the HTML code generated by the parent is printed, then |
||
| 36 | * the HTML code of its sub-clients. The order of the HTML sub-clients |
||
| 37 | * determines the order of the output of these sub-clients inside the parent |
||
| 38 | * container. If the configured list of clients is |
||
| 39 | * |
||
| 40 | * array( "subclient1", "subclient2" ) |
||
| 41 | * |
||
| 42 | * you can easily change the order of the output by reordering the subparts: |
||
| 43 | * |
||
| 44 | * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
||
| 45 | * |
||
| 46 | * You can also remove one or more parts if they shouldn't be rendered: |
||
| 47 | * |
||
| 48 | * client/html/<clients>/subparts = array( "subclient1" ) |
||
| 49 | * |
||
| 50 | * As the clients only generates structural HTML, the layout defined via CSS |
||
| 51 | * should support adding, removing or reordering content by a fluid like |
||
| 52 | * design. |
||
| 53 | * |
||
| 54 | * @param array List of sub-client names |
||
| 55 | * @since 2014.03 |
||
| 56 | * @category Developer |
||
| 57 | */ |
||
| 58 | private $subPartPath = 'client/html/basket/standard/standard/subparts'; |
||
| 59 | private $subPartNames = []; |
||
| 60 | private $view; |
||
| 61 | |||
| 62 | |||
| 63 | /** |
||
| 64 | * Returns the HTML code for insertion into the body. |
||
| 65 | * |
||
| 66 | * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
||
| 67 | * @return string HTML code |
||
| 68 | */ |
||
| 69 | public function getBody( $uid = '' ) |
||
| 70 | { |
||
| 71 | $context = $this->getContext(); |
||
| 72 | $view = $this->getView(); |
||
| 73 | |||
| 74 | try |
||
| 75 | { |
||
| 76 | if( !isset( $this->view ) ) { |
||
| 77 | $view = $this->view = $this->getObject()->addData( $view ); |
||
| 78 | } |
||
| 79 | |||
| 80 | $html = ''; |
||
| 81 | foreach( $this->getSubClients() as $subclient ) { |
||
| 82 | $html .= $subclient->setView( $view )->getBody( $uid ); |
||
| 83 | } |
||
| 84 | $view->standardBody = $html; |
||
| 85 | } |
||
| 86 | catch( \Aimeos\Client\Html\Exception $e ) |
||
| 87 | { |
||
| 88 | $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
||
| 89 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error; |
||
| 90 | } |
||
| 91 | catch( \Aimeos\Controller\Frontend\Exception $e ) |
||
| 92 | { |
||
| 93 | $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
||
| 94 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error; |
||
| 95 | } |
||
| 96 | catch( \Aimeos\MShop\Exception $e ) |
||
| 97 | { |
||
| 98 | $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 99 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error; |
||
| 100 | } |
||
| 101 | catch( \Exception $e ) |
||
| 102 | { |
||
| 103 | $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
||
| 104 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error; |
||
| 105 | $this->logException( $e ); |
||
| 106 | } |
||
| 107 | |||
| 108 | /** client/html/basket/standard/standard/template-body |
||
| 109 | * Relative path to the HTML body template of the basket standard client. |
||
| 110 | * |
||
| 111 | * The template file contains the HTML code and processing instructions |
||
| 112 | * to generate the result shown in the body of the frontend. The |
||
| 113 | * configuration string is the path to the template file relative |
||
| 114 | * to the templates directory (usually in client/html/templates). |
||
| 115 | * |
||
| 116 | * You can overwrite the template file configuration in extensions and |
||
| 117 | * provide alternative templates. These alternative templates should be |
||
| 118 | * named like the default one but with the string "standard" replaced by |
||
| 119 | * an unique name. You may use the name of your project for this. If |
||
| 120 | * you've implemented an alternative client class as well, "standard" |
||
| 121 | * should be replaced by the name of the new class. |
||
| 122 | * |
||
| 123 | * @param string Relative path to the template creating code for the HTML page body |
||
| 124 | * @since 2014.03 |
||
| 125 | * @category Developer |
||
| 126 | * @see client/html/basket/standard/standard/template-header |
||
| 127 | */ |
||
| 128 | $tplconf = 'client/html/basket/standard/standard/template-body'; |
||
| 129 | $default = 'basket/standard/body-standard'; |
||
| 130 | |||
| 131 | return $view->render( $view->config( $tplconf, $default ) ); |
||
| 132 | } |
||
| 133 | |||
| 134 | |||
| 135 | /** |
||
| 136 | * Returns the HTML string for insertion into the header. |
||
| 137 | * |
||
| 138 | * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
||
| 139 | * @return string|null String including HTML tags for the header on error |
||
| 140 | */ |
||
| 141 | public function getHeader( $uid = '' ) |
||
| 142 | { |
||
| 143 | $view = $this->getView(); |
||
| 144 | |||
| 145 | try |
||
| 146 | { |
||
| 147 | if( !isset( $this->view ) ) { |
||
| 148 | $view = $this->view = $this->getObject()->addData( $view ); |
||
| 149 | } |
||
| 150 | |||
| 151 | $html = ''; |
||
| 152 | foreach( $this->getSubClients() as $subclient ) { |
||
| 153 | $html .= $subclient->setView( $view )->getHeader( $uid ); |
||
| 154 | } |
||
| 155 | $view->standardHeader = $html; |
||
| 156 | } |
||
| 157 | catch( \Exception $e ) |
||
| 158 | { |
||
| 159 | $this->logException( $e ); |
||
| 160 | return ''; |
||
| 161 | } |
||
| 162 | |||
| 163 | /** client/html/basket/standard/standard/template-header |
||
| 164 | * Relative path to the HTML header template of the basket standard client. |
||
| 165 | * |
||
| 166 | * The template file contains the HTML code and processing instructions |
||
| 167 | * to generate the HTML code that is inserted into the HTML page header |
||
| 168 | * of the rendered page in the frontend. The configuration string is the |
||
| 169 | * path to the template file relative to the templates directory (usually |
||
| 170 | * in client/html/templates). |
||
| 171 | * |
||
| 172 | * You can overwrite the template file configuration in extensions and |
||
| 173 | * provide alternative templates. These alternative templates should be |
||
| 174 | * named like the default one but with the string "standard" replaced by |
||
| 175 | * an unique name. You may use the name of your project for this. If |
||
| 176 | * you've implemented an alternative client class as well, "standard" |
||
| 177 | * should be replaced by the name of the new class. |
||
| 178 | * |
||
| 179 | * @param string Relative path to the template creating code for the HTML page head |
||
| 180 | * @since 2014.03 |
||
| 181 | * @category Developer |
||
| 182 | * @see client/html/basket/standard/standard/template-body |
||
| 183 | */ |
||
| 184 | $tplconf = 'client/html/basket/standard/standard/template-header'; |
||
| 185 | $default = 'basket/standard/header-standard'; |
||
| 186 | |||
| 187 | return $view->render( $view->config( $tplconf, $default ) ); |
||
| 188 | } |
||
| 189 | |||
| 190 | |||
| 191 | /** |
||
| 192 | * Returns the sub-client given by its name. |
||
| 193 | * |
||
| 194 | * @param string $type Name of the client type |
||
| 195 | * @param string|null $name Name of the sub-client (Default if null) |
||
| 196 | * @return \Aimeos\Client\Html\Iface Sub-client object |
||
| 197 | */ |
||
| 198 | public function getSubClient( $type, $name = null ) |
||
| 199 | { |
||
| 200 | /** client/html/basket/standard/decorators/excludes |
||
| 201 | * Excludes decorators added by the "common" option from the basket standard html client |
||
| 202 | * |
||
| 203 | * Decorators extend the functionality of a class by adding new aspects |
||
| 204 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 205 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 206 | * modify what is returned to the caller. |
||
| 207 | * |
||
| 208 | * This option allows you to remove a decorator added via |
||
| 209 | * "client/html/common/decorators/default" before they are wrapped |
||
| 210 | * around the html client. |
||
| 211 | * |
||
| 212 | * client/html/basket/standard/decorators/excludes = array( 'decorator1' ) |
||
| 213 | * |
||
| 214 | * This would remove the decorator named "decorator1" from the list of |
||
| 215 | * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
||
| 216 | * "client/html/common/decorators/default" to the html client. |
||
| 217 | * |
||
| 218 | * @param array List of decorator names |
||
| 219 | * @since 2014.05 |
||
| 220 | * @category Developer |
||
| 221 | * @see client/html/common/decorators/default |
||
| 222 | * @see client/html/basket/standard/decorators/global |
||
| 223 | * @see client/html/basket/standard/decorators/local |
||
| 224 | */ |
||
| 225 | |||
| 226 | /** client/html/basket/standard/decorators/global |
||
| 227 | * Adds a list of globally available decorators only to the basket standard html client |
||
| 228 | * |
||
| 229 | * Decorators extend the functionality of a class by adding new aspects |
||
| 230 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 231 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 232 | * modify what is returned to the caller. |
||
| 233 | * |
||
| 234 | * This option allows you to wrap global decorators |
||
| 235 | * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
||
| 236 | * |
||
| 237 | * client/html/basket/standard/decorators/global = array( 'decorator1' ) |
||
| 238 | * |
||
| 239 | * This would add the decorator named "decorator1" defined by |
||
| 240 | * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
||
| 241 | * |
||
| 242 | * @param array List of decorator names |
||
| 243 | * @since 2014.05 |
||
| 244 | * @category Developer |
||
| 245 | * @see client/html/common/decorators/default |
||
| 246 | * @see client/html/basket/standard/decorators/excludes |
||
| 247 | * @see client/html/basket/standard/decorators/local |
||
| 248 | */ |
||
| 249 | |||
| 250 | /** client/html/basket/standard/decorators/local |
||
| 251 | * Adds a list of local decorators only to the basket standard html client |
||
| 252 | * |
||
| 253 | * Decorators extend the functionality of a class by adding new aspects |
||
| 254 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 255 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 256 | * modify what is returned to the caller. |
||
| 257 | * |
||
| 258 | * This option allows you to wrap local decorators |
||
| 259 | * ("\Aimeos\Client\Html\Basket\Decorator\*") around the html client. |
||
| 260 | * |
||
| 261 | * client/html/basket/standard/decorators/local = array( 'decorator2' ) |
||
| 262 | * |
||
| 263 | * This would add the decorator named "decorator2" defined by |
||
| 264 | * "\Aimeos\Client\Html\Basket\Decorator\Decorator2" only to the html client. |
||
| 265 | * |
||
| 266 | * @param array List of decorator names |
||
| 267 | * @since 2014.05 |
||
| 268 | * @category Developer |
||
| 269 | * @see client/html/common/decorators/default |
||
| 270 | * @see client/html/basket/standard/decorators/excludes |
||
| 271 | * @see client/html/basket/standard/decorators/global |
||
| 272 | */ |
||
| 273 | |||
| 274 | return $this->createSubClient( 'basket/standard/' . $type, $name ); |
||
| 275 | } |
||
| 276 | |||
| 277 | |||
| 278 | /** |
||
| 279 | * Sets the necessary parameter values in the view. |
||
| 280 | */ |
||
| 281 | public function process() |
||
| 282 | { |
||
| 283 | $view = $this->getView(); |
||
| 284 | $context = $this->getContext(); |
||
| 285 | $controller = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
||
| 286 | |||
| 287 | try |
||
| 288 | { |
||
| 289 | switch( $view->param( 'b_action' ) ) |
||
| 290 | { |
||
| 291 | case 'add': |
||
| 292 | $this->addProducts( $view ); |
||
| 293 | break; |
||
| 294 | case 'coupon-delete': |
||
| 295 | $this->deleteCoupon( $view ); |
||
| 296 | break; |
||
| 297 | case 'delete': |
||
| 298 | $this->deleteProducts( $view ); |
||
| 299 | break; |
||
| 300 | default: |
||
| 301 | $this->editProducts( $view ); |
||
| 302 | $this->addCoupon( $view ); |
||
| 303 | } |
||
| 304 | |||
| 305 | parent::process(); |
||
| 306 | |||
| 307 | /** client/html/basket/standard/check |
||
| 308 | * Alters the behavior of the product checks before continuing with the checkout |
||
| 309 | * |
||
| 310 | * By default, the product related checks are performed every time the basket |
||
| 311 | * is shown. They test if there are any products in the basket and execute all |
||
| 312 | * basket plugins that have been registered for the "check.before" and "check.after" |
||
| 313 | * events. |
||
| 314 | * |
||
| 315 | * Using this configuration setting, you can either disable all checks completely |
||
| 316 | * (0) or display a "Check" button instead of the "Checkout" button (2). In the |
||
| 317 | * later case, customers have to click on the "Check" button first to perform |
||
| 318 | * the checks and if everything is OK, the "Checkout" button will be displayed |
||
| 319 | * that allows the customers to continue the checkout process. If one of the |
||
| 320 | * checks fails, the customers have to fix the related basket item and must click |
||
| 321 | * on the "Check" button again before they can continue. |
||
| 322 | * |
||
| 323 | * Available values are: |
||
| 324 | * 0 = no product related checks |
||
| 325 | * 1 = checks are performed every time when the basket is displayed |
||
| 326 | * 2 = checks are performed only when clicking on the "check" button |
||
| 327 | * |
||
| 328 | * @param integer One of the allowed values (0, 1 or 2) |
||
| 329 | * @since 2016.08 |
||
| 330 | * @category Developer |
||
| 331 | * @category User |
||
| 332 | */ |
||
| 333 | $check = (int) $view->config( 'client/html/basket/standard/check', 1 ); |
||
| 334 | |||
| 335 | switch( $check ) |
||
| 336 | { |
||
| 337 | case 2: |
||
| 338 | if( $view->param( 'b_check', 0 ) == 0 ) { break; } |
||
|
|
|||
| 339 | case 1: |
||
| 340 | $controller->get()->check( \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT ); |
||
|
1 ignored issue
–
show
|
|||
| 341 | default: |
||
| 342 | $view->standardCheckout = true; |
||
| 343 | } |
||
| 344 | } |
||
| 345 | catch( \Aimeos\Client\Html\Exception $e ) |
||
| 346 | { |
||
| 347 | $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
||
| 348 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error; |
||
| 349 | } |
||
| 350 | catch( \Aimeos\Controller\Frontend\Exception $e ) |
||
| 351 | { |
||
| 352 | $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
||
| 353 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error; |
||
| 354 | } |
||
| 355 | catch( \Aimeos\MShop\Plugin\Provider\Exception $e ) |
||
| 356 | { |
||
| 357 | $errors = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 358 | $errors = array_merge( $errors, $this->translatePluginErrorCodes( $e->getErrorCodes() ) ); |
||
| 359 | |||
| 360 | $view->standardErrorCodes = $e->getErrorCodes(); |
||
| 361 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $errors; |
||
| 362 | } |
||
| 363 | catch( \Aimeos\MShop\Exception $e ) |
||
| 364 | { |
||
| 365 | $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 366 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error; |
||
| 367 | } |
||
| 368 | catch( \Exception $e ) |
||
| 369 | { |
||
| 370 | $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
||
| 371 | $view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error; |
||
| 372 | $this->logException( $e ); |
||
| 373 | } |
||
| 374 | |||
| 375 | // store updated basket after plugins updated content and have thrown an exception |
||
| 376 | $controller->save(); |
||
|
1 ignored issue
–
show
|
|||
| 377 | } |
||
| 378 | |||
| 379 | |||
| 380 | /** |
||
| 381 | * Returns the list of sub-client names configured for the client. |
||
| 382 | * |
||
| 383 | * @return array List of HTML client names |
||
| 384 | */ |
||
| 385 | protected function getSubClientNames() |
||
| 386 | { |
||
| 387 | return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
||
| 388 | } |
||
| 389 | |||
| 390 | |||
| 391 | /** |
||
| 392 | * Sets the necessary parameter values in the view. |
||
| 393 | * |
||
| 394 | * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
||
| 395 | * @param array &$tags Result array for the list of tags that are associated to the output |
||
| 396 | * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
||
| 397 | * @return \Aimeos\MW\View\Iface Modified view object |
||
| 398 | */ |
||
| 399 | public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expire = null ) |
||
| 400 | { |
||
| 401 | $context = $this->getContext(); |
||
| 402 | $site = $context->getLocale()->getSite()->getCode(); |
||
| 403 | |||
| 404 | if( ( $params = $context->getSession()->get( 'aimeos/catalog/detail/params/last/' . $site ) ) !== null ) |
||
| 405 | { |
||
| 406 | $target = $view->config( 'client/html/catalog/detail/url/target' ); |
||
| 407 | $controller = $view->config( 'client/html/catalog/detail/url/controller', 'catalog' ); |
||
| 408 | $action = $view->config( 'client/html/catalog/detail/url/action', 'detail' ); |
||
| 409 | $config = $view->config( 'client/html/catalog/detail/url/config', [] ); |
||
| 410 | } |
||
| 411 | else |
||
| 412 | { |
||
| 413 | $params = $context->getSession()->get( 'aimeos/catalog/lists/params/last/' . $site, [] ); |
||
| 414 | |||
| 415 | $target = $view->config( 'client/html/catalog/lists/url/target' ); |
||
| 416 | $controller = $view->config( 'client/html/catalog/lists/url/controller', 'catalog' ); |
||
| 417 | $action = $view->config( 'client/html/catalog/lists/url/action', 'list' ); |
||
| 418 | $config = $view->config( 'client/html/catalog/lists/url/config', [] ); |
||
| 419 | |||
| 420 | } |
||
| 421 | |||
| 422 | if( empty( $params ) === false ) { |
||
| 423 | $view->standardBackUrl = $view->url( $target, $controller, $action, $params, [], $config ); |
||
| 424 | } |
||
| 425 | |||
| 426 | $controller = \Aimeos\Controller\Frontend::create( $this->getContext(), 'basket' ); |
||
| 427 | |||
| 428 | $view->standardBasket = $controller->get(); |
||
| 429 | $view->standardTaxRates = $this->getTaxRates( $view->standardBasket ); |
||
| 430 | |||
| 431 | return parent::addData( $view, $tags, $expire ); |
||
| 432 | } |
||
| 433 | |||
| 434 | |||
| 435 | /** |
||
| 436 | * Adds the coupon specified by the view parameters from the basket. |
||
| 437 | * |
||
| 438 | * @param \Aimeos\MW\View\Iface $view View object |
||
| 439 | */ |
||
| 440 | protected function addCoupon( \Aimeos\MW\View\Iface $view ) |
||
| 441 | { |
||
| 442 | if( ( $coupon = $view->param( 'b_coupon' ) ) != '' ) |
||
| 443 | { |
||
| 444 | $controller = \Aimeos\Controller\Frontend::create( $this->getContext(), 'basket' ); |
||
| 445 | $controller->addCoupon( $coupon ); |
||
|
1 ignored issue
–
show
|
|||
| 446 | $this->clearCached(); |
||
| 447 | } |
||
| 448 | } |
||
| 449 | |||
| 450 | |||
| 451 | /** |
||
| 452 | * Adds the products specified by the view parameters to the basket. |
||
| 453 | * |
||
| 454 | * @param \Aimeos\MW\View\Iface $view View object |
||
| 455 | */ |
||
| 456 | protected function addProducts( \Aimeos\MW\View\Iface $view ) |
||
| 457 | { |
||
| 458 | $controller = \Aimeos\Controller\Frontend::create( $this->getContext(), 'basket' ); |
||
| 459 | $products = (array) $view->param( 'b_prod', [] ); |
||
| 460 | |||
| 461 | if( ( $prodid = $view->param( 'b_prodid', '' ) ) !== '' ) |
||
| 462 | { |
||
| 463 | $products[] = array( |
||
| 464 | 'prodid' => $prodid, |
||
| 465 | 'quantity' => $view->param( 'b_quantity', 1 ), |
||
| 466 | 'attrvarid' => $view->param( 'b_attrvarid', [] ), |
||
| 467 | 'attrconfid' => $view->param( 'b_attrconfid', [] ), |
||
| 468 | 'attrhideid' => $view->param( 'b_attrhideid', [] ), |
||
| 469 | 'attrcustid' => $view->param( 'b_attrcustid', [] ), |
||
| 470 | 'stocktype' => $view->param( 'b_stocktype', 'default' ), |
||
| 471 | ); |
||
| 472 | } |
||
| 473 | |||
| 474 | foreach( $products as $values ) { |
||
| 475 | $this->addProduct( $controller, $values ); |
||
| 476 | } |
||
| 477 | |||
| 478 | $this->clearCached(); |
||
| 479 | } |
||
| 480 | |||
| 481 | |||
| 482 | /** |
||
| 483 | * Adds a single product specified by its values to the basket. |
||
| 484 | * |
||
| 485 | * @param \Aimeos\Controller\Frontend\Basket\Iface $controller Basket frontend controller |
||
| 486 | * @param array $values Associative list of key/value pairs from the view specifying the product |
||
| 487 | */ |
||
| 488 | protected function addProduct( \Aimeos\Controller\Frontend\Basket\Iface $controller, array $values ) |
||
| 509 | ); |
||
| 510 | } |
||
| 511 | |||
| 512 | |||
| 513 | /** |
||
| 514 | * Removes the coupon specified by the view parameters from the basket. |
||
| 515 | * |
||
| 516 | * @param \Aimeos\MW\View\Iface $view View object |
||
| 517 | */ |
||
| 518 | protected function deleteCoupon( \Aimeos\MW\View\Iface $view ) |
||
| 519 | { |
||
| 520 | if( ( $coupon = $view->param( 'b_coupon' ) ) != '' ) |
||
| 521 | { |
||
| 522 | $controller = \Aimeos\Controller\Frontend::create( $this->getContext(), 'basket' ); |
||
| 523 | $controller->deleteCoupon( $coupon ); |
||
|
1 ignored issue
–
show
|
|||
| 524 | $this->clearCached(); |
||
| 525 | } |
||
| 526 | } |
||
| 527 | |||
| 528 | |||
| 529 | /** |
||
| 530 | * Removes the products specified by the view parameters from the basket. |
||
| 531 | * |
||
| 532 | * @param \Aimeos\MW\View\Iface $view View object |
||
| 533 | */ |
||
| 534 | protected function deleteProducts( \Aimeos\MW\View\Iface $view ) |
||
| 535 | { |
||
| 536 | $controller = \Aimeos\Controller\Frontend::create( $this->getContext(), 'basket' ); |
||
| 537 | $products = (array) $view->param( 'b_position', [] ); |
||
| 538 | |||
| 539 | foreach( $products as $position ) { |
||
| 540 | $controller->deleteProduct( $position ); |
||
|
1 ignored issue
–
show
|
|||
| 541 | } |
||
| 542 | |||
| 543 | $this->clearCached(); |
||
| 544 | } |
||
| 545 | |||
| 546 | |||
| 547 | /** |
||
| 548 | * Edits the products specified by the view parameters to the basket. |
||
| 549 | * |
||
| 550 | * @param \Aimeos\MW\View\Iface $view View object |
||
| 551 | */ |
||
| 552 | protected function editProducts( \Aimeos\MW\View\Iface $view ) |
||
| 576 | } |
||
| 577 | } |
||
| 578 |