mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
PHRAS-1819: add quarantine rule based on media type
This commit is contained in:
@@ -20,6 +20,7 @@ use Symfony\Component\Translation\TranslatorInterface;
|
||||
class Colorspace extends AbstractChecker
|
||||
{
|
||||
protected $colorspaces;
|
||||
protected $mediatypes;
|
||||
|
||||
const COLORSPACE_RGB = 'rgb';
|
||||
const COLORSPACE_CMYK = 'cmyk';
|
||||
@@ -32,7 +33,12 @@ class Colorspace extends AbstractChecker
|
||||
throw new \InvalidArgumentException('Missing "colorspaces" options');
|
||||
}
|
||||
|
||||
if (!isset($options['media_types'])) {
|
||||
throw new \InvalidArgumentException('Missing "media_types" options');
|
||||
}
|
||||
|
||||
$this->colorspaces = array_map('strtolower', (array) $options['colorspaces']);
|
||||
$this->mediatypes = $options['media_types'];
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
@@ -42,8 +48,8 @@ class Colorspace extends AbstractChecker
|
||||
|
||||
if (0 === count($this->colorspaces)) {
|
||||
$boolean = true; //bypass color if empty array
|
||||
} elseif ($file->getMedia()->getType() === Document::TYPE_DOCUMENT) {
|
||||
$boolean = true; //bypass color checker if file is of type document
|
||||
} elseif (0 !== count($this->mediatypes) && $file->getMedia()->getType() !== NULL && !in_array($file->getMedia()->getType(), $this->mediatypes)) {
|
||||
$boolean = true; //bypass color checker if media type is not in the config
|
||||
} elseif (method_exists($file->getMedia(), 'getColorSpace')) {
|
||||
$colorspace = null;
|
||||
switch ($file->getMedia()->getColorSpace())
|
||||
|
Reference in New Issue
Block a user