zapis pola ako parametru pre metodu v neonu
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- duskohu
- Člen | 778
Caute, viete mi poradit? Mam triedu Logger\FileLogger a v nej metodu createFileLogger a tejto metode potrebujem predat parametre v poli, ako to mam vyriesit?
class FileLogger extends \Nette\Object implements ILogger{
.....
public static function createFileLogger($options = array())
{
$logger = new FileLogger();
if (isset($options['filenameMask']))
$logger->setFilenameMask($options['filenameMask']);
if (isset($options['minimumLogLevel']))
$logger->setMinimumLogLevel(self::parseLevel($options['minimumLogLevel']));
if (isset($options['defaultLogLevel']))
$logger->setDefaultLogLevel(self::parseLevel($options['defaultLogLevel']));
if (isset($options['logDir']))
$logger->setLogDir($options['logDir']);
if (isset($options['granularity']))
$logger->setGranularity((int) $options['granularity']);
if (isset($options['dateFormat']))
$logger->setDateFormat($options['dateFormat']);
return $logger;
}
.....
}
neon:
services:
NetteLogger:
class: Logger\FileLogger::createFileLogger
options:
defaultLogLevel: ERROR
minimumLogLevel: INFO
dateFormat: c
vracia mi to:
Service 'NetteLogger': Unknown key 'options' in definition of service
- Jan Tvrdík
- Nette guru | 2595
services:
NetteLogger:
class: Logger\FileLogger::createFileLogger
arguments:
options:
defaultLogLevel: ERROR
minimumLogLevel: INFO
dateFormat: c
- vvoody
- Člen | 910
Aha :D ty potrebujes nieco ako toto:
services:
NetteLogger:
class: Logger\FileLogger
factory: Logger\FileLogger::createFileLogger
arguments:
options:
defaultLogLevel: ERROR
minimumLogLevel: INFO
dateFormat: c
Mozno aj bez riadku class, logicky by ho nemalo byt treba, ale ruku za to do ohna nedam :)