Conditions | 8 |
Paths | 21 |
Total Lines | 79 |
Code Lines | 34 |
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 |
||
168 | public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface |
||
169 | { |
||
170 | if( !isset( $view->pageContent ) ) { |
||
171 | return parent::data( $view, $tags, $expire ); |
||
172 | } |
||
173 | |||
174 | $texts = []; |
||
175 | $context = $this->getContext(); |
||
176 | $config = $context->getConfig(); |
||
177 | $cntl = \Aimeos\Controller\Frontend::create( $context, 'product' ); |
||
178 | |||
179 | /** client/html/cms/page/template-cataloglist |
||
180 | * Relative path to the HTML template of the page catalog list client. |
||
181 | * |
||
182 | * The template file contains the HTML code and processing instructions |
||
183 | * to generate the HTML code that is inserted into the HTML page |
||
184 | * of the rendered page in the frontend. The configuration string is the |
||
185 | * path to the template file relative to the templates directory (usually |
||
186 | * in client/html/templates). |
||
187 | * |
||
188 | * You can overwrite the template file configuration in extensions and |
||
189 | * provide alternative templates. These alternative templates should be |
||
190 | * named like the default one but with the string "standard" replaced by |
||
191 | * an unique name. You may use the name of your project for this. If |
||
192 | * you've implemented an alternative client class as well, "standard" |
||
193 | * should be replaced by the name of the new class. |
||
194 | * |
||
195 | * @param string Relative path to the template creating code for the catalog list |
||
196 | * @since 2021.07 |
||
197 | * @category Developer |
||
198 | * @see client/html/cms/page/template-body |
||
199 | * @see client/html/cms/page/template-header |
||
200 | */ |
||
201 | $template = $config->get( 'client/html/cms/page/template-cataloglist', 'cms/page/cataloglist/list-standard' ); |
||
202 | $domains = $config->get( 'client/html/catalog/lists/domains', ['media', 'media/property', 'price', 'text'] ); |
||
203 | |||
204 | if( $view->config( 'client/html/cms/page/basket-add', false ) ) { |
||
205 | $domains = array_merge_recursive( $domains, ['product' => ['default'], 'attribute' => ['variant', 'custom', 'config']] ); |
||
206 | } |
||
207 | |||
208 | libxml_use_internal_errors( true ); |
||
209 | |||
210 | foreach( $view->pageContent as $content ) |
||
211 | { |
||
212 | $dom = new \DOMDocument( '1.0', 'UTF-8' ); |
||
213 | $dom->loadHTML( '<?xml encoding="utf-8" ?>' . $content, LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD ); |
||
214 | $nodes = $dom->getElementsByTagName( 'cataloglist' ); |
||
215 | |||
216 | while( $nodes->length > 0 ) |
||
217 | { |
||
218 | $node = $nodes->item( 0 ); |
||
219 | $catid = $node->hasAttribute( 'catid' ) ? $node->getAttribute( 'catid' ) : null; |
||
|
|||
220 | $type = $node->hasAttribute( 'type' ) ? $node->getAttribute( 'type' ) : 'default'; |
||
221 | $limit = $node->hasAttribute( 'limit' ) ? $node->getAttribute( 'limit' ) : 3; |
||
222 | |||
223 | $products = ( clone $cntl )->uses( $domains ) |
||
224 | ->category( $catid, $type ) |
||
225 | ->slice( 0, $limit ) |
||
226 | ->search(); |
||
227 | |||
228 | $this->addMetaItems( $products, $expire, $tags ); |
||
229 | |||
230 | $view = $context->getView()->set( 'products', $products ); |
||
231 | |||
232 | $pdom = new \DOMDocument( '1.0', 'UTF-8' ); |
||
233 | $pdom->loadHTML( '<?xml encoding="utf-8" ?>' . $view->render( $template ), LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD ); |
||
234 | |||
235 | $pnode = $dom->importNode( $pdom->documentElement, true ); |
||
236 | $node->parentNode->replaceChild( $pnode, $node ); |
||
237 | } |
||
238 | |||
239 | $texts[] = substr( $dom->saveHTML(), 25 ); |
||
240 | } |
||
241 | |||
242 | libxml_clear_errors(); |
||
243 | |||
244 | $view->pageContent = $texts; |
||
245 | |||
246 | return parent::data( $view, $tags, $expire ); |
||
247 | } |
||
260 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.