Files
Phraseanet/lib/Alchemy/Phrasea/Border/Checker/Sha256.php
Benoît Burnichon f2e62abd8b Remove !count() calls
2016-03-11 18:03:53 +01:00

49 lines
1.1 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 Doctrine\ORM\EntityManager;
use Symfony\Component\Translation\TranslatorInterface;
/**
* Checks if a file with the same Sha256 checksum already exists in the
* destination databox
*/
class Sha256 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()->findBySha256($file->getSha256()));
return new Response($boolean, $this);
}
/**
* {@inheritdoc}
*/
public function getMessage(TranslatorInterface $translator)
{
return $translator->trans('A file with the same checksum already exists in database');
}
}