Files
Phraseanet/lib/Alchemy/Phrasea/Border/Checker/UUID.php
Jean-Yves Gaulier 837a294827 PHRAS-1192_quarantaine-by-filenames_4.0
- add : quarantine thumbnails looks like result thb (zoom, caption, infos, ...) by using the same template
 - removed : some code about highlighting titles
 - fix : double extension on exported files
2016-09-28 13:16:10 +02:00

69 lines
1.6 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Border\Checker;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Translation\TranslatorInterface;
/**
* Checks if a file with the same UUID already exists in the destination databox
*/
class UUID extends AbstractChecker
{
public function __construct(Application $app)
{
parent::__construct($app);
}
/**
* {@inheritdoc}
*/
public function check(EntityManager $em, File $file)
{
$boolean = empty($file->getCollection()->get_databox()->getRecordRepository()->findByUuid($file->getUUID()));
return new Response($boolean, $this);
}
/**
* @param Application $app
* @param LazaretFile $file
* @return \record_adapter[]
*/
public static function listConflicts(Application $app, LazaretFile $file)
{
$databox = $file->getCollection($app)->get_databox();
return $databox->getRecordRepository()->findByUuid($file->getUUID());
}
/**
* {@inheritdoc}
*/
public static function getReason(TranslatorInterface $translator)
{
return $translator->trans('same UUID');
}
/**
* {@inheritdoc}
*/
public function getMessage(TranslatorInterface $translator)
{
return $translator->trans('A file with the same UUID already exists in database');
}
}