-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1224 from ezsystems/impl-EZP-23471-search-semanti…
…c-config-2 Implement EZP-23471: semantic configuration for search engines
- Loading branch information
Showing
49 changed files
with
1,511 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
eZ/Bundle/EzPublishCoreBundle/ApiLoader/Exception/InvalidSearchEngine.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* This file is part of the eZ Publish Kernel package | ||
* | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
* @version //autogentag// | ||
*/ | ||
|
||
namespace eZ\Bundle\EzPublishCoreBundle\ApiLoader\Exception; | ||
|
||
use InvalidArgumentException; | ||
|
||
class InvalidSearchEngine extends InvalidArgumentException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
eZ/Bundle/EzPublishCoreBundle/ApiLoader/SearchEngineFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* This file is part of the eZ Publish Kernel package | ||
* | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
* @version //autogentag// | ||
*/ | ||
|
||
namespace eZ\Bundle\EzPublishCoreBundle\ApiLoader; | ||
|
||
use eZ\Bundle\EzPublishCoreBundle\ApiLoader\Exception\InvalidSearchEngine; | ||
use eZ\Publish\SPI\Search\Handler as SearchHandler; | ||
|
||
/** | ||
* The search engine factory. | ||
*/ | ||
class SearchEngineFactory | ||
{ | ||
/** | ||
* @var \eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider | ||
*/ | ||
private $repositoryConfigurationProvider; | ||
|
||
/** | ||
* Hash of registered search engines. | ||
* Key is the search engine identifier, value search handler itself. | ||
* | ||
* @var \eZ\Publish\SPI\Search\Handler[] | ||
*/ | ||
protected $searchEngines = array(); | ||
|
||
public function __construct( RepositoryConfigurationProvider $repositoryConfigurationProvider ) | ||
{ | ||
$this->repositoryConfigurationProvider = $repositoryConfigurationProvider; | ||
} | ||
|
||
/** | ||
* Registers $searchHandler as a valid search engine with identifier $searchEngineIdentifier. | ||
* | ||
* @note It is strongly recommended to register a lazy persistent handler. | ||
* | ||
* @param \eZ\Publish\SPI\Search\Handler $searchHandler | ||
* @param string $searchEngineIdentifier | ||
*/ | ||
public function registerSearchEngine( SearchHandler $searchHandler, $searchEngineIdentifier ) | ||
{ | ||
$this->searchEngines[$searchEngineIdentifier] = $searchHandler; | ||
} | ||
|
||
/** | ||
* Returns registered search engines. | ||
* | ||
* @return \eZ\Publish\SPI\Search\Handler[] | ||
*/ | ||
public function getSearchEngines() | ||
{ | ||
return $this->searchEngines; | ||
} | ||
|
||
/** | ||
* Builds search engine identified by its identifier (the "alias" attribute in the service tag), | ||
* resolved for current siteaccess. | ||
* | ||
* @throws \eZ\Bundle\EzPublishCoreBundle\ApiLoader\Exception\InvalidSearchEngine | ||
* | ||
* @return \eZ\Publish\SPI\Persistence\Handler | ||
*/ | ||
public function buildSearchEngine() | ||
{ | ||
$repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig(); | ||
|
||
if ( | ||
!( | ||
isset( $repositoryConfig['search']['engine'] ) | ||
&& isset( $this->searchEngines[$repositoryConfig['search']['engine']] ) | ||
) | ||
) | ||
{ | ||
throw new InvalidSearchEngine( | ||
"Invalid search engine '{$repositoryConfig['search']['engine']}'. " . | ||
"Could not find a service tagged as 'ezpublish.searchEngine' " . | ||
"with alias '{$repositoryConfig['search']['engine']}'." | ||
); | ||
} | ||
|
||
return $this->searchEngines[$repositoryConfig['search']['engine']]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.