Skip to content

Commit 26b4613

Browse files
authored
Merge pull request #16 from kdambekalns/cleanup
TASK: Cleanup, reformat to PSR-2, mark migrations applied
2 parents d782f58 + 9478c9a commit 26b4613

20 files changed

Lines changed: 381 additions & 309 deletions

File tree

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
11
<?php
22
namespace Flowpack\SearchPlugin\Controller;
33

4-
/* *
5-
* This script belongs to the TYPO3 Flow package "Flowpack.SearchPlugin". *
6-
* *
7-
* It is free software; you can redistribute it and/or modify it under *
8-
* the terms of the GNU Lesser General Public License, either version 3 *
9-
* of the License, or (at your option) any later version. *
10-
* *
11-
* The TYPO3 project - inspiring people to share! *
12-
* */
4+
/*
5+
* This file is part of the Flowpack.SearchPlugin package.
6+
*
7+
* (c) Contributors of the Flowpack Team - flowpack.org
8+
*
9+
* This package is Open Source Software. For the full copyright and license
10+
* information, please view the LICENSE file which was distributed with this
11+
* source code.
12+
*/
1313

1414
use TYPO3\Flow\Annotations as Flow;
1515
use TYPO3\Flow\Mvc\Controller\ActionController;
1616
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
1717

1818
/**
1919
* Class AjaxSearchController
20-
*
21-
* @author Sebastian Kurfürst <sk@sandstorm.de>
22-
* @author Bastian Heist <bh@sandstorm.de>
23-
* @package Flowpack\SearchPlugin\Controller
2420
*/
25-
class AjaxSearchController extends ActionController {
26-
27-
/**
28-
* Override the default view from the ActionController to output TypoScript directly
29-
*
30-
* @var string
31-
* @api
32-
*/
33-
protected $defaultViewObjectName = \TYPO3\Neos\View\TypoScriptView::class;
34-
35-
/**
36-
* @param NodeInterface $node
37-
*/
38-
public function searchAction(NodeInterface $node) {
39-
/* @var $view \TYPO3\Neos\View\TypoScriptView */
40-
$view = $this->view;
41-
$view->setTypoScriptPath('ajaxSearch');
42-
$view->assign('value', $node);
43-
}
21+
class AjaxSearchController extends ActionController
22+
{
23+
/**
24+
* Override the default view from the ActionController to output TypoScript directly
25+
*
26+
* @var string
27+
* @api
28+
*/
29+
protected $defaultViewObjectName = \TYPO3\Neos\View\TypoScriptView::class;
4430

45-
}
31+
/**
32+
* @param NodeInterface $node
33+
* @return void
34+
*/
35+
public function searchAction(NodeInterface $node)
36+
{
37+
/* @var $view \TYPO3\Neos\View\TypoScriptView */
38+
$view = $this->view;
39+
$view->setTypoScriptPath('ajaxSearch');
40+
$view->assign('value', $node);
41+
}
42+
}
Lines changed: 47 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,57 @@
11
<?php
22
namespace Flowpack\SearchPlugin\Controller;
33

4-
/* *
5-
* This script belongs to the TYPO3 Flow package "Flowpack.SearchPlugin". *
6-
* *
7-
* It is free software; you can redistribute it and/or modify it under *
8-
* the terms of the GNU Lesser General Public License, either version 3 *
9-
* of the License, or (at your option) any later version. *
10-
* *
11-
* The TYPO3 project - inspiring people to share! *
12-
* */
4+
/*
5+
* This file is part of the Flowpack.SearchPlugin package.
6+
*
7+
* (c) Contributors of the Flowpack Team - flowpack.org
8+
*
9+
* This package is Open Source Software. For the full copyright and license
10+
* information, please view the LICENSE file which was distributed with this
11+
* source code.
12+
*/
1313

1414
use TYPO3\Flow\Annotations as Flow;
1515
use TYPO3\Flow\Mvc\Controller\ActionController;
16-
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
1716

