Commit ae985c33 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix merge

parent fed61e1b
Loading
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -2117,6 +2117,16 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi
        $this->getSearchEngineStrategy()->addActivity($activity);
    }

    public function searchIndex_rebuildProject()
    {
        // PROJETS
        $projects = $this->getEntityManager()->getRepository(Project::class)->findAll();

        $this->getLoggerService()->info('[elasic] Reindex ' . count($projects) . ' project(s)');
        $this->getSearchEngineProjectStrategy()->rebuildIndex($projects);
    }


    /**
     * Retourne les jalons de l'activité.
     *
@@ -2158,6 +2168,24 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi
        return true;
    }

    public function getSearchEngineProjectStrategy()
    {
        static $searchStrategy;
        if ($searchStrategy === null) {
            $opt = $this->getOscarConfigurationService()->getConfiguration('strategy.activity.search_engine');
            $params = $opt['params'];
            $params[] = $this->getLoggerService();
            $class = new \ReflectionClass(ProjectElasticSearch::class);
            $searchStrategy = $class->newInstanceArgs($params);

            $searchStrategy->staticDatas = [
                'typesChainIds' => $this->getActivityTypeService()->getIdsTreeByLast(),
                'typesChainlabels' => $this->getActivityTypeService()->getIdsTreeByLast(true),
            ];
        }

        return $searchStrategy;
    }

    /**
     * @return IActivitySearchStrategy
@@ -2171,7 +2199,14 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi
            $params[] = $this->getLoggerService();
            $class = new \ReflectionClass($opt['class']);
            $searchStrategy = $class->newInstanceArgs($params);
            if ($searchStrategy instanceof ElasticActivitySearch) {
                $searchStrategy->staticDatas = [
                    'typesChainIds' => $this->getActivityTypeService()->getIdsTreeByLast(),
                    'typesChainlabels' => $this->getActivityTypeService()->getIdsTreeByLast(true),
                ];
            }
        }

        return $searchStrategy;
    }