/** * Bootstrap the application services. * * @return void */ public function boot() { /* * Provide a method to override the default configuration per environment. We only accept three named * environments called development, testing and production. Each of these environments has a directory * inside config where an config override can be made. */ $envConfig = Config::get(app()->environment()); if (!empty($envConfig) && is_array($envConfig)) { foreach ($envConfig as $configKey => $configElement) { $overrideConfig = $envConfig[$configKey]; $defaultConfig = Config::get($configKey); $configWithOverrides = array_replace_recursive($defaultConfig, $overrideConfig); Config::set($configKey, $configWithOverrides); } } /* * Were updating the timezone manually because we are updating the config later then boot. Using method from: * vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php * This enforces the timezone we use in the override config file. */ date_default_timezone_set(config('app.timezone')); // Publish config files of all installed Parsers // All parser configs we will put into the master 'parsers' tree of the config // So we can easily walk through all of them based on the active configuration $parserList = ParserFactory::getParsers(); $this->buildConfig($parserList, 'parser'); // Publish config files of all installed Collectors the same way $collectorList = CollectorFactory::getCollectors(); $this->buildConfig($collectorList, 'collector'); // Publish config files of all installed Collectors the same way $notificationList = NotificationFactory::getNotification(); $this->buildConfig($notificationList, 'notification'); }
/** * Create and return a Collector object and it's configuration * * @param string $requiredName * @return object */ public static function create($requiredName) { /** * Loop through the notification list and try to find a match by name */ $notifications = Factory::getNotification(); foreach ($notifications as $notificationName) { if ($notificationName === ucfirst($requiredName)) { $notificationClass = 'AbuseIO\\Notification\\' . $notificationName; // Collector is enabled, then return its object if (config("notifications.{$notificationName}.notification.enabled") === true) { return new $notificationClass(); } else { Log::info('AbuseIO\\Notification\\Factory: ' . "The notification {$notificationName} has been disabled and will not be used."); return false; } } } // No valid notifications found Log::info('AbuseIO\\Notification\\Factory: ' . "The notification {$requiredName} is not present on this system"); return false; }