Skip to content

Commit

Permalink
Merge pull request #1224 from ezsystems/impl-EZP-23471-search-semanti…
Browse files Browse the repository at this point in the history
…c-config-2

Implement EZP-23471: semantic configuration for search engines
  • Loading branch information
pspanja committed Apr 16, 2015
2 parents bdadc3b + 0425872 commit bf76f53
Show file tree
Hide file tree
Showing 49 changed files with 1,511 additions and 166 deletions.
43 changes: 43 additions & 0 deletions doc/bc/changes-5.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,49 @@ Changes affecting version compatibility with former or future versions.
Note: Does not affect future Solr/ElasticSearch search engines which has far more
advanced search options built in.

* 5.3.6: Semantic configuration for search engines has been implemented

At the moment of writing, only Legacy Search Engine is supported. Search engine bundles are also
introduced here, these need to be activated in `EzPublishKernel.php` in order for the engine to be
available for configuration. For the Legacy Search Engine the bundle is located at
`eZ/Bundle/EzPublishLegacySearchEngineBundle`.

With semantic configuration for search engines, repository configuration has changed. Previous
structure:

```yml
ezpublish:
repositories:
main:
engine: legacy
connection: default
```

has been updated with search engine configuration. With it, storage settings are now moved under
`storage` key. New structure looks like this:

```yml
ezpublish:
repositories:
main:
storage:
engine: legacy
connection: my_connection
search:
engine: legacy
connection: my_connection
```

The same as was previously the case with storage configuration, it is not mandatory to provide
search configuration. In that case the system will try to use default search engine and default
connection. Old structure is still supported, but is deprecated. The support will be removed in
one of the future releases.

* 5.3.6: `eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageRepositoryProvider` is has been renamed to
`eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider`, as it now provides
repository configuration for both storage and search engines. Class signature has remained the
same.

## Deprecations

* Method `eZ\Publish\API\Repository\RoleService::removePolicy` is deprecated in
Expand Down
43 changes: 43 additions & 0 deletions doc/bc/changes-5.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,49 @@ Changes affecting version compatibility with former or future versions.
Note: Does not affect future Solr/ElasticSearch search engines which has far more
advanced search options built in.

* 5.4.3: Semantic configuration for search engines has been implemented

At the moment of writing, only Legacy Search Engine is supported. Search engine bundles are also
introduced here, these need to be activated in `EzPublishKernel.php` in order for the engine to be
available for configuration. For the Legacy Search Engine the bundle is located at
`eZ/Bundle/EzPublishLegacySearchEngineBundle`.

With semantic configuration for search engines, repository configuration has changed. Previous
structure:

```yml
ezpublish:
repositories:
main:
engine: legacy
connection: default
```

has been updated with search engine configuration. With it, storage settings are now moved under
`storage` key. New structure looks like this:

```yml
ezpublish:
repositories:
main:
storage:
engine: legacy
connection: my_connection
search:
engine: legacy
connection: my_connection
```

The same as was previously the case with storage configuration, it is not mandatory to provide
search configuration. In that case the system will try to use default search engine and default
connection. Old structure is still supported, but is deprecated. The support will be removed in
one of the future releases.

* 5.4.3: `eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageRepositoryProvider` is has been renamed to
`eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider`, as it now provides
repository configuration for both storage and search engines. Class signature has remained the
same.

## Deprecations

* `imagemagick` siteaccess settings are now deprecated. It is mandatory to remove them.
Expand Down
47 changes: 47 additions & 0 deletions doc/bc/changes-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,47 @@ Changes affecting version compatibility with former or future versions.
Note: Does not affect future Solr/ElasticSearch search engines which has far more
advanced search options built in.

* Semantic configuration for search engines has been implemented. At the moment of writing, only
Legacy Search Engine is supported. Search engine bundles are also introduced here, these need to
be activated in `EzPublishKernel.php` in order for the engine to be available for configuration.
For the Legacy Search Engine the bundle is located at `eZ/Bundle/EzPublishLegacySearchEngineBundle`.

With semantic configuration for search engines, repository configuration has changed. Previous
structure:

```yml
ezpublish:
repositories:
main:
engine: legacy
connection: default
```

has been updated with search engine configuration. With it, storage settings are now moved under
`storage` key. New structure looks like this:

```yml
ezpublish:
repositories:
main:
storage:
engine: legacy
connection: my_connection
search:
engine: legacy
connection: my_connection
```

The same as was previously the case with storage configuration, it is not mandatory to provide
search configuration. In that case the system will try to use default search engine and default
connection. Old structure is still supported, but is deprecated. The support will be removed in
one of the future releases.

* `eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageRepositoryProvider` is has been renamed to
`eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider`, as it now provides
repository configuration for both storage and search engines. Class signature has remained the
same.

## Deprecations