1817
/**
1918
* Class SuggestController
20-
*
21-
* @author Jon Klixbüll Langeland <jon@moc.net>
22-
* @package Flowpack\SearchPlugin\Controller
2319
*/
24-
class SuggestController extends ActionController {
25-
26-
/**
27-
* @Flow\Inject
28-
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient
29-
*/
30-
protected $elasticSearchClient;
31-
32-
/**
33-
* The node inside which searching should happen
34-
*
35-
* @var NodeInterface
36-
*/
37-
protected $contextNode;
38-
39-
/**
40-
* @Flow\Inject
41-
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\LoggerInterface
42-
*/
43-
protected $logger;
44-
45-
/**
46-
* @var boolean
47-
*/
48-
protected $logThisQuery = FALSE;
49-
50-
/**
51-
* @var string
52-
*/
53-
protected $logMessage;
54-
55-
/**
56-
* @var array
57-
*/
58-
protected $viewFormatToObjectNameMap = array(
59-
'json' => 'TYPO3\Flow\Mvc\View\JsonView'
60-
);
61-
62-
/**
63-
* @param NodeInterface $node
64-
* @param string $term
65-
*/
66-
public function indexAction(NodeInterface $node, $term) {
67-
$request = array(
68-
'suggests' => array(
69-
'text' => $term,
70-
'term' => array(
71-
'field' => '_all'
72-
)
73-
)
74-
);
75-
76-
$response = $this->elasticSearchClient->getIndex()->request('GET', '/_suggest', array(), json_encode($request))->getTreatedContent();
77-
$suggestions = array_map(function($option) {
78-
return $option['text'];
79-
}, $response['suggests'][0]['options']);
80-
81-
$this->view->assign('value', $suggestions);
82-
}
83-
84-
}
20+
class SuggestController extends ActionController
21+
{
22+
/**
23+
* @Flow\Inject
24+
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient
25+
*/
26+
protected $elasticSearchClient;
27+
28+
/**
29+
* @var array
30+
*/
31+
protected $viewFormatToObjectNameMap = [
32+
'json' => 'TYPO3\Flow\Mvc\View\JsonView'
33+
];
34+
35+
/**
36+
* @param string $term
37+
* @return void
38+
*/
39+
public function indexAction($term)
40+
{
41+
$request = [
42+
'suggests' => [
43+
'text' => $term,
44+
'term' => [
45+
'field' => '_all'
46+
]
47+
]
48+
];
49+
50+
$response = $this->elasticSearchClient->getIndex()->request('POST', '/_suggest', [], json_encode($request))->getTreatedContent();
51+
$suggestions = array_map(function ($option) {
52+
return $option['text'];
53+
}, $response['suggests'][0]['options']);
54+
55+
$this->view->assign('value', $suggestions);
56+
}
57+
}
Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,52 @@
11
<?php
22
namespace Flowpack\SearchPlugin\EelHelper;
33

4-
/* *
5-
* This script belongs to the TYPO3 Flow package "Flowpack.SearchPlugin". *
6-
* *
7-
* It is free software; you can redistribute it and/or modify it under *
8-
* the terms of the GNU Lesser General Public License, either version 3 *
9-
* of the License, or (at your option) any later version. *
10-
* *
11-
* The TYPO3 project - inspiring people to share! *
12-
* */
13-
use TYPO3\Flow\Annotations as Flow;
4+
/*
5+
* This file is part of the Flowpack.SearchPlugin package.
6+
*
7+
* (c) Contributors of the Flowpack Team - flowpack.org
8+
*
9+
* This package is Open Source Software. For the full copyright and license
10+
* information, please view the LICENSE file which was distributed with this
11+
* source code.
12+
*/
13+
1414
use TYPO3\Eel\ProtectedContextAwareInterface;
15+
use TYPO3\Flow\Annotations as Flow;
1516

