Files
Phraseanet/lib/Alchemy/Phrasea/TaskManager/Job/IndexerJob.php
2015-12-22 18:34:42 +01:00

58 lines
1.4 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\TaskManager\Editor\IndexerEditor;
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer;
class IndexerJob extends AbstractJob
{
/**
* {@inheritdoc}
*/
public function getName()
{
return $this->translator->trans('Indexation task');
}
/**
* {@inheritdoc}
*/
public function getJobId()
{
return 'Indexer';
}
/**
* {@inheritdoc}
*/
public function getDescription()
{
return $this->translator->trans("Indexing Batch (collections/databox)");
}
/**
* {@inheritdoc}
*/
public function getEditor()
{
return new IndexerEditor($this->translator);
}
/**
* {@inheritdoc}
*/
protected function doJob(JobData $data)
{
$app = $data->getApplication();
/** @var Indexer $indexer */
$indexer = $app['elasticsearch.indexer'];
$databoxes = array_filter($app->getDataboxes(), function (\databox $databox) use ($app) {
return $app->getApplicationBox()->is_databox_indexable($databox);
});
$indexer->indexScheduledRecords($databoxes);
}
}