I have the problem
If I just add in config/autoload/global.php:
'service_manager' => [
'factories' => [
...
ImageResizerService::class => ImageResizerServiceFactory::class,
ImageMagick::class => ImageMagickFactory::class,
],
],
and
'rvdlee' => [
'zf-image-resizer' => [
'adapter' => \Rvdlee\ZfImageResizer\Adapter\ImageMagick::class,
'validator-chain' => [
['name' => \Zend\Validator\File\IsImage::class],
],
],
],
Than I can get ImageResizerService in any factory by:
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
...
$imageResizerService = $container->get(ImageResizerService::class);
...
}
As in extension’s documentation GitHub - rvdlee/zf-image-resizer: A Zend Package to make image resizing easier..
But as I understood, this must working without providing of factories in configuration. As I see, extension have all this configuration (and more) in vendor/rvdlee/zf-image-resizer/config/module.config.php:
return [
'console' => [
'router' => [
'routes' => [
'console_image_resizer' => [
'options' => [
'route' => 'image-resizer [--image=]',
'defaults' => [
'controller' => ConsoleController::class,
'action' => 'resizeImage',
],
],
],
],
],
],
'controllers' => [
'factories' => [
ConsoleController::class => ConsoleControllerFactory::class,
],
],
'service_manager' => [
'factories' => [
ImageResizerService::class => ImageResizerServiceFactory::class,
ImageMagick::class => ImageMagickFactory::class,
],
],
'filters' => [
'factories' => [
ImageResizer::class => ImageResizerFactory::class,
],
],
];
This should be handled when loading the module. But if I trying to add modulename (‘ZfImageResizer’) to config/modules.config.php of my Application module, than I get the fatal error:
Fatal error: Uncaught Zend\ModuleManager\Exception\RuntimeException: Module (ZfImageResizer) could not be initialized. in Path/To/My/Project\vendor\zendframework\zend-modulemanager\src\ModuleManager.php:201
Stack trace: #0 Path/To/My/Project\vendor\zendframework\zend-modulemanager\src\ModuleManager.php(173): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
#1 Path/To/My/Project\vendor\zendframework\zend-modulemanager\src\ModuleManager.php(95): Zend\ModuleManager\ModuleManager->loadModule(‘ZfImageResizer’)
#2 Path/To/My/Project\vendor\zendframework\zend-eventmanager\src\EventManager.php(322): Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#3 Path/To/My/Project\vendor\zendframework\zend-eventmanager\src\EventManager.php(171): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\Modul in Path/To/My/Project\vendor\zendframework\zend-modulemanager\src\ModuleManager.php on line 201
Please, tell me, where is my mistake can be? Thank you!