0

I have a factory within Module/src/Module/Service/Factory/CourseServiceFactory.php

I have defined this factory in module.config.php as follows:

'service_manager' => array(
        'factories' => array(
            'CourseServiceFactory' => 'Module\Service\Factory\CourseServiceFactory',
        ),
),

However this factory isn't being loaded upon calling the application and I receive this error:

Warning: Missing argument 1 for Module\Service\CourseService::__construct(),

This is how my CourseServiceFactory.php looks like:

public function createService(ServiceLocatorInterface $serviceLocator)
{
    $config = $serviceLocator->get('config');

    return new CourseService($config);
}

Anyone have any idea what's wrong?

HelmBurger
  • 1,168
  • 5
  • 15
  • 35

1 Answers1

0

I suspect you're not implementing the factory interface which causes the service loader to be injected into the constructor.

Make sure your factory implements:

Zend\ServiceManager\FactoryInterface

See example factory here

https://framework.zend.com/manual/2.4/en/in-depth-guide/services-and-servicemanager.html

Andrew
  • 12,617
  • 1
  • 34
  • 48