Skip to content

Commit de8e4d6

Browse files
committed
Merge branch '2.0' into dfeyer-bugfix-escape-slash
# Conflicts: # Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Eel/ElasticSearchQueryBuilder.php
2 parents 3e22bb3 + cf0a7eb commit de8e4d6

26 files changed

Lines changed: 983 additions & 814 deletions
File renamed without changes.

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
language: php
22
matrix:
33
include:
4+
- php: 7.0
45
- php: 5.6
56
- php: 5.5
67
sudo: false
78
before_install:
89
- cd ..
9-
- wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.0.zip && unzip elasticsearch-1.7.0.zip
10-
- mv elasticsearch-1.7.0 elasticsearch
10+
- wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.5.zip && unzip elasticsearch-1.7.5.zip
11+
- mv elasticsearch-1.7.5 elasticsearch
1112
- cd elasticsearch
1213
- bin/elasticsearch -d
1314
- cd ..
1415
- git clone https://github.com/neos/neos-base-distribution.git
1516
- cd neos-base-distribution
1617
- composer require flowpack/elasticsearch-contentrepositoryadaptor dev-master
18+
- composer require typo3/typo3cr-search dev-master
1719
install:
1820
- composer install
1921
- cd ..
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?php
22
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Client;
33

4-
/* *
5-
* This script belongs to the TYPO3 Flow package "Flowpack.ElasticSearch.ContentRepositoryAdaptor". *
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.ElasticSearch.ContentRepositoryAdaptor package.
6+
*
7+
* (c) Contributors of the Neos Project - www.neos.io
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

14+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient;
15+
use Flowpack\ElasticSearch\Domain\Model\Client;
1416
use TYPO3\Flow\Annotations as Flow;
1517

1618
/**
@@ -29,10 +31,10 @@ class ClientFactory
2931
/**
3032
* Create a client
3133
*
32-
* @return \Flowpack\ElasticSearch\Domain\Model\Client
34+
* @return Client
3335
*/
3436
public function create()
3537
{
36-
return $this->clientFactory->create(null, 'Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient');
38+
return $this->clientFactory->create(null, ElasticSearchClient::class);
3739
}
3840
}

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Command/NodeIndexCommandController.php

Lines changed: 22 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<?php
22
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Command;
33

