several config.neon, need service from another config.neon

Notice: This thread is very old.
mcmatak
Member | 504
+
0
-

i am trying to load several config.neon files:

$configurator->addConfig($this->parameters['cronModuleAppDir'] . '/config/config.neon', $configurator::AUTO);
$configurator->addConfig($this->parameters['coreAppDir'] . '/config/config.services.neon');
$configurator->addConfig($this->parameters['appDir'] . '/config/config.neon');

but i still get this error:

Service of type Loggers\LoggerService needed by System\Application\Cron\CronQueueFactory::__construct()

this is due to the cronqueuefactory is defined in core/config.services.neon and loggerservice is defined in cronmodule/config.neon

how to solve it?

based on url i add different configuration files, in one you have filelogger, in another you have consolelogger etc.

any idea?

mcmatak
Member | 504
+
0
-

mcmatak wrote:

i am trying to load several config.neon files:

$configurator->addConfig($this->parameters['cronModuleAppDir'] . '/config/config.neon', $configurator::AUTO);
$configurator->addConfig($this->parameters['coreAppDir'] . '/config/config.services.neon');
$configurator->addConfig($this->parameters['appDir'] . '/config/config.neon');

but i still get this error:

Service of type Loggers\LoggerService needed by System\Application\Cron\CronQueueFactory::__construct()

this is due to the cronqueuefactory is defined in core/config.services.neon and loggerservice is defined in cronmodule/config.neon

how to solve it?

based on url i add different configuration files, in one you have filelogger, in another you have consolelogger etc.

any idea?

the same problem is when you have services injection in your presenters and you have services defined in more config.neon files, when you add the first config.neon the presenters are checked if the service is defined, and dont wait for next config.neon

David Matějka
Moderator | 6445
+
0
-

this is due to the cronqueuefactory is defined in core/config.services.neon and loggerservice is defined in cronmodule/config.neon

when you add the first config.neon the presenters are checked if the service is defined, and dont wait for next config.neon

That is not the reason – all config files are loaded before services are processed. Could you please show the content of config files?

mcmatak
Member | 504
+
0
-

$configurator->addConfig($this->parameters[‘cronModuleAppDir’] . ‘/config/config.neon’, $configurator::AUTO);

common:
	parameters:

	php:
		date.timezone: Europe/Prague
		mssql.charset: UTF-8

	application:
		errorPresenter: Error
		mapping:
			*: App\*Module\Presenters\*Presenter

	session:
		expiration: 14 days

	extensions:
		varioConnection: Dibi\Bridges\Nette\DibiExtension22

	services:
		routerFactory: CronModule\System\Router\RouterFactory
		router: @routerFactory::createRouter

production < common: []
development < common: []
console < common: []

$configurator->addConfig($this->parameters[‘coreAppDir’] . ‘/config/config.services.neon’);

extensions:
	webloader: WebLoader\Nette\Extension
	translation: Kdyby\Translation\DI\TranslationExtension

services:
	user: Security\User
	- Security\Authorizator
	- Model\Users\UsersService

	# jaky logger pouzijeme? bude se logovat na consoli nebo do souboru
	#logger: Loggers\Console\ConsoleLoggerFactory(%logVerbosity%)
	logger: Loggers\File\FileLoggerFactory(%logDir%, %logVerbosity%)

	- Loggers\LoggerService(@logger)

	# logovani sql query dotazu do souboru, nema nic spolecneho s klasickymi ILoggerService
	#loggers.databaseLogger:
	#	class: Loggers\NetteDatabaseLogger\NetteDatabaseLoggerService
	#	arguments: [%logDir%, "Y-m-d-H-i-s"]
	#	tags: [run]


	varioConnection:
		class: Database\SqlVario(%varioConnection%)

	- {class: System\Listeners\DisableSessionListener, tags: [kdyby.subscriber]}

	- System\Application\Cron\CronQueueFactory

	- LogisticModule\Model\Vario\VarioAgendaServices(%varioAvisUrl%)

	- AdminModule\Connector\ConnectorService("%appDir%/config/googledrive")

	- AdminModule\Model\DefaultEventService
	- AdminModule\Model\DefaultLocaleEventService
	- AdminModule\Model\Producers\ProducerEventService
	- AdminModule\Model\Users\UserEventService
	- AdminModule\Model\Categories\CategoryEventService
	- AdminModule\Model\ParameterValueLocales\ParameterValueLocaleEventService
	- AdminModule\Model\ParameterValues\ParameterValueEventService

	- AdminModule\Model\DefaultFormBuilderService
	- AdminModule\Model\SearchTemplates\SearchTemplateFormBuilderService
	- AdminModule\Model\Roles\RoleFormBuilderService
	- AdminModule\Model\Users\UserFormBuilderService
	- AdminModule\Model\Products\ProductFormBuilderService

	- System\FileUploader\FileUploaderService("%appDir%/media")

	- Model\Import\ImportImagesService("%appDir%/media/import/images")

$configurator->addConfig($this->parameters[‘appDir’] . ‘/config/config.neon’);

parameters:
	media:
		relativeMediaDir: "/media"

	images:
		allowed:
			sizes: {20x20, 100x100, 1000x1000, 1000x100}

includes:
	- config.local.neon

config.local.neon

parameters:
	salt: xyz
	logVerbosity: 1
mcmatak
Member | 504
+
0
-

but the problem is during the services processing, bcs if you have services in 2 config.neon it is problem, when you try to add first config nette check all injection in presenters, if it find injection which is not included in first config it crash,

if it is feature, so very hard to join configs based on independent modules

David Matějka
Moderator | 6445
+
0
-

Where do you call those ->addConfig? do you have it before createContainer()? Could you show bootstrap.php?