mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
start subdef creation after first write meta
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
namespace Alchemy\Phrasea\TaskManager\Job;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent;
|
||||
use Alchemy\Phrasea\Core\PhraseaTokens;
|
||||
use Alchemy\Phrasea\Metadata\TagFactory;
|
||||
use Alchemy\Phrasea\TaskManager\Editor\WriteMetadataEditor;
|
||||
@@ -69,7 +71,7 @@ class WriteMetadataJob extends AbstractJob
|
||||
foreach ($jobData->getApplication()->getDataboxes() as $databox) {
|
||||
$connection = $databox->get_connection();
|
||||
|
||||
$statement = $connection->prepare('SELECT record_id, coll_id, jeton FROM record WHERE (jeton & :token > 0)');
|
||||
$statement = $connection->prepare('SELECT record_id, coll_id, work, jeton FROM record WHERE (jeton & :token > 0)');
|
||||
$statement->execute(['token' => PhraseaTokens::WRITE_META]);
|
||||
$rs = $statement->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$statement->closeCursor();
|
||||
@@ -203,6 +205,13 @@ class WriteMetadataJob extends AbstractJob
|
||||
'record_id' => $record_id,
|
||||
'token' => PhraseaTokens::WRITE_META,
|
||||
]);
|
||||
|
||||
// write meta for the document is finished
|
||||
// if it's a new record, order to create subdef
|
||||
if (count($record->get_subdefs()) == 3 && count($subdefs) == 1 && isset($subdefs['document']) && $row['work'] != 1) {
|
||||
$this->getDispatcher($jobData->getApplication())->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($record, true));
|
||||
}
|
||||
|
||||
$statement->closeCursor();
|
||||
}
|
||||
}
|
||||
@@ -217,6 +226,11 @@ class WriteMetadataJob extends AbstractJob
|
||||
return $app['exiftool.writer'];
|
||||
}
|
||||
|
||||
private function getDispatcher(Application $app)
|
||||
{
|
||||
return $app['dispatcher'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \databox $databox
|
||||
* @param string $subdefType
|
||||
|
||||
Reference in New Issue
Block a user