4-
/* *
5-
* This script belongs to the TYPO3 Flow package "Flowpack.ElasticSearch.ContentRepositoryAdaptor". *
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.ElasticSearch.ContentRepositoryAdaptor package.
6+
*
7+
* (c) Contributors of the Neos Project - www.neos.io
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

14+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Mapping\NodeTypeMappingBuilder;
15+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\IndexWorkspaceTrait;
1416
use TYPO3\Flow\Annotations as Flow;
1517
use TYPO3\Flow\Cli\CommandController;
16-
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Mapping\NodeTypeMappingBuilder;
17-
use TYPO3\TYPO3CR\Domain\Service\ContentDimensionCombinator;
18-
use TYPO3\TYPO3CR\Search\Indexer\NodeIndexingManager;
1918

2019
/**
2120
* Provides CLI features for index handling
@@ -24,18 +23,14 @@
2423
*/
2524
class NodeIndexCommandController extends CommandController
2625
{
26+
use IndexWorkspaceTrait;
27+
2728
/**
2829
* @Flow\Inject
2930
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Indexer\NodeIndexer
3031
*/
3132
protected $nodeIndexer;
3233

33-
/**
34-
* @Flow\Inject
35-
* @var NodeIndexingManager
36-
*/
37-
protected $nodeIndexingManager;
38-
3934
/**
4035
* @Flow\Inject
4136
* @var \TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository
@@ -54,12 +49,6 @@ class NodeIndexCommandController extends CommandController
5449
*/
5550
protected $nodeFactory;
5651

57-
/**
58-
* @Flow\Inject
59-
* @var \TYPO3\TYPO3CR\Domain\Service\ContextFactory
60-
*/
61-
protected $contextFactory;
62-
6352
/**
6453
* @Flow\Inject
6554
* @var \TYPO3\Neos\Domain\Service\ContentDimensionPresetSourceInterface
@@ -72,21 +61,6 @@ class NodeIndexCommandController extends CommandController
7261
*/
7362
protected $nodeTypeMappingBuilder;
7463

75-
/**
76-
* @var integer
77-
*/
78-
protected $indexedNodes;
79-
80-
/**
81-
* @var integer
82-
*/
83-
protected $countedIndexedNodes;
84-
85-
/**
86-
* @var integer
87-
*/
88-
protected $limit;
89-
9064
/**
9165
* @Flow\Inject
9266
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\LoggerInterface
@@ -99,12 +73,6 @@ class NodeIndexCommandController extends CommandController
9973
*/
10074
protected $configurationManager;
10175

102-
/**
103-
* @Flow\Inject
104-
* @var ContentDimensionCombinator
105-
*/
106-
protected $contentDimensionCombinator;
107-
10876
/**
10977
* @var array
11078
*/
@@ -192,23 +160,24 @@ public function buildCommand($limit = null, $update = false, $workspace = null,
192160
$this->logger->log(sprintf('Indexing %snodes ... ', ($limit !== null ? 'the first ' . $limit . ' ' : '')), LOG_INFO);
193161

194162
$count = 0;
195-
$this->limit = $limit;
196-
$this->indexedNodes = 0;
197-
$this->countedIndexedNodes = 0;
198163

199164
if ($workspace === null && $this->settings['indexAllWorkspaces'] === false) {
200165
$workspace = 'live';
201166
}
202167

168+
$callback = function ($workspaceName, $indexedNodes, $dimensions) {
169+
if ($dimensions === []) {
170+
$this->outputLine('Workspace "' . $workspaceName . '" without dimensions done. (Indexed ' . $indexedNodes . ' nodes)');
171+
} else {
172+
$this->outputLine('Workspace "' . $workspaceName . '" and dimensions "' . json_encode($dimensions) . '" done. (Indexed ' . $indexedNodes . ' nodes)');
173+
}
174+
};
203175
if ($workspace === null) {
204176
foreach ($this->workspaceRepository->findAll() as $workspace) {
205-
$this->indexWorkspace($workspace->getName());
206-
207-
$count = $count + $this->countedIndexedNodes;
177+
$count += $this->indexWorkspace($workspace->getName(), $limit, $callback);
208178
}
209179
} else {
210-
$this->indexWorkspace($workspace);
211-
$count = $count + $this->countedIndexedNodes;
180+
$count += $this->indexWorkspace($workspace, $limit, $callback);
212181
}
213182

214183
$this->nodeIndexingManager->flushQueues();
@@ -243,60 +212,4 @@ public function cleanupCommand()
243212
$this->logger->log(sprintf('Nothing removed. ElasticSearch responded with status %s, saying "%s"', $response->status, $response->error));
244213
}
245214
}
246-
247-
/**
248-
* @param string $workspaceName
249-
* @return void
250-
*/
251-
protected function indexWorkspace($workspaceName)
252-
{
253-
$combinations = $this->contentDimensionCombinator->getAllAllowedCombinations();
254-
if ($combinations === array()) {
255-
$this->indexWorkspaceWithDimensions($workspaceName);
256-
} else {
257-
foreach ($combinations as $combination) {
258-
$this->indexWorkspaceWithDimensions($workspaceName, $combination);
259-
}
260-
}
261-
}
262-
263-
/**
264-
* @param string $workspaceName
265-
* @param array $dimensions
266-
* @return void
267-
*/
268-
protected function indexWorkspaceWithDimensions($workspaceName, array $dimensions = array())
269-
{
270-
$context = $this->contextFactory->create(array('workspaceName' => $workspaceName, 'dimensions' => $dimensions));
271-
$rootNode = $context->getRootNode();
272-
273-
$this->traverseNodes($rootNode);
274-
275-
if ($dimensions === array()) {
276-
$this->outputLine('Workspace "' . $workspaceName . '" without dimensions done. (Indexed ' . $this->indexedNodes . ' nodes)');
277-
} else {
278-
$this->outputLine('Workspace "' . $workspaceName . '" and dimensions "' . json_encode($dimensions) . '" done. (Indexed ' . $this->indexedNodes . ' nodes)');
279-
}
280-
281-
$this->countedIndexedNodes = $this->countedIndexedNodes + $this->indexedNodes;
282-
$this->indexedNodes = 0;
283-
}
284-
285-
/**
286-
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $currentNode
287-
* @return void
288-
*/
289-
protected function traverseNodes(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $currentNode)
290-
{
291-
if ($this->limit !== null && $this->indexedNodes > $this->limit) {
292-
return;
293-
}
294-
295-
$this->nodeIndexingManager->indexNode($currentNode);
296-
$this->indexedNodes++;
297-
298-
foreach ($currentNode->getChildNodes() as $childNode) {
299-
$this->traverseNodes($childNode);
300-
}
301-
}
302215
}

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Command/NodeTypeCommandController.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Command;
33

4-
/* *
5-
* This script belongs to the TYPO3 Flow package "Flowpack.ElasticSearch.ContentRepositoryAdaptor". *
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.ElasticSearch.ContentRepositoryAdaptor package.
6+
*
7+
* (c) Contributors of the Neos Project - www.neos.io
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\Cli\CommandController;
@@ -43,7 +43,7 @@ public function showCommand($nodeType = null)
4343
$configuration = $nodeType->getFullConfiguration();
4444
} else {
4545
$nodeTypes = $this->nodeTypeManager->getNodeTypes();
46-
$configuration = array();
46+
$configuration = [];
4747
/** @var \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType */
4848
foreach ($nodeTypes as $nodeTypeName => $nodeType) {
4949
$configuration[$nodeTypeName] = $nodeType->getFullConfiguration();

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Eel/ElasticSearchQuery.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel;
33

4-
/* *
5-
* This script belongs to the TYPO3 Flow package "Flowpack.ElasticSearch.ContentRepositoryAdaptor". *
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.ElasticSearch.ContentRepositoryAdaptor package.
6+
*
7+
* (c) Contributors of the Neos Project - www.neos.io
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 Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception;
1515
use TYPO3\Flow\Persistence\QueryInterface;
@@ -30,6 +30,11 @@ class ElasticSearchQuery implements QueryInterface
3030
*/
3131
protected static $runtimeQueryResultCache;
3232

33+
/**
34+
* ElasticSearchQuery constructor.
35+
*
36+
* @param ElasticSearchQueryBuilder $elasticSearchQueryBuilder
37+
*/
3338
public function __construct(ElasticSearchQueryBuilder $elasticSearchQueryBuilder)
3439
{
3540
$this->queryBuilder = $elasticSearchQueryBuilder;
@@ -46,6 +51,7 @@ public function execute($cacheResult = false)
4651
}
4752
$queryResult = new ElasticSearchQueryResult($this);
4853
self::$runtimeQueryResultCache[$queryHash] = $queryResult;
54+
4955
return $queryResult;
5056
}
5157

0 commit comments

Comments
 (0)