| Conditions | 2 |
| Paths | 2 |
| Total Lines | 69 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 66 | public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface |
||
| 67 | { |
||
| 68 | $context = $this->context(); |
||
| 69 | $config = $context->config(); |
||
| 70 | |||
| 71 | $cntl = \Aimeos\Controller\Frontend::create( $context, 'product' ) |
||
| 72 | ->text( $view->param( 'f_search' ) ); // sort by relevance first |
||
| 73 | |||
| 74 | |||
| 75 | /** client/html/catalog/suggest/domains |
||
| 76 | * List of domain items that should be fetched along with the products |
||
| 77 | * |
||
| 78 | * The suggsted entries for the full text search in the catalog filter component |
||
| 79 | * usually consist of the names of the matched products. By default, only the |
||
| 80 | * product item including the localized name is available. You can add more domains |
||
| 81 | * like e.g. "media" to get the images of the product as well. |
||
| 82 | * |
||
| 83 | * **Note:** The more domains you will add, the slower the autocomplete requests |
||
| 84 | * will be! Keep it to an absolute minium for user friendly response times. |
||
| 85 | * |
||
| 86 | * @param array List of domain names |
||
| 87 | * @since 2016.08 |
||
| 88 | * @see client/html/catalog/suggest/template-body |
||
| 89 | * @see client/html/catalog/suggest/restrict |
||
| 90 | * @see client/html/catalog/suggest/size |
||
| 91 | */ |
||
| 92 | $domains = $config->get( 'client/html/catalog/suggest/domains', ['text'] ); |
||
| 93 | |||
| 94 | /** client/html/catalog/suggest/size |
||
| 95 | * The number of products shown in the list of suggestions |
||
| 96 | * |
||
| 97 | * Limits the number of products that are shown in the list of suggested |
||
| 98 | * products. |
||
| 99 | * |
||
| 100 | * @param integer Number of products |
||
| 101 | * @since 2018.10 |
||
| 102 | * @see client/html/catalog/suggest/domains |
||
| 103 | * @see client/html/catalog/suggest/restrict |
||
| 104 | */ |
||
| 105 | $size = $config->get( 'client/html/catalog/suggest/size', 24 ); |
||
| 106 | |||
| 107 | /** client/html/catalog/suggest/restrict |
||
| 108 | * Restricts suggestions to category and attribute facets |
||
| 109 | * |
||
| 110 | * Limits the shown suggestions to the current category and selected |
||
| 111 | * attribute facets. If disabled, suggestions are limited by the |
||
| 112 | * entered text only. |
||
| 113 | * |
||
| 114 | * @param boolean True to use category and facets, false for all results |
||
| 115 | * @since 2019.07 |
||
| 116 | * @see client/html/catalog/suggest/domains |
||
| 117 | * @see client/html/catalog/suggest/size |
||
| 118 | */ |
||
| 119 | if( $config->get( 'client/html/catalog/suggest/restrict', true ) == true ) |
||
| 120 | { |
||
| 121 | $level = $config->get( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
||
| 122 | $catids = $view->param( 'f_catid', $config->get( 'client/html/catalog/lists/catid-default' ) ); |
||
| 123 | |||
| 124 | $cntl->category( $catids, 'default', $level ) |
||
| 125 | ->allOf( $view->param( 'f_attrid', [] ) ) |
||
| 126 | ->oneOf( $view->param( 'f_optid', [] ) ) |
||
| 127 | ->oneOf( $view->param( 'f_oneid', [] ) ); |
||
| 128 | |||
| 129 | $this->call( 'conditions', $cntl, $view ); |
||
| 130 | } |
||
| 131 | |||
| 132 | $view->suggestItems = $cntl->uses( $domains )->slice( 0, $size )->search(); |
||
| 133 | |||
| 134 | return parent::data( $view, $tags, $expire ); |
||
| 135 | } |
||
| 195 |