/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { // initialize the server context $this->serverContext = $serverContext; // initialize the profile logger if ($serverContext->hasLogger(LoggerUtils::PROFILE)) { $this->profileLogger = $serverContext->getLogger(LoggerUtils::PROFILE); } }
/** * Initiates the module * * @param \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext The server's context instance * * @return bool * @throws \AppserverIo\Server\Exceptions\ModuleException */ public function init(ServerContextInterface $serverContext) { $this->typeInstances = array(); $this->serverContext = $serverContext; $this->authentications = $serverContext->getServerConfig()->getAuthentications(); $systemLogger = $serverContext->getLogger(LoggerUtils::SYSTEM); // check if authentication are given if (is_array($this->authentications)) { // init all uri patterns foreach ($this->authentications as $uri => $params) { $this->uriPatterns[$uri] = $params; // try to get authentication type instance try { // pre init types by calling getter in init $this->getAuthenticationInstance($uri, $params); } catch (\Exception $e) { // log exception as warning to not end up with a server break $systemLogger->warning($e->getMessage()); } } } }
/** * Will init the parameter mappings for our hit types * * @param array $params The parameters to check for requirements * * @return null */ protected function checkInputParameters(array $params) { // we only check if we know the requirements if (isset($this->requiredParameters[$params['t']])) { foreach ($this->requiredParameters[$params['t']] as $requirement) { if (!isset($params[$requirement])) { // do the logging, preferably by one of our loggers $message = 'We miss the required parameter "%s", you might not get proper analytics!'; if ($this->serverContext->hasLogger(LoggerUtils::SYSTEM)) { $logger = $this->serverContext->getLogger(LoggerUtils::SYSTEM); $logger->warning(sprintf($message, $requirement)); } else { error_log(sprintf($message, $requirement)); } } } } }