2121 */
2222class SaveImageInformation
2323{
24- private const IMAGE_FILE_NAME_PATTERN = '#\.(jpg|jpeg|gif|png)$# i ' ;
25-
2624 /**
2725 * @var IsPathExcludedInterface
2826 */
@@ -48,25 +46,33 @@ class SaveImageInformation
4846 */
4947 private $ synchronizeFiles ;
5048
49+ /**
50+ * @var string[]
51+ */
52+ private $ imageExtensions ;
53+
5154 /**
5255 * @param Filesystem $filesystem
5356 * @param LoggerInterface $log
5457 * @param IsPathExcludedInterface $isPathExcluded
5558 * @param SynchronizeFilesInterface $synchronizeFiles
5659 * @param ConfigInterface $config
60+ * @param array $imageExtensions
5761 */
5862 public function __construct (
5963 Filesystem $ filesystem ,
6064 LoggerInterface $ log ,
6165 IsPathExcludedInterface $ isPathExcluded ,
6266 SynchronizeFilesInterface $ synchronizeFiles ,
63- ConfigInterface $ config
67+ ConfigInterface $ config ,
68+ array $ imageExtensions
6469 ) {
6570 $ this ->log = $ log ;
6671 $ this ->isPathExcluded = $ isPathExcluded ;
6772 $ this ->filesystem = $ filesystem ;
6873 $ this ->synchronizeFiles = $ synchronizeFiles ;
6974 $ this ->config = $ config ;
75+ $ this ->imageExtensions = $ imageExtensions ;
7076 }
7177
7278 /**
@@ -75,6 +81,7 @@ public function __construct(
7581 * @param Uploader $subject
7682 * @param array $result
7783 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
84+ * @return array
7885 */
7986 public function afterSave (Uploader $ subject , array $ result ): array
8087 {
@@ -103,7 +110,7 @@ private function isApplicable(string $path): bool
103110 try {
104111 return $ path
105112 && !$ this ->isPathExcluded ->execute ($ path )
106- && preg_match (self :: IMAGE_FILE_NAME_PATTERN , $ path );
113+ && preg_match (' #\.( ' . implode ( " | " , $ this -> imageExtensions ) . ' )$# i ' , $ path );
107114 } catch (\Exception $ exception ) {
108115 $ this ->log ->critical ($ exception );
109116 return false ;
0 commit comments