|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the `liip/LiipImagineBundle` project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Liip\ImagineBundle\Config; |
|
13
|
|
|
|
|
14
|
|
|
use Liip\ImagineBundle\Exception\InvalidArgumentException; |
|
15
|
|
|
|
|
16
|
|
|
final class Stack implements StackInterface |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
private $name; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $dataLoader; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var int |
|
30
|
|
|
*/ |
|
31
|
|
|
private $quality; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var FilterInterface[] |
|
35
|
|
|
*/ |
|
36
|
|
|
private $filters = []; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param string|null $dataLoader name of a custom data loader. Default value: filesystem (which means the standard filesystem loader is used). |
|
40
|
|
|
* @param FilterInterface[] $filters |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct(string $name, string $dataLoader = null, int $quality = null, array $filters) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->name = $name; |
|
45
|
|
|
$this->dataLoader = $dataLoader; |
|
46
|
|
|
$this->quality = $quality; |
|
47
|
|
|
$this->setFilters($filters); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getName(): string |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->name; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function getDataLoader(): ?string |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->dataLoader; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function getQuality(): ?int |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->quality; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return FilterInterface[] |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getFilters(): array |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->filters; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param FilterInterface[] $filters |
|
75
|
|
|
*/ |
|
76
|
|
|
private function setFilters(array $filters): void |
|
77
|
|
|
{ |
|
78
|
|
|
foreach ($filters as $filter) { |
|
79
|
|
|
if (!($filter instanceof FilterInterface)) { |
|
80
|
|
|
throw new InvalidArgumentException('Unknown filter provided.'); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
$this->filters = $filters; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|