| Conditions | 6 |
| Paths | 19 |
| Total Lines | 61 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 79 | |||
| 80 | if( ( $prodIds = $prodMap->keys()->diff( $exclude )->toArray() ) !== [] ) |
||
| 81 | { |
||
| 82 | $productItems = \Aimeos\Controller\Frontend::create( $context, 'product' ) |
||
| 83 | ->uses( ['text' => ['name'], 'media' => ['default']] ) |
||
| 84 | ->product( $prodIds ) |
||
| 85 | ->search(); |
||
| 86 | |||
| 87 | foreach( $prodMap as $prodId => $ordProdId ) |
||
| 88 | { |
||
| 89 | if( $item = $productItems->get( $prodId ) ) { |
||
| 90 | $products[$prodId] = $item->set( 'orderProductId', $ordProdId ); |
||
| 91 | } |
||
| 92 | } |
||
| 93 | } |
||
| 94 | |||
| 95 | $view->reviewProductItems = map( $products )->filter()->take( $size ); |
||
| 96 | |||
| 97 | return parent::data( $view, $tags, $expire ); |
||
| 98 | } |
||
| 99 | |||
| 100 | |||
| 101 | /** |
||
| 102 | * Processes the input, e.g. store given values. |
||
| 103 | * |
||
| 104 | * A view must be available and this method doesn't generate any output |
||
| 105 | * besides setting view variables if necessary. |
||
| 106 | */ |
||
| 107 | public function init() |
||
| 108 | { |
||
| 109 | $view = $this->view(); |
||
| 110 | |||
| 111 | if( ( $reviews = $view->param( 'review', [] ) ) !== [] ) |
||
| 112 | { |
||
| 113 | $context = $this->context(); |
||
| 114 | $cntl = \Aimeos\Controller\Frontend::create( $context, 'review' ); |
||
| 115 | $addr = \Aimeos\Controller\Frontend::create( $context, 'customer' )->get()->getPaymentAddress(); |
||
| 116 | |||
| 117 | foreach( $reviews as $values ) { |
||
| 118 | $cntl->save( $cntl->create( $values )->setDomain( 'product' )->setName( $addr->getFirstName() ) ); |
||
| 119 | } |
||
| 120 | |||
| 121 | $view->reviewInfoList = [$view->translate( 'client', 'Thank you for your review!' )]; |
||
| 122 | } |
||
| 123 | |||
| 124 | parent::init(); |
||
| 125 | } |
||
| 126 | |||
| 127 | |||
| 128 | /** client/html/account/review/template-body |
||
| 129 | * Relative path to the HTML body template of the account review client. |
||
| 130 | * |
||
| 131 | * The template file contains the HTML code and processing instructions |
||
| 132 | * to generate the result shown in the body of the frontend. The |
||
| 133 | * configuration string is the path to the template file relative |
||
| 134 | * to the templates directory (usually in client/html/templates). |
||
| 135 | * |
||
| 136 | * You can overwrite the template file configuration in extensions and |
||
| 137 | * provide alternative templates. These alternative templates should be |
||
| 138 | * named like the default one but suffixed by |
||
| 139 | * an unique name. You may use the name of your project for this. If |
||
| 140 | * you've implemented an alternative client class as well, it |
||
| 171 |