/** * Sets the param with the passed name, type and value. * * @param string $name The param name * @param string $type The param type * @param mixed $value The param value * * @return void */ public function setParam($name, $type, $value) { // initialize the param to set $paramToSet = new ParamNode($name, $type, new NodeValue($value)); // query whether a param with this name has already been set foreach ($this->params as $key => $param) { if ($param->getName() === $paramToSet->getName()) { // override the param $this->params[$key] = $paramToSet; return; } } // append the param $this->params[] = $paramToSet; }
/** * Returns an array with initialized parameters. * * @return array<\AppserverIo\Appserver\Core\Api\Node\ParamNode> The array with params */ public function getParamNodes() { $configuration = new Configuration(); $configuration->initFromFile(__DIR__ . '/_files/params.xml'); $params = array(); foreach ($configuration->getChilds('/params/param') as $paramConfiguration) { $paramNode = new ParamNode(); $paramNode->initFromConfiguration($paramConfiguration); $params[$paramNode->getName()] = $paramNode; } return $params; }
/** * Initializes the default logger configuration. * * @return void */ protected function initDefaultLoggers() { // we dont need any processors $processors = array(); // initialize the params for the system logger handler $handlerParams = array(); $logLevelParam = new ParamNode('logLevel', 'string', new NodeValue(LogLevel::INFO)); $logFileParam = new ParamNode('logFile', 'string', new NodeValue('var/log/appserver-errors.log')); $handlerParams[$logFileParam->getPrimaryKey()] = $logFileParam; $handlerParams[$logLevelParam->getPrimaryKey()] = $logLevelParam; // initialize the handler $handlers = array(); $handler = new HandlerNode('\\AppserverIo\\Logger\\Handlers\\CustomFileHandler', null, $handlerParams); $handlers[$handler->getPrimaryKey()] = $handler; // initialize the system logger with the processor and the handlers $systemLogger = new LoggerNode(LoggerUtils::SYSTEM, '\\AppserverIo\\Logger\\Logger', 'system', $processors, $handlers); // we dont need any processors $processors = array(); // initialize the params for the access logger formatter $formatterParams = array(); $messageFormatParam = new ParamNode('format', 'string', new NodeValue('%4$s')); $formatterParams[$messageFormatParam->getPrimaryKey()] = $messageFormatParam; // initialize the formatter for the access logger $formatter = new FormatterNode('\\AppserverIo\\Logger\\Formatters\\StandardFormatter', $formatterParams); // initialize the params for the system logger handler $handlerParams = array(); $logLevelParam = new ParamNode('logLevel', 'string', new NodeValue(LogLevel::DEBUG)); $logFileParam = new ParamNode('logFile', 'string', new NodeValue('var/log/appserver-access.log')); $handlerParams[$logFileParam->getPrimaryKey()] = $logFileParam; $handlerParams[$logLevelParam->getPrimaryKey()] = $logLevelParam; // initialize the handler $handlers = array(); $handler = new HandlerNode('\\AppserverIo\\Logger\\Handlers\\CustomFileHandler', $formatter, $handlerParams); $handlers[$handler->getPrimaryKey()] = $handler; // initialize the system logger with the processor and the handlers $accessLogger = new LoggerNode(LoggerUtils::ACCESS, '\\AppserverIo\\Logger\\Logger', 'access', $processors, $handlers); // add the loggers to the default logger configuration $this->loggers[$systemLogger->getPrimaryKey()] = $systemLogger; $this->loggers[$accessLogger->getPrimaryKey()] = $accessLogger; }