Skip to content

Commit

Permalink
[SearchBundle][NodeSearchBundle] Elastica/Elasticsearch <7 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
acrobat committed Jun 25, 2020
1 parent ddbc8c3 commit 3925ce9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public function load(array $configs, ContainerBuilder $container)
->addMethodCall('setDefaultProperties', [$config['mapping']]);

$container->setParameter('kunstmaan_node_search.contexts', $config['contexts']);

if (class_exists(\Elastica\Type\Mapping::class)) {
$nodeSearch = $container->getDefinition('kunstmaan_node_search.search.node');
$nodeSearch->addMethodCall('setIndexType', ['%kunstmaan_node_search.indextype%']);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ services:
parent: kunstmaan_node_search.search.abstract_elastica_searcher
calls:
- [ setIndexName, ['%kunstmaan_node_search.indexname%']]
- [ setIndexType, ['%kunstmaan_node_search.indextype%']]
- [ setTokenStorage, ['@security.token_storage']]
- [ setDomainConfiguration, ['@kunstmaan_admin.domain_configuration']]
- [ setEntityManager, ['@doctrine.orm.entity_manager']]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,30 @@ public function getIndexName()
}

/**
* @deprecated upgrade to ruflin/elastica and elasticsearch v7 and don't set an index type
*
* @param string $indexType
*
* @return SearcherInterface
*/
public function setIndexType($indexType)
{
@trigger_error(sprintf('The "setIndexType" method in "%s" is deprecated since KunstmaanSearchBundle 5.6 and will be removed in KunstmaanSearchBundle 6.0. Upgrade to ruflin/elastica and elasticsearch v7 and don\'t set an index type.', __CLASS__), E_USER_DEPRECATED);

$this->indexType = $indexType;

return $this;
}

/**
* @deprecated upgrade to ruflin/elastica and elasticsearch v7 and don't set an index type
*
* @return string
*/
public function getIndexType()
{
@trigger_error(sprintf('The "getIndexType" method in "%s" is deprecated since KunstmaanSearchBundle 5.6 and will be removed in KunstmaanSearchBundle 6.0. Upgrade to ruflin/elastica and elasticsearch v7 and don\'t set an index type.', __CLASS__), E_USER_DEPRECATED);

return $this->indexType;
}

Expand Down
4 changes: 4 additions & 0 deletions src/Kunstmaan/NodeSearchBundle/Search/SearcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@ public function setIndexName($name);
public function getIndexName();

/**
* @deprecated upgrade to ruflin/elastica and elasticsearch v7 and don't set an index type
*
* @param string $indexType
*
* @return SearcherInterface
*/
public function setIndexType($indexType);

/**
* @deprecated upgrade to ruflin/elastica and elasticsearch v7 and don't set an index type
*
* @return string
*/
public function getIndexType();
Expand Down
5 changes: 5 additions & 0 deletions src/Kunstmaan/SearchBundle/Provider/ElasticaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public function getClient()
array('connections' => $this->nodes,
)
);

//NEXT_MAJOR: remove checks and update ruflin/elastica dependency constraints
if (!class_exists(\Elastica\Mapping::class)) {
@trigger_error('Using a version of ruflin/elastica below v7.0 is deprecated since KunstmaanSearchBundle 5.6 and support for older versions will be removed in KunstmaanSearchBundle 6.0. Upgrade to ruflin/elastica and elasticsearch v7 instead.', E_USER_DEPRECATED);
}
}

return $this->client;
Expand Down

0 comments on commit 3925ce9

Please sign in to comment.