Class and factory are missing in definition of service ‘*’

Notice: This thread is very old.
holantomas
Member | 55
+
0
-

Hi I don't know if it's bug or “feature” BUT.

If I try to use combinatione Nette\DI\CompilerExtension with standard config.neon setup it's throws Class and factory are missing in definition of service 'testService'.

Extension file

class TestExtension extends CompilerExtension {

    public function loadConfiguration() {
        $builder    = $this->getContainerBuilder();


        $builder->addDefinition($this->prefix('testService'))
            ->setClass('NameSpace\TestClass');
    }

}

config.neno

extensions:
	test: TestExtension

services:

	# Repositories
	studentsRepository: App\MainModul\Model\StudentsRepository
	personsRepository: App\MainModul\Model\PersonsRepository
	addressesRepository: App\MainModul\Model\AddressesRepository
	countriesRepository: App\MainModul\Model\CountriesRepository

	testService:
		setup:
			- "$service->addModel(?,?)"('1',@studentsRepository)
			- "$service->addModel(?,?)"('2',@personsRepository)
			- "$service->addModel(?,?)"('3',@addressesRepository)
			- "$service->addModel(?,?)"('4',@countriesRepository)

I am doing something wrong?

jiri.pudil
Nette Blogger | 1029
+
0
-

The prefix method in CompilerExtension prefixes the service name with the name of the extension as registered in extensions section, i.e. in your case it is test.testService

holantomas
Member | 55
+
0
-

It's working. Thanks! Never read about that.

EDIT: This topic can be closed.

Last edited by holantomas (2016-04-04 13:18)