You are here

public function DrupalCommerceEntityController::invoke in Commerce Core 7

(Internal use) Invokes a hook on behalf of the entity.

For hooks that have a respective field API attacher like insert/update/.. the attacher is called too.

Overrides EntityAPIControllerInterface::invoke

2 calls to DrupalCommerceEntityController::invoke()
DrupalCommerceEntityController::delete in includes/commerce.controller.inc
Delete permanently saved entities.
DrupalCommerceEntityController::save in includes/commerce.controller.inc
Permanently saves the given entity.

File

includes/commerce.controller.inc, line 130
Provides a central controller for Drupal Commerce.

Class

DrupalCommerceEntityController
Default implementation of DrupalCommerceEntityControllerInterface.

Code

public function invoke($hook, $entity) {
  if (!empty($this->entityInfo['fieldable']) && function_exists($function = 'field_attach_' . $hook)) {
    $function($this->entityType, $entity);
  }

  // Invoke the hook.
  module_invoke_all($this->entityType . '_' . $hook, $entity);

  // Invoke the respective entity level hook.
  if ($hook == 'presave' || $hook == 'insert' || $hook == 'update' || $hook == 'delete') {
    module_invoke_all('entity_' . $hook, $entity, $this->entityType);
  }

  // Invoke rules.
  if (module_exists('rules')) {
    rules_invoke_event($this->entityType . '_' . $hook, $entity);
  }
}