| Conditions | 1 |
| Paths | 1 |
| Total Lines | 74 |
| Code Lines | 1 |
| 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 |
||
| 135 | } |
||
| 136 | |||
| 137 | $refresh = true; |
||
| 138 | break; |
||
| 139 | } |
||
| 140 | } |
||
| 141 | |||
| 142 | |||
| 143 | if( $refresh ) |
||
| 144 | { |
||
| 145 | $session->set( 'aimeos/catalog/session/pinned/list', $pinned ); |
||
| 146 | |||
| 147 | foreach( $session->get( 'aimeos/catalog/session/pinned/cache', [] ) as $key => $value ) { |
||
| 148 | $session->set( $key, null ); |
||
| 149 | } |
||
| 150 | } |
||
| 151 | } |
||
| 152 | |||
| 153 | |||
| 154 | /** |
||
| 155 | * Sets the necessary parameter values in the view. |
||
| 156 | * |
||
| 157 | * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
||
| 158 | * @param array &$tags Result array for the list of tags that are associated to the output |
||
| 159 | * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
||
| 160 | * @return \Aimeos\MW\View\Iface Modified view object |
||
| 161 | */ |
||
| 162 | public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface |
||
| 163 | { |
||
| 164 | $items = []; |
||
| 165 | $context = $this->context(); |
||
| 166 | $config = $context->config(); |
||
| 167 | $session = $context->session(); |
||
| 168 | |||
| 169 | $domains = $config->get( 'client/html/catalog/domains', ['media', 'price', 'text'] ); |
||
| 170 | |||
| 171 | /** client/html/catalog/session/pinned/domains |
||
| 172 | * A list of domain names whose items should be available in the pinned view template for the product |
||
| 173 | * |
||
| 174 | * The templates rendering product details usually add the images, |
||
| 175 | * prices and texts, etc. associated to the product |
||
| 176 | * item. If you want to display additional or less content, you can |
||
| 177 | * configure your own list of domains (attribute, media, price, product, |
||
| 178 | * text, etc. are domains) whose items are fetched from the storage. |
||
| 179 | * Please keep in mind that the more domains you add to the configuration, |
||
| 180 | * the more time is required for fetching the content! |
||
| 181 | * |
||
| 182 | * @param array List of domain names |
||
| 183 | * @since 2015.04 |
||
| 184 | * @see client/html/catalog/domains |
||
| 185 | * @see client/html/catalog/lists/domains |
||
| 186 | * @see client/html/catalog/detail/domains |
||
| 187 | */ |
||
| 188 | $domains = $config->get( 'client/html/catalog/session/pinned/domains', $domains ); |
||
| 189 | |||
| 190 | if( ( $pinned = $session->get( 'aimeos/catalog/session/pinned/list', [] ) ) !== [] ) |
||
| 191 | { |
||
| 192 | $result = \Aimeos\Controller\Frontend::create( $context, 'product' ) |
||
| 193 | ->uses( $domains )->product( $pinned )->slice( 0, count( $pinned ) )->search(); |
||
| 194 | |||
| 195 | foreach( array_reverse( $pinned ) as $id ) |
||
| 196 | { |
||
| 197 | if( isset( $result[$id] ) ) { |
||
| 198 | $items[$id] = $result[$id]; |
||
| 199 | } |
||
| 200 | } |
||
| 201 | } |
||
| 202 | |||
| 203 | $view->pinnedProductItems = $items; |
||
| 204 | $view->pinnedParams = $this->getClientParams( $view->param() ); |
||
| 205 | |||
| 206 | return parent::data( $view, $tags, $expire ); |
||
| 207 | } |
||
| 208 | } |
||
| 209 |