Skip to content

Commit 4b53203

Browse files
committed
TASK: Polished code after migrations
1 parent 153b816 commit 4b53203

16 files changed

Lines changed: 60 additions & 64 deletions

File tree

Classes/Controller/AjaxSearchController.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,29 @@
1111
* source code.
1212
*/
1313

14+
use Neos\ContentRepository\Domain\Model\NodeInterface;
1415
use Neos\Flow\Annotations as Flow;
1516
use Neos\Flow\Mvc\Controller\ActionController;
16-
use Neos\ContentRepository\Domain\Model\NodeInterface;
17+
use Neos\Neos\View\FusionView;
1718

18-
/**
19-
* Class AjaxSearchController
20-
*/
2119
class AjaxSearchController extends ActionController
2220
{
2321
/**
24-
* Override the default view from the ActionController to output TypoScript directly
22+
* Override the default view from the ActionController to output Fusion directly
2523
*
2624
* @var string
2725
* @api
2826
*/
29-
protected $defaultViewObjectName = \Neos\Neos\View\FusionView::class;
27+
protected $defaultViewObjectName = FusionView::class;
3028

3129
/**
3230
* @param NodeInterface $node
31+
*
3332
* @return void
3433
*/
3534
public function searchAction(NodeInterface $node)
3635
{
37-
/* @var $view \Neos\Neos\View\FusionView */
36+
/* @var FusionView $view */
3837
$view = $this->view;
3938
$view->setFusionPath('ajaxSearch');
4039
$view->assign('value', $node);

Classes/Controller/SuggestController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@
1111
* source code.
1212
*/
1313

14+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient;
1415
use Neos\Flow\Annotations as Flow;
1516
use Neos\Flow\Mvc\Controller\ActionController;
17+
use Neos\Flow\Mvc\View\JsonView;
1618

17-
/**
18-
* Class SuggestController
19-
*/
2019
class SuggestController extends ActionController
2120
{
2221
/**
2322
* @Flow\Inject
24-
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient
23+
* @var ElasticSearchClient
2524
*/
2625
protected $elasticSearchClient;
2726

2827
/**
2928
* @var array
3029
*/
3130
protected $viewFormatToObjectNameMap = [
32-
'json' => 'Neos\Flow\Mvc\View\JsonView'
31+
'json' => JsonView::class
3332
];
3433

3534
/**
3635
* @param string $term
36+
*
3737
* @return void
3838
*/
3939
public function indexAction($term)

Classes/EelHelper/SearchArrayHelper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class SearchArrayHelper implements ProtectedContextAwareInterface
2525
* Concatenate arrays or values to a new array
2626
*
2727
* @param array|mixed $arrays First array or value
28+
*
2829
* @return array The array with concatenated arrays or values
2930
*/
3031
public function flatten($arrays)
@@ -43,6 +44,7 @@ public function flatten($arrays)
4344
* All methods are considered safe
4445
*
4546
* @param string $methodName
47+
*
4648
* @return boolean
4749
*/
4850
public function allowsCallOfMethod($methodName)

Classes/FusionObjects/CanRenderImplementation.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,25 @@
1414
use Neos\Flow\Annotations as Flow;
1515
use Neos\Fusion\FusionObjects\AbstractFusionObject;
1616

17-
/**
18-
* Class CanRenderImplementation
19-
*
20-
*/
2117
class CanRenderImplementation extends AbstractFusionObject
2218
{
2319
/**
24-
* TypoScript Type which shall be rendered
20+
* Evaluate this Fusion object and return the result
2521
*
26-
* @return string
22+
* @return mixed
2723
*/
28-
public function getType()
24+
public function evaluate()
2925
{
30-
return $this->tsValue('type');
26+
return $this->runtime->canRender('/type<' . $this->getType() . '>');
3127
}
3228

3329
/**
34-
* Evaluate this TypoScript object and return the result
30+
* Fusion Type which shall be rendered
3531
*
36-
* @return mixed
32+
* @return string
3733
*/
38-
public function evaluate()
34+
public function getType()
3935
{
40-
return $this->tsRuntime->canRender('/type<' . $this->getType() . '>');
36+
return $this->fusionValue('type');
4137
}
4238
}

Configuration/Policy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ roles:
1313
permission: GRANT
1414
-
1515
privilegeTarget: Flowpack_SearchPlugin_Controller_AjaxSearchController
16-
permission: GRANT
16+
permission: GRANT

Configuration/Routes.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'@controller': 'Suggest'
88
'@action': 'index'
99
'@format': 'json'
10-
appendExceedingArguments: TRUE
10+
appendExceedingArguments: true
1111
httpMethods: ['GET']
1212
-
1313
name: 'flowpack/searchplugin - SuggestController->ajax'
@@ -17,5 +17,5 @@
1717
'@controller': 'AjaxSearch'
1818
'@action': 'search'
1919
'@format': 'html'
20-
appendExceedingArguments: TRUE
21-
httpMethods: ['GET']
20+
appendExceedingArguments: true
21+
httpMethods: ['GET']

Configuration/Settings.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
21
Neos:
2+
Flow:
3+
mvc:
4+
routes:
5+
'Flowpack.SearchPlugin':
6+
position: 'before Neos.Neos'
7+
Fusion:
8+
defaultContext:
9+
Flowpack.SearchPlugin.Array: Flowpack\SearchPlugin\EelHelper\SearchArrayHelper
310
Neos:
411
fusion:
512
autoInclude:
613
Flowpack.SearchPlugin: true
7-
Fusion:
8-
defaultContext:
9-
Flowpack.SearchPlugin.Array: Flowpack\SearchPlugin\EelHelper\SearchArrayHelper

README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,33 @@
11
# Flowpack.SearchPlugin
22

3-
This plugin is just a very bare-bones basis for a Search-Plugin, to be used together with
4-
Flowpack.ElasticSearch.ContentRepositoryAdaptor or Flowpack.SimpleSearch.ContentRepositoryAdaptor.
3+
This plugin is just a very bare-bones basis for a Search Plugin, to be used together with
4+
[Flowpack.ElasticSearch.ContentRepositoryAdaptor](https://github.com/Flowpack/Flowpack.ElasticSearch.ContentRepositoryAdaptor)
5+
or [Flowpack.SimpleSearch.ContentRepositoryAdaptor](https://github.com/Flowpack/Flowpack.SimpleSearch.ContentRepositoryAdaptor).
56

67
## Installation
78

8-
Make sure to include the Routes from this package into your main `Configuration/Routes.yaml` by the following snippet:
9-
10-
-
11-
name: 'Flowpack.SearchPlugin'
12-
uriPattern: '<SearchSubroutes>'
13-
subRoutes:
14-
'SearchSubroutes':
15-
package: 'Flowpack.SearchPlugin'
9+
Inclusion of the routes from this package into your main `Configuration/Routes.yaml` is no longer needed as of Flow 4.0.
1610

1711
## Configuration
1812

1913

2014
### Pagination
2115

22-
The pagination search results can be configured via TypoScript. The following shows the defaults:
16+
The pagination search results can be configured via Fusion. The following shows the defaults:
2317

2418
prototype(Flowpack.SearchPlugin:Search).configuration {
2519
itemsPerPage = 25
26-
insertAbove = ${false}
27-
insertBelow = ${true}
20+
insertAbove = false
21+
insertBelow = true
2822
maximumNumberOfLinks = 10
2923
}
3024

3125
### Custom result rendering
3226

33-
The result list is rendered using a TypoScript object of type `nodeType + 'SearchResult'` for each hit.
27+
The result list is rendered using a Fusion object of type `nodeType + 'SearchResult'` for each hit.
3428
Thus you can easily adjust the rendering per type like this for an imaginary `Acme.AcmeCom:Product` nodetype:
3529

36-
prototype(Acme.AcmeCom:ProductSearchResult) < prototype(TYPO3.Neos:DocumentSearchResult) {
30+
prototype(Acme.AcmeCom:ProductSearchResult) < prototype(Neos.Neos:DocumentSearchResult) {
3731
templatePath = 'resource://Acme.AcmeCom/Private/Templates/SearchResult/ProductSearchResult.html'
3832
}
3933

@@ -57,6 +51,6 @@ The plugin comes with a controller that can be reached like this per default, us
5751

5852
{f:uri.action(action: 'index', controller: 'AjaxSearch', package: 'Flowpack.SearchPlugin', absolute: 1)}
5953

60-
It expects the search term as a parameter named `q` (as defined in `AjaxSearch.ts2`). This controller
54+
It expects the search term as a parameter named `q` (as defined in `AjaxSearch.fusion`). This controller
6155
renders the search results and returns them as HTML without any of the page template. It can therefore
6256
be used to request search results via AJAX and display the result by adding it to the DOM as needed.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
prototype(Flowpack.SearchPlugin:AjaxSearch) < prototype(Neos.Fusion:Template) {
22
templatePath = 'resource://Flowpack.SearchPlugin/Private/Templates/NodeTypes/AjaxSearch.html'
3+
34
searchResultRenderer = Flowpack.SearchPlugin:SearchResultRenderer {
45
@context.searchResults = ${Search.query(site).fulltext(request.arguments.q).execute()}
56
}
6-
}
7+
}

Resources/Private/Fusion/ResultRendering.ts2 renamed to Resources/Private/Fusion/ResultRendering.fusion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ prototype(Flowpack.SearchPlugin:SingleResult) < prototype(Neos.Fusion:Case) {
77
}
88

99
fallback {
10-
condition = TRUE
10+
condition = true
1111
type = 'Neos.Neos:DocumentSearchResult'
1212
}
1313
}

0 commit comments

Comments
 (0)