Conditions | 2 |
Paths | 2 |
Total Lines | 77 |
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 |
||
23 | protected function execute(InputInterface $input, OutputInterface $output) |
||
24 | { |
||
25 | |||
26 | // HACK to make sure ezfind modules and fetch functions are active. |
||
27 | // The problem still remains though: the rest of the legacy kernel will not be loaded correctly... |
||
28 | $legacyKernelClosure = $this->getContainer()->get('ezpublish_legacy.kernel'); |
||
29 | $legacyKernel = $legacyKernelClosure(); |
||
30 | $legacyKernel->runCallback( |
||
31 | function () { |
||
32 | $moduleRepositories = \eZModule::activeModuleRepositories(true); |
||
33 | $moduleRepositories[] = 'extension/ezfind/modules'; |
||
34 | //var_dump($moduleRepositories); |
||
35 | \eZModule::setGlobalPathList( $moduleRepositories ); |
||
36 | }, |
||
37 | false |
||
38 | ); |
||
39 | |||
40 | $searchService = $this->getContainer()->get('ezfind_search_engine.api.service.search'); |
||
41 | |||
42 | |||
43 | $query = new KQuery(); |
||
44 | $query->query = new Criterion\LogicalOr([ |
||
45 | new Criterion\LogicalAnd([ |
||
46 | new Criterion\ContentTypeIdentifier('fs_article'), |
||
47 | new Criterion\Subtree('/1/2/'), |
||
48 | new Criterion\ParentLocationId(128), |
||
49 | new Criterion\FullText('spuerscript'), |
||
50 | new Criterion\Field('fs_article/strapline', Criterion\Operator::CONTAINS, 'ome'), |
||
51 | new Criterion\Field('fs_article/strapline', Criterion\Operator::LIKE, 's_m%'), |
||
52 | new Criterion\Field('fs_article/integer', Criterion\Operator::GT, 12), |
||
53 | new Criterion\Field('fs_article/integer', Criterion\Operator::IN, array(23, 32)), |
||
54 | ]), |
||
55 | new Criterion\ContentTypeIdentifier('folder'), |
||
56 | new Criterion\LogicalAnd([ |
||
57 | new Criterion\SectionId(1), |
||
58 | new Criterion\ContentId(5), |
||
59 | new Criterion\LocationId(5), |
||
60 | new Criterion\LocationPriority(Criterion\Operator::GT, 0), |
||
|
|||
61 | new Criterion\RemoteId('abcdefg:ka and bb:cc'), |
||
62 | new Criterion\DateMetadata(Criterion\DateMetadata::CREATED, Criterion\Operator::GT, 500000000), |
||
63 | new KCriterion\SolrRaw('NOT(meta_path_string_ms:bbbb^4 OR meta_path_string_ms:bbba^4 AND (meta_path_string_ms:hello OR meta_path_string_ms:world))'), |
||
64 | new Criterion\LogicalNot(new Criterion\RemoteId('abcdefg')), |
||
65 | new Criterion\UserMetadata(Criterion\UserMetadata::OWNER, Criterion\Operator::EQ, 14), |
||
66 | ]) |
||
67 | ]); |
||
68 | |||
69 | $query->limit = 10; |
||
70 | //$query->offset = $searchOffset; |
||
71 | |||
72 | $query->sortClauses = [ |
||
73 | //new KSortClause\Score(KQuery::SORT_DESC) |
||
74 | //new SortClause\ContentId(KQuery::SORT_ASC) |
||
75 | new SortClause\LocationPathString(KQuery::SORT_DESC) |
||
76 | ]; |
||
77 | |||
78 | //$query->returnType = KQuery::RETURN_EZFIND_DATA; |
||
79 | |||
80 | $results = $searchService->findContent($query); |
||
81 | |||
82 | echo "count: "; var_dump(count($results->searchHits)); |
||
83 | echo "totalCount: "; var_dump($results->totalCount); |
||
84 | echo "time (ms): "; var_dump($results->time); |
||
85 | echo "maxScore: "; var_dump($results->maxScore); |
||
86 | echo "q: "; var_dump($results->searchExtras->attribute('responseHeader')['params']['q']); |
||
87 | echo "fq: "; var_dump($results->searchExtras->attribute('responseHeader')['params']['fq']); |
||
88 | echo "sort: "; var_dump($results->searchExtras->attribute('responseHeader')['params']['sort']); |
||
89 | |||
90 | foreach($results->searchHits as $i => $searchHit) { |
||
91 | /** @var Content $content */ |
||
92 | $content = $searchHit->valueObject; |
||
93 | $score = $searchHit->score; |
||
94 | //echo "hit $i: obj ".$content->id.', score '.$score."\n"; |
||
95 | var_dump($content); |
||
96 | } |
||
97 | |||
98 | //var_dump($results->searchExtras); |
||
99 | } |
||
100 | } |
||
101 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.