* `eZ\Publish\Core\MVC\Symfony\Cache\GatewayCachePurger::purge()` is deprecated and will be removed in v6.1.
Expand Down Expand Up @@ -104,3 +145,9 @@ Changes affecting version compatibility with former or future versions.
* eZ Publish Legacy isn't included by default anymore
The legacy-bridge requirement introduced in this version isn't included by default. The legacy application, as well
as the related bundle, libraries and configuration, are no longer shipped by default.

## Changes from 2015.01 (6.0.0-alpha1)

* Bundle `EzPublishElasticsearchBundle` has been renamed to `EzPublishElasticsearchSearchEngineBundle`

* Bundle `EzPublishSolrBundle` has been renamed to `EzPublishSolrSearchEngineBundle`
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
{
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* File containing the StorageRepositoryProvider class.
* 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.
Expand All @@ -13,9 +13,9 @@
use eZ\Publish\Core\MVC\ConfigResolverInterface;

/**
* The storage repository provider.
* The repository configuration provider.
*/
class StorageRepositoryProvider
class RepositoryConfigurationProvider
{
/**
* @var \eZ\Publish\Core\MVC\ConfigResolverInterface
Expand Down
89 changes: 89 additions & 0 deletions eZ/Bundle/EzPublishCoreBundle/ApiLoader/SearchEngineFactory.php
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']];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
class StorageConnectionFactory extends ContainerAware
{
/**
* @var \eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageRepositoryProvider
* @var \eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider
*/
protected $storageRepositoryProvider;
protected $repositoryConfigurationProvider;

public function __construct( StorageRepositoryProvider $storageRepositoryProvider )
public function __construct( RepositoryConfigurationProvider $repositoryConfigurationProvider )
{
$this->storageRepositoryProvider = $storageRepositoryProvider;
$this->repositoryConfigurationProvider = $repositoryConfigurationProvider;
}

/**
Expand All @@ -33,12 +33,13 @@ public function __construct( StorageRepositoryProvider $storageRepositoryProvide
*/
public function getConnection()
{
$repositoryConfig = $this->storageRepositoryProvider->getRepositoryConfig();
$repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
// Taking provided connection name if any.
// Otherwise, just fallback to the default connection.
if ( isset( $repositoryConfig['connection'] ) )

if ( isset( $repositoryConfig['storage']['connection'] ) )
{
$doctrineConnectionId = sprintf( 'doctrine.dbal.%s_connection', $repositoryConfig['connection'] );
$doctrineConnectionId = sprintf( 'doctrine.dbal.%s_connection', $repositoryConfig['storage']['connection'] );
}
else
{
Expand All @@ -49,7 +50,7 @@ public function getConnection()
if ( !$this->container->has( $doctrineConnectionId ) )
{
throw new InvalidArgumentException(
"Invalid Doctrine connection '{$repositoryConfig['connection']}' for repository '{$repositoryConfig['alias']}'." .
"Invalid Doctrine connection '{$repositoryConfig['storage']['connection']}' for repository '{$repositoryConfig['alias']}'." .
"Valid connections are " . implode( ', ', array_keys( $this->container->getParameter( 'doctrine.connections' ) ) )
);
}
Expand Down
24 changes: 13 additions & 11 deletions eZ/Bundle/EzPublishCoreBundle/ApiLoader/StorageEngineFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
class StorageEngineFactory
{
/**
* @var \eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageRepositoryProvider
* @var \eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider
*/
private $storageRepositoryProvider;
private $repositoryConfigurationProvider;

/**
* Hash of registered storage engines.
Expand All @@ -30,9 +30,9 @@ class StorageEngineFactory
*/
protected $storageEngines = array();

public function __construct( StorageRepositoryProvider $storageRepositoryProvider )
public function __construct( RepositoryConfigurationProvider $repositoryConfigurationProvider )
{
$this->storageRepositoryProvider = $storageRepositoryProvider;
$this->repositoryConfigurationProvider = $repositoryConfigurationProvider;
}

/**
Expand Down Expand Up @@ -65,20 +65,22 @@ public function getStorageEngines()
*/
public function buildStorageEngine()
{
$repositoryConfig = $this->storageRepositoryProvider->getRepositoryConfig();
$repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();

if (
!(
isset( $repositoryConfig['engine'] )
&& isset( $this->storageEngines[$repositoryConfig['engine']] )
)
!(
isset( $repositoryConfig['storage']['engine'] )
&& isset( $this->storageEngines[$repositoryConfig['storage']['engine']] )
)
)
{
throw new InvalidStorageEngine(
"Invalid storage engine '{$repositoryConfig['engine']}'. Could not find any service tagged as ezpublish.storageEngine with alias {$repositoryConfig['engine']}."
"Invalid storage engine '{$repositoryConfig['storage']['engine']}'. " .
"Could not find any service tagged as ezpublish.storageEngine " .
"with alias {$repositoryConfig['storage']['engine']}."
);
}

return $this->storageEngines[$repositoryConfig['engine']];
return $this->storageEngines[$repositoryConfig['storage']['engine']];
}
}
Loading

0 comments on commit bf76f53

Please sign in to comment.