PHRAS-1819: add quarantine rule based on media type

This commit is contained in:
Sandeep
2018-05-07 14:31:12 +04:00
parent 0b6892ac35
commit 7f8251d4e2
3 changed files with 66 additions and 4 deletions

View File

@@ -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())