Skip to content

3.2) Hooks: List

Marco Cesarato edited this page May 20, 2019 · 10 revisions

All hooks

Hook Type Description Params Return Default function
custom_api_call Action Create custom API Call (ex. localhost/example/custom/call.json) void action_custom_api_call
sql_restriction Filter Add restriction on where conditions for each query (string) $restriction (string) $table (string) $permission String filter_sql_restriction
can_read Filter Return if can get/select (bool) $permission = true Bool filter_can_read
can_write Filter Return if can post/insert (bool) $permission = true Bool filter_can_write
can_edit Filter Return if can put/update (bool) $permission = true Bool filter_can_edit
can_delete Filter Return if can delete (bool) $permission = true Bool filter_can_delete
on_error Action On error occurred (string) $error (int) $code void filter_on_error
on_read Filter Result content returned on get/read (object) $data (string) $table Object filter_on_read
on_write Filter Result content returned on post/write (object) $data (string) $table Object filter_on_write
on_edit Filter Result content returned on put/edit (object) $data (string) $table Object filter_on_edit
on_delete Filter Get result content returned on delete (object) $data (string) $table Object filter_on_delete
auth_validate_token Filter Validate token (bool) $is_valid (sstring) $token Bool filter_auth_validate_token
auth_user_id Filter Filter user auth login id to force one (string) $user_id String filter_auth_user_id
auth_bypass Filter Bypass authentication (bool) $bypass = false Bool filter_bypass_authentication
auth_login Filter Login data result (object) $data Object filter_auth_login
auth_login_request Filter Check if is a login request (bool) $is_valid_request = false (array) $query Bool filter_auth_login_request
auth_token_check Filter Token check data result (object) $data Object filter_auth_token_check
auth_validate_user Filter Validate user (bool) $is_valid (array) $user_row Bool filter_auth_validate_user
render Filter Manipulate render response data (array) $data (array) $query (string) $method Array filter_render

Hooks detail

  • Filter: sql_restriction

    Options of $permission:

    case 'READ':
    case 'EDIT':
    case 'DELETE':

    Return

    // All denied
    $sql = "'1' = '0'";
    // All allowed
    $sql = "'1' = '1'";

    Examples:

    // Only Created
    $sql = 'created_by = '.$user['id'];
    // Only Team
    $sql = 'created_by IN ('.implode(',',$teams_ids).')';
Clone this wiki locally