PHRAS-1101_THMB-TRAIN-IN-PREVIEW

backport from master
#time 30m
This commit is contained in:
Jean-Yves Gaulier
2016-05-12 17:16:47 +02:00
parent c7b1b6b78d
commit 378cc45a87
2 changed files with 12 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\SearchEngine;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Authentication\Authenticator; use Alchemy\Phrasea\Authentication\Authenticator;
use Alchemy\Phrasea\Collection\CollectionRepository;
use Alchemy\Phrasea\Collection\Reference\CollectionReferenceCollection; use Alchemy\Phrasea\Collection\Reference\CollectionReferenceCollection;
use Assert\Assertion; use Assert\Assertion;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@@ -74,10 +75,12 @@ class SearchEngineOptions
$collections = []; $collections = [];
foreach ($references->groupByDataboxIdAndCollectionId() as $databoxId => $indexes) { foreach ($references->groupByDataboxIdAndCollectionId() as $databoxId => $indexes) {
/** @var CollectionRepository $repository */
$repository = $app['repo.collections-registry']->getRepositoryByDatabox($databoxId); $repository = $app['repo.collections-registry']->getRepositoryByDatabox($databoxId);
foreach ($indexes as $collectionId => $index) { foreach ($indexes as $collectionId => $index) {
$collections[] = $repository->find($collectionId); $coll = $repository->find($collectionId);
$collections[$coll->get_base_id()] = $coll;
} }
} }
@@ -124,9 +127,9 @@ class SearchEngineOptions
} }
/** @var string */ /** @var string */
protected $record_type; protected $record_type = self::TYPE_ALL;
protected $search_type = 0; protected $search_type = self::RECORD_RECORD;
/** @var \collection[] */ /** @var \collection[] */
protected $collections = []; protected $collections = [];
/** @var null|\databox[] */ /** @var null|\databox[] */

View File

@@ -21,11 +21,13 @@ class SearchEngineOptionsTest extends \PhraseanetTestCase
$app = self::$DI['app']; $app = self::$DI['app'];
/** @var \collection $collection */ /** @var \collection $collection */
$collection = self::$DI['collection']; $collection = self::$DI['collection'];
$collections[$collection->get_base_id()] = $collection;
$options = new SearchEngineOptions($app); $options = new SearchEngineOptions($app);
$options->onCollections([$collection]); $options->onCollections($collections);
$options->setRecordType(SearchEngineOptions::TYPE_ALL);
$options->allowBusinessFieldsOn([$collection]); $options->setSearchType(SearchEngineOptions::RECORD_RECORD);
$options->allowBusinessFieldsOn($collections);
foreach ($collection->get_databox()->get_meta_structure() as $field) { foreach ($collection->get_databox()->get_meta_structure() as $field) {
$options->setFields([$field]); $options->setFields([$field]);
@@ -35,9 +37,9 @@ class SearchEngineOptionsTest extends \PhraseanetTestCase
$min_date = new \DateTime('-5 days'); $min_date = new \DateTime('-5 days');
$max_date = new \DateTime('+5 days'); $max_date = new \DateTime('+5 days');
$options->setMinDate(\DateTime::createFromFormat(DATE_ATOM, $min_date->format(DATE_ATOM))); $options->setMinDate(\DateTime::createFromFormat(DATE_ATOM, $min_date->format(DATE_ATOM)));
$options->setMaxDate(\DateTime::createFromFormat(DATE_ATOM, $max_date->format(DATE_ATOM))); $options->setMaxDate(\DateTime::createFromFormat(DATE_ATOM, $max_date->format(DATE_ATOM)));
$options->setFirstResult(3); $options->setFirstResult(3);
$options->setMaxResults(42); $options->setMaxResults(42);