/** * Internal building method builds all static services and some dynamic * services from file annotations, otherwise swagger info is loaded from * database or storage files for each service, if it exists. * * @throws \Exception */ protected static function buildEventMaps() { \Log::info('Building event cache'); // Build event mapping from services in database // Initialize the event map $processEventMap = []; $broadcastEventMap = []; // Pull any custom swagger docs $result = ServiceModel::with(['serviceDocs' => function ($query) { $query->where('format', ApiDocFormatTypes::SWAGGER); }])->get(); // Spin through services and pull the events foreach ($result as $service) { $apiName = $service->name; try { if (empty($content = ServiceModel::getStoredContentForService($service))) { throw new \Exception(' * No event content found for service.'); continue; } $serviceEvents = static::parseSwaggerEvents($apiName, $content); // Parse the events while we get the chance... $processEventMap[$apiName] = ArrayUtils::get($serviceEvents, 'process', []); $broadcastEventMap[$apiName] = ArrayUtils::get($serviceEvents, 'broadcast', []); unset($content, $service, $serviceEvents); } catch (\Exception $ex) { \Log::error(" * System error building event map for service '{$apiName}'.\n{$ex->getMessage()}"); } } static::$eventMap = ['process' => $processEventMap, 'broadcast' => $broadcastEventMap]; // Write event cache file \Cache::forever(static::EVENT_CACHE_KEY, static::$eventMap); \Log::info('Event cache build process complete'); }