/** * 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 collector list and try to find a match by name */ $collectors = Factory::getCollectors(); foreach ($collectors as $collectorName) { if ($collectorName === ucfirst($requiredName)) { $collectorClass = 'AbuseIO\\Collectors\\' . $collectorName; // Collector is enabled, then return its object if (config("collectors.{$collectorName}.collector.enabled") === true) { return new $collectorClass(); } else { Log::info('AbuseIO\\Collectors\\Factory: ' . "The collector {$collectorName} has been disabled and will not be used."); } } } // No valid collectors found Log::info('AbuseIO\\Collectors\\Factory: ' . "The collector {$requiredName} is not present on this system"); return false; }