1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rvdlee\ZfImageOptimiser\Factory\Service; |
4
|
|
|
|
5
|
|
|
use Interop\Container\ContainerInterface; |
6
|
|
|
use Rvdlee\ZfImageOptimiser\Exception\InvalidArgumentException; |
7
|
|
|
use Rvdlee\ZfImageOptimiser\Exception\InvalidConfigurationException; |
8
|
|
|
use Rvdlee\ZfImageOptimiser\Interfaces\ImageOptimiserInterface; |
9
|
|
|
use Rvdlee\ZfImageOptimiser\Service\ImageOptimiserService; |
10
|
|
|
use Zend\Log\Logger; |
|
|
|
|
11
|
|
|
use Zend\Log\LoggerInterface; |
|
|
|
|
12
|
|
|
use Zend\Log\Writer\Mock; |
|
|
|
|
13
|
|
|
use Zend\Log\Writer\Stream; |
|
|
|
|
14
|
|
|
use Zend\ServiceManager\Factory\FactoryInterface; |
15
|
|
|
|
16
|
|
|
class ImageOptimiserServiceFactory implements FactoryInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @param ContainerInterface $container |
20
|
|
|
* @param string $requestedName |
21
|
|
|
* @param array|null $options |
22
|
|
|
* |
23
|
|
|
* @return object|ImageOptimiserService |
24
|
|
|
* @throws InvalidConfigurationException |
25
|
|
|
* @throws InvalidArgumentException |
26
|
|
|
*/ |
27
|
|
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
28
|
|
|
{ |
29
|
|
|
/** @var array|ImageOptimiserInterface $adapters */ |
30
|
|
|
$adapters = []; |
31
|
|
|
/** @var array $config */ |
32
|
|
|
$config = $container->get('config'); |
33
|
|
|
|
34
|
|
|
if ( ! isset($config['rvdlee']['zf-image-optimiser']['enabled'])) { |
35
|
|
|
throw new InvalidConfigurationException('We are missing configuration to make this code work.'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
foreach ($config['rvdlee']['zf-image-optimiser']['enabled'] as $adapter) { |
39
|
|
|
$adapters[] = $container->get($adapter); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if (isset($options['logger']) && $options['logger'] instanceof LoggerInterface) { |
43
|
|
|
$logger = $options['logger']; |
44
|
|
|
} else { |
45
|
|
|
/** @var Logger $logger */ |
46
|
|
|
$logger = $container->get(Logger::class); |
47
|
|
|
/** @var Stream $writer */ |
48
|
|
|
$logger->addWriter(new Mock()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return new ImageOptimiserService($adapters, $logger); |
52
|
|
|
} |
53
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths