PHRAS-2069 rescan file metadata command (#4420)

This commit is contained in:
Aina Sitraka
2023-11-29 16:09:43 +03:00
committed by GitHub
parent d1d15daa54
commit 7bfd9569d8
7 changed files with 368 additions and 18 deletions

View File

@@ -45,6 +45,9 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\ORM\EntityManager;
use MediaVorus\MediaVorus;
use Monolog\Logger;
use PHPExiftool\Driver\Metadata\Metadata;
use PHPExiftool\Reader;
use Ramsey\Uuid\Uuid;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\File\File as SymfoFile;
@@ -1266,6 +1269,34 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
return $this;
}
/**
* @param $tag
* @return array|null
* @throws \PHPExiftool\Exception\EmptyCollectionException
*/
public function getFileMetadataByTag($tag)
{
$logger = new Logger('exif-tool');
$reader = Reader::create($logger);
$value = null;
// throw exception
$documentSubdef = $this->get_subdef('document');
$metadatas = $reader->files($documentSubdef->getRealPath())->first();
/** @var Metadata $metadata */
foreach ($metadatas as $metadata) {
if ($metadata->getTag() == $tag) {
$value = explode(";", $metadata->getValue());
break;
}
}
return $value;
}
/*
* =============================================================================