You are here

function services_client_process_events in Services Client 7.2

Process entity by trigerring all events that are enabled and are matching conditions.

Parameters

string $event: Event type - 'save', 'delete'.

stdClass $entity: Drupal entity.

string $entity_type: Entity type name.

Return value

array Array of ServicesClientEventResult objects which are representing all executed operations. This array doesn't include queued events.

7 calls to services_client_process_events()
ServicesClientErrorWebTestCase::testServicesClientErrors in services_client_error/tests/services_client_error.test
ServicesClientHooksWebTestCase::testServicesClientHooks in tests/services_client.test
ServicesClientWebTestCase::testServicesClientProcessing in tests/services_client.test
services_client_entity_delete in ./services_client.module
Implements hook_entity_delete().
services_client_entity_insert in ./services_client.module
Implements hook_entity_insert().

... See full list

File

./services_client.module, line 265

Code

function services_client_process_events($event, $entity, $entity_type) {
  $events = services_client_event_load_active($event, $entity_type);
  $results = array();

  // Go through all events
  foreach ($events as $event) {
    $handler = $event
      ->getHandler();
    $handler
      ->setEntity($entity);

    // Entity can be synced to event in following cases
    // 1. Event is auto triggered
    // 2. Entity shouldn't be skipped
    // 3. Enttiy shouldn't be processed via queue
    if ($handler
      ->isAutoTriggered() && !$handler
      ->skipAutosync()) {

      // Check if entity matches all event sync conditions.
      if ($handler
        ->isMatching()) {

        // Check if shouldn't be enqueued.
        if (!$handler
          ->enqueue()) {
          $results[] = $handler
            ->execute();
        }
      }
    }
  }

  // Allow other modules to react on changes.
  if (!empty($results)) {
    module_invoke_all('services_client_process_events', $results);
  }
  return $results;
}