Skip to content

Commit 0761c35

Browse files
committed
MERGE: Merge branch 'task/update-neos-3.0' into task/merge-master
2 parents 5ee0cea + a210676 commit 0761c35

49 files changed

Lines changed: 2407 additions & 942 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,32 @@ language: php
22
matrix:
33
include:
44
- php: 7.0
5+
env: ES=1
6+
- php: 7.0
7+
env: ES=2
8+
- php: 5.6
9+
env: ES=1
510
- php: 5.6
6-
- php: 5.5
11+
env: ES=2
712
sudo: false
813
before_install:
14+
- export NEOS_TARGET_VERSION=2.3
915
- cd ..
10-
- wget --no-check-certificate https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/2.4.1/elasticsearch-2.4.1.zip && unzip elasticsearch-2.4.1.zip
11-
- mv elasticsearch-2.4.1 elasticsearch
16+
- if [ "$ES" = 1 ]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.5.zip && unzip elasticsearch-1.7.5.zip && mv elasticsearch-1.7.5 elasticsearch; fi
17+
- if [ "$ES" = 2 ]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.4.3.zip && unzip elasticsearch-2.4.3.zip && mv elasticsearch-2.4.3 elasticsearch; fi
1218
- cd elasticsearch
1319
- bin/elasticsearch -d
1420
- cd ..
15-
- git clone https://github.com/neos/neos-base-distribution.git
21+
- git clone https://github.com/neos/neos-base-distribution.git -b ${NEOS_TARGET_VERSION}
1622
- cd neos-base-distribution
17-
- composer require flowpack/elasticsearch-contentrepositoryadaptor dev-master
18-
- composer require typo3/typo3cr-search dev-master
23+
- composer require --no-update --no-interaction flowpack/elasticsearch-contentrepositoryadaptor:3.0.x-dev
1924
install:
20-
- composer install
25+
- composer install --no-interaction
2126
- cd ..
2227
- rm -rf neos-base-distribution/Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor
2328
- mv Flowpack.ElasticSearch.ContentRepositoryAdaptor neos-base-distribution/Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor
2429
- cd neos-base-distribution
2530
script:
26-
- bin/phpunit -c Build/BuildEssentials/PhpUnit/UnitTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Unit
27-
- bin/phpunit -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional
31+
- bin/phpunit --colors -c Build/BuildEssentials/PhpUnit/UnitTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Unit
32+
- if [ "$ES" = 1 ]; then FLOW_CONTEXT="Testing/ElasticVersion1" bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional; fi
33+
- if [ "$ES" = 2 ]; then FLOW_CONTEXT="Testing/ElasticVersion2" bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional; fi

Classes/Command/NodeIndexCommandController.php

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\IndexWorkspaceTrait;
1616
use Neos\Flow\Annotations as Flow;
1717
use Neos\Flow\Cli\CommandController;
18-
use Neos\ContentRepository\Domain\Model\NodeInterface;
18+
use Neos\Neos\Controller\CreateContentContextTrait;
19+
use Neos\ContentRepository\Domain\Model\Workspace;
1920

2021
/**
2122
* Provides CLI features for index handling
@@ -25,6 +26,7 @@
2526
class NodeIndexCommandController extends CommandController
2627
{
2728
use IndexWorkspaceTrait;
29+
use CreateContentContextTrait;
2830

2931
/**
3032
* @Flow\Inject
@@ -131,6 +133,64 @@ public function showMappingCommand()
131133
}
132134
}
133135

136+
/**
137+
* Index a single node by the given identifier and workspace name
138+
*
139+
* @param string $identifier
140+
* @param string $workspace
141+
* @return void
142+
*/
143+
public function indexNodeCommand($identifier, $workspace = null)
144+
{
145+
if ($workspace === null && $this->settings['indexAllWorkspaces'] === false) {
146+
$workspace = 'live';
147+
}
148+
149+
$indexNode = function ($identifier, Workspace $workspace, array $dimensions) {
150+
$context = $this->createContentContext($workspace->getName(), $dimensions);
151+
$node = $context->getNodeByIdentifier($identifier);
152+
if ($node === null) {
153+
$this->outputLine('Node with the given identifier is not found.');
154+
$this->quit();
155+
}
156+
$this->outputLine();
157+
$this->outputLine('Index node "%s" (%s)', [
158+
$node->getLabel(),
159+
$node->getIdentifier(),
160+
]);
161+
$this->outputLine(' workspace: %s', [
162+
$workspace->getName()
163+
]);
164+
$this->outputLine(' node type: %s', [
165+
$node->getNodeType()->getName()
166+
]);
167+
$this->outputLine(' dimensions: %s', [
168+
json_encode($dimensions)
169+
]);
170+
$this->nodeIndexer->indexNode($node);
171+
};
172+
173+
$indexInWorkspace = function ($identifier, Workspace $workspace) use ($indexNode) {
174+
$combinations = $this->contentDimensionCombinator->getAllAllowedCombinations();
175+
if ($combinations === []) {
176+
$indexNode($identifier, $workspace, []);
177+
} else {
178+
foreach ($combinations as $combination) {
179+
$indexNode($identifier, $workspace, $combination);
180+
}
181+
}
182+
};
183+
184+
if ($workspace === null) {
185+
foreach ($this->workspaceRepository->findAll() as $workspace) {
186+
$indexInWorkspace($identifier, $workspace);
187+
}
188+
} else {
189+
$workspace = $this->workspaceRepository->findByIdentifier($workspace);
190+
$indexInWorkspace($identifier, $workspace);
191+
}
192+
}
193+
134194
/**
135195
* Index all nodes by creating a new index and when everything was completed, switch the index alias.
136196
*

Classes/Driver/AbstractDriver.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver;
3+
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+
*/
13+
14+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient;
15+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\LoggerInterface;
16+
use Neos\Flow\Annotations as Flow;
17+
18+
/**
19+
* Abstract Elasticsearch driver
20+
*/
21+
abstract class AbstractDriver
22+
{
23+
/**
24+
* @Flow\Inject
25+
* @var ElasticSearchClient
26+
*/
27+
protected $searchClient;
28+
29+
/**
30+
* @Flow\Inject
31+
* @var LoggerInterface
32+
*/
33+
protected $logger;
34+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver;
3+
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+
*/
13+
14+
use Neos\ContentRepository\Domain\Model\NodeInterface;
15+
16+
/**
17+
* Abstract Fulltext Indexer Driver
18+
*/
19+
abstract class AbstractIndexerDriver extends AbstractDriver
20+
{
21+
/**
22+
* Whether the node is configured as fulltext root.
23+
*
24+
* @param NodeInterface $node
25+
* @return boolean
26+
*/
27+
protected function isFulltextRoot(NodeInterface $node)
28+
{
29+
if ($node->getNodeType()->hasConfiguration('search')) {
30+
$elasticSearchSettingsForNode = $node->getNodeType()->getConfiguration('search');
31+
if (isset($elasticSearchSettingsForNode['fulltext']['isRoot']) && $elasticSearchSettingsForNode['fulltext']['isRoot'] === true) {
32+
return true;
33+
}
34+
}
35+
36+
return false;
37+
}
38+
}

0 commit comments

Comments
 (0)