public function OAuth2ServerEntityController::invoke in OAuth2 Server 7
Overrides EntityAPIControllerExportable::invoke().
Overrides EntityAPIControllerExportable::invoke
File
- includes/
oauth2_server.server_controller.inc, line 13
Class
- OAuth2ServerEntityController
- The entity controller for oauth2_server entities.
Code
public function invoke($hook, $entity) {
if ($hook == 'delete') {
// To ease figuring out whether this is a revert, make sure that the
// entity status is updated in case the providing module has been
// disabled.
if (entity_has_status('oauth2_server_scope', $entity, ENTITY_IN_CODE) && !module_exists($entity->module)) {
$entity->status = ENTITY_CUSTOM;
}
$is_revert = entity_has_status('oauth2_server_scope', $entity, ENTITY_IN_CODE);
}
// The server serves as a bundle for scopes and clients.
if ($hook == 'insert') {
field_attach_create_bundle('oauth2_server_scope', $entity->name);
field_attach_create_bundle('oauth2_server_client', $entity->name);
}
elseif ($hook == 'delete' && empty($is_revert)) {
field_attach_delete_bundle('oauth2_server_scope', $entity->name);
field_attach_delete_bundle('oauth2_server_client', $entity->name);
}
elseif ($hook == 'update' && $entity->original->name != $entity->name) {
field_attach_rename_bundle('oauth2_server_scope', $entity->original->name, $entity->name);
field_attach_rename_bundle('oauth2_server_client', $entity->original->name, $entity->name);
}
parent::invoke($hook, $entity);
}