original_string: public function handleApiEvent($event)
      {
          $eventName = str_replace('.queued', null, $event->name);
          $ckey = 'event:' . $eventName;
          $records = Cache::remember($ckey, Config::get('df.default_cache_ttl'), function () use ($eventName) {
              return ServiceEventMap::whereEvent($eventName)->get()->all();
          });
          if (empty($records)) {
              // Look for wildcard events by service (example: user.*)
              $serviceName = substr($eventName, 0, strpos($eventName, '.'));
              $wildcardEvent = $serviceName . '.*';
              $ckey = 'event:' . $wildcardEvent;
              $records = Cache::remember($ckey, Config::get('df.default_cache_ttl'), function () use ($wildcardEvent) {
                  return ServiceEventMap::whereEvent($wildcardEvent)->get()->all();
              });
          }
  
          /** @var BaseModel $record */
          foreach ($records as $record) {
              Log::debug('Service event handled: ' . $eventName);
              /** @var BaseRestService $service */
              $service = \ServiceManager::getServiceById($record->service_id);
              Event::fire(new ServiceAssignedEvent($service, $event, $record->toArray()));
          }
      }
code: public function handleApiEvent($event)
      {
          $eventName = str_replace('.queued', null, $event->name);
          $ckey = 'event:' . $eventName;
          $records = Cache::remember($ckey, Config::get('df.default_cache_ttl'), function () use ($eventName) {
              return ServiceEventMap::whereEvent($eventName)->get()->all();
          });
          if (empty($records)) {
              // Look for wildcard events by service (example: user.*)
              $serviceName = substr($eventName, 0, strpos($eventName, '.'));
              $wildcardEvent = $serviceName . '.*';
              $ckey = 'event:' . $wildcardEvent;
              $records = Cache::remember($ckey, Config::get('df.default_cache_ttl'), function () use ($wildcardEvent) {
                  return ServiceEventMap::whereEvent($wildcardEvent)->get()->all();
              });
          }
  
          /** @var BaseModel $record */
          foreach ($records as $record) {
              Log::debug('Service event handled: ' . $eventName);
              /** @var BaseRestService $service */
              $service = \ServiceManager::getServiceById($record->service_id);
              Event::fire(new ServiceAssignedEvent($service, $event, $record->toArray()));
          }
      }
code_tokens: public function handleApiEvent ( $ event ) { $ eventName = str_replace ( '.queued' , null , $ event -> name ) ; $ ckey = 'event:' . $ eventName ; $ records = Cache :: remember ( $ ckey , Config :: get ( 'df.default_cache_ttl' ) , function ( ) use ( $ eventName ) { return ServiceEventMap :: whereEvent ( $ eventName ) -> get ( ) -> all ( ) ; } ) ; if ( empty ( $ records ) ) { // Look for wildcard events by service (example: user.*) $ serviceName = substr ( $ eventName , 0 , strpos ( $ eventName , '.' ) ) ; $ wildcardEvent = $ serviceName . '.*' ; $ ckey = 'event:' . $ wildcardEvent ; $ records = Cache :: remember ( $ ckey , Config :: get ( 'df.default_cache_ttl' ) , function ( ) use ( $ wildcardEvent ) { return ServiceEventMap :: whereEvent ( $ wildcardEvent ) -> get ( ) -> all ( ) ; } ) ; } /** @var BaseModel $record */ foreach ( $ records as $ record ) { Log :: debug ( 'Service event handled: ' . $ eventName ) ; /** @var BaseRestService $service */ $ service = \ ServiceManager :: getServiceById ( $ record -> service_id ) ; Event :: fire ( new ServiceAssignedEvent ( $ service , $ event , $ record -> toArray ( ) ) ) ; } }
docstring: Handle API events.
  
  @param ApiEvent $event
docstring_tokens: Handle API events .