1617
/**
1718
* Additional Array Helpers which might once
1819
*
1920
* @Flow\Proxy(false)
2021
*/
21-
class SearchArrayHelper implements ProtectedContextAwareInterface {
22-
23-
/**
24-
* Concatenate arrays or values to a new array
25-
*
26-
* @param array|mixed $arrays First array or value
27-
* @return array The array with concatenated arrays or values
28-
*/
29-
public function flatten($arrays) {
30-
$return = array();
31-
if (is_array($arrays)) {
32-
array_walk_recursive($arrays, function ($a) use (&$return) {
33-
$return[] = $a;
34-
});
35-
}
36-
return $return;
37-
}
22+
class SearchArrayHelper implements ProtectedContextAwareInterface
23+
{
24+
/**
25+
* Concatenate arrays or values to a new array
26+
*
27+
* @param array|mixed $arrays First array or value
28+
* @return array The array with concatenated arrays or values
29+
*/
30+
public function flatten($arrays)
31+
{
32+
$return = [];
33+
if (is_array($arrays)) {
34+
array_walk_recursive($arrays, function ($a) use (&$return) {
35+
$return[] = $a;
36+
});
37+
}
3838

39-
/**
40-
* All methods are considered safe
41-
*
42-
* @param string $methodName
43-
* @return boolean
44-
*/
45-
public function allowsCallOfMethod($methodName) {
46-
return true;
47-
}
39+
return $return;
40+
}
4841

42+
/**
43+
* All methods are considered safe
44+
*
45+
* @param string $methodName
46+
* @return boolean
47+
*/
48+
public function allowsCallOfMethod($methodName)
49+
{
50+
return true;
51+
}
4952
}
Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<?php
22
namespace Flowpack\SearchPlugin\TypoScriptObjects;
33

4-
5-
/* *
6-
* This script belongs to the TYPO3 Flow package "Flowpack.SearchPlugin". *
7-
* *
8-
* It is free software; you can redistribute it and/or modify it under *
9-
* the terms of the GNU Lesser General Public License, either version 3 *
10-
* of the License, or (at your option) any later version. *
11-
* *
12-
* The TYPO3 project - inspiring people to share! *
13-
* */
4+
/*
5+
* This file is part of the Flowpack.SearchPlugin package.
6+
*
7+
* (c) Contributors of the Flowpack Team - flowpack.org
8+
*
9+
* This package is Open Source Software. For the full copyright and license
10+
* information, please view the LICENSE file which was distributed with this
11+
* source code.
12+
*/
1413

1514
use TYPO3\Flow\Annotations as Flow;
1615
use TYPO3\TypoScript\TypoScriptObjects\AbstractTypoScriptObject;
@@ -19,22 +18,25 @@
1918
* Class CanRenderImplementation
2019
*
2120
*/
22-
class CanRenderImplementation extends AbstractTypoScriptObject {
23-
24-
/**
25-
* TypoScript Type which shall be rendered
26-
* @return string
27-
*/
28-
public function getType() {
29-
return $this->tsValue('type');
30-
}
21+
class CanRenderImplementation extends AbstractTypoScriptObject
22+
{
23+
/**
24+
* TypoScript Type which shall be rendered
25+
*
26+
* @return string
27+
*/
28+
public function getType()
29+
{
30+
return $this->tsValue('type');
31+
}
3132

32-
/**
33-
* Evaluate this TypoScript object and return the result
34-
*
35-
* @return mixed
36-
*/
37-
public function evaluate() {
38-
return $this->tsRuntime->canRender('/type<' . $this->getType() . '>');
39-
}
40-
}
33+
/**
34+
* Evaluate this TypoScript object and return the result
35+
*
36+
* @return mixed
37+
*/
38+
public function evaluate()
39+
{
40+
return $this->tsRuntime->canRender('/type<' . $this->getType() . '>');
41+
}
42+
}

Configuration/NodeTypes.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'Flowpack.SearchPlugin:Search':
2-
superTypes: ['TYPO3.Neos:Content']
2+
superTypes:
3+
'TYPO3.Neos:Content': true
34
ui:
45
label: 'Search'
5-
icon: 'icon-search'
6+
icon: 'icon-search'

Configuration/Settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ TYPO3:
22
Neos:
33
typoScript:
44
autoInclude:
5-
'Flowpack.SearchPlugin': TRUE
5+
'Flowpack.SearchPlugin': true
66

77
TypoScript:
88
defaultContext:

0 commit comments

Comments
 (0)