1 | <?php |
||
12 | abstract class Filter implements FilterInterface |
||
13 | { |
||
14 | /** |
||
15 | * Filter's name |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $name; |
||
20 | |||
21 | /** |
||
22 | * Filter's configuration |
||
23 | * |
||
24 | * @var ConfigurationInterface |
||
25 | */ |
||
26 | protected $configuration; |
||
27 | |||
28 | /** |
||
29 | * Notification dispatcher |
||
30 | * |
||
31 | * @var EventDispatcherInterface |
||
32 | */ |
||
33 | protected $eventDispatcher; |
||
34 | |||
35 | /** |
||
36 | * Apply a filter to a list of source files |
||
37 | * |
||
38 | * @param SplFileInfo[] $files |
||
39 | * @param SplFileInfo[] $destinations |
||
40 | * |
||
41 | * @return SplFileInfo[] |
||
42 | */ |
||
43 | abstract public function run(array $files, array $destinations); |
||
44 | |||
45 | /** |
||
46 | * Filter constructor. |
||
47 | * |
||
48 | * @param string $name |
||
49 | * @param ConfigurationInterface $configuration |
||
50 | * @param EventDispatcherInterface $eventDispatcher |
||
51 | */ |
||
52 | public function __construct( |
||
61 | |||
62 | /** |
||
63 | * Use this method to check your filter requirements (for example, if the library required by this filter are |
||
64 | * installed). |
||
65 | */ |
||
66 | public function checkRequirements() |
||
69 | |||
70 | /** |
||
71 | * Remove the assets cache directory. |
||
72 | */ |
||
73 | public function clean() |
||
81 | |||
82 | /** |
||
83 | * Return the assets cache dir. |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | public function getCacheDir() |
||
98 | |||
99 | /** |
||
100 | * @return string |
||
101 | */ |
||
102 | public function getName() |
||
106 | |||
107 | /** |
||
108 | * Return files matching $pattern in filters cache directory. |
||
109 | * |
||
110 | * @param string $pattern |
||
111 | * |
||
112 | * @return Finder|SplFileInfo[] |
||
113 | */ |
||
114 | protected function findFilesInCacheDir($pattern) |
||
123 | |||
124 | /** |
||
125 | * Add a notification to the subscriber. |
||
126 | * |
||
127 | * @param $message |
||
128 | */ |
||
129 | protected function addNotification($message) |
||
139 | } |
||
140 |