mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add doublemetaphone function and config to enable-disable usage of double metaphone
This commit is contained in:
parent
82f1aeee19
commit
44d8236f21
@ -101,14 +101,25 @@ class PersonController extends Controller {
|
|||||||
$offset = $this->getRequest()->query->getInt('offet', 0);
|
$offset = $this->getRequest()->query->getInt('offet', 0);
|
||||||
$limit = $this->getRequest()->query->getInt('limit', 30);
|
$limit = $this->getRequest()->query->getInt('limit', 30);
|
||||||
|
|
||||||
$persons = $em->createQuery('SELECT p FROM CLChillPersonBundle:Person p'
|
$dql = 'SELECT p FROM CLChillPersonBundle:Person p'
|
||||||
. ' WHERE LOWER(p.name) like LOWER(:q) OR LOWER(p.surname) '
|
. ' WHERE'
|
||||||
. ' like LOWER(:q) ')
|
. ' LOWER(p.name) like LOWER(:q)'
|
||||||
->setParameter('q', '%'.$q.'%')
|
. ' OR LOWER(p.surname) like LOWER(:q)';
|
||||||
|
|
||||||
|
if ($this->container->getParameter('cl_chill_person.search.use_double_metaphone')) {
|
||||||
|
$dql .= ' OR DOUBLEMETAPHONE(p.name) = DOUBLEMETAPHONE(:qabsolute)';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query = $em->createQuery($dql)
|
||||||
|
->setParameter('q', '%'.$q.'%');
|
||||||
|
if ($this->container->getParameter('cl_chill_person.search.use_double_metaphone')) {
|
||||||
|
$query->setParameter('qabsolute', $q);
|
||||||
|
}
|
||||||
|
|
||||||
// ->setOffset($offset)
|
// ->setOffset($offset)
|
||||||
// ->setLimit($limit)
|
// ->setLimit($limit)
|
||||||
->getResult()
|
$persons = $query->getResult() ;
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
if (count($persons) === 0 ){
|
if (count($persons) === 0 ){
|
||||||
|
@ -21,6 +21,9 @@ class CLChillPersonExtension extends Extension
|
|||||||
{
|
{
|
||||||
$configuration = new Configuration();
|
$configuration = new Configuration();
|
||||||
$config = $this->processConfiguration($configuration, $configs);
|
$config = $this->processConfiguration($configuration, $configs);
|
||||||
|
|
||||||
|
$container->setParameter('cl_chill_person.search.use_double_metaphone',
|
||||||
|
$config['search']['use_double_metaphone']);
|
||||||
|
|
||||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||||
$loader->load('services.yml');
|
$loader->load('services.yml');
|
||||||
|
@ -19,6 +19,18 @@ class Configuration implements ConfigurationInterface
|
|||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder();
|
$treeBuilder = new TreeBuilder();
|
||||||
$rootNode = $treeBuilder->root('cl_chill_person');
|
$rootNode = $treeBuilder->root('cl_chill_person');
|
||||||
|
|
||||||
|
$rootNode
|
||||||
|
->canBeDisabled()
|
||||||
|
->children()
|
||||||
|
->arrayNode('search')
|
||||||
|
->canBeDisabled()
|
||||||
|
->children()
|
||||||
|
->booleanNode('use_double_metaphone')
|
||||||
|
->defaultFalse()
|
||||||
|
->end()
|
||||||
|
->booleanNode('use_trigrams')->defaultFalse()->end();
|
||||||
|
|
||||||
|
|
||||||
// Here you should define the parameters that are allowed to
|
// Here you should define the parameters that are allowed to
|
||||||
// configure your bundle. See the documentation linked above for
|
// configure your bundle. See the documentation linked above for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user