PHP Classes

File: plugins/loader.php

Recommend this page to a friend!
  Classes of Marco Cesarato   PHP API Database   plugins/loader.php   Download  
File: plugins/loader.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP API Database
Provide access to database records via REST API
Author: By
Last change: Reformatted code (php-cs-fixer)

Added code standard,
Added hooks git for code standard,
Fixed parse where on null elements
Date: 5 years ago
Size: 1,767 bytes
 

Contents

Class file image Download
<?php
/**
 * Hooks - Loader.
 *
 * @author Marco Cesarato <cesarato.developer@gmail.com>
 */
use marcocesarato\DatabaseAPI\Hooks;

require_once
__API_DIR_PLUGINS__ . '/functions.php';
require_once
__API_DIR_PLUGINS__ . '/filters.php';
require_once
__API_DIR_PLUGINS__ . '/actions.php';

$hooks = Hooks::getInstance();

// Include plugins
$dir = new RecursiveDirectoryIterator(__API_DIR_PLUGINS__);
$ite = new RecursiveIteratorIterator($dir);
$pattern = '/^.+\/([^\/]+)\/([^\/]+)\.hooks\.php$/';
$files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH);
foreach (
$files as $file) {
    include_once
$file[0];
}

// Register loaders
$hooks->add_filter('on_read', 'loader_on_read_tables', 25);
$hooks->add_filter('on_write', 'loader_on_write_tables', 25);
$hooks->add_filter('on_edit', 'loader_on_edit_tables', 25);

// Register filters and actions
$hooks->add_action('custom_api_call', 'action_custom_api_call', 1);
$hooks->add_action('on_error', 'action_on_error');
$hooks->add_filter('sql_restriction', 'filter_sql_restriction');
$hooks->add_filter('can_read', 'filter_can_read');
$hooks->add_filter('can_write', 'filter_can_write');
$hooks->add_filter('can_edit', 'filter_can_edit');
$hooks->add_filter('can_delete', 'filter_can_delete');
$hooks->add_filter('on_read', 'filter_on_read');
$hooks->add_filter('on_write', 'filter_on_write');
$hooks->add_filter('on_edit', 'filter_on_edit');
$hooks->add_filter('auth_validate_user', 'filter_auth_validate_user');
$hooks->add_filter('auth_validate_token', 'filter_auth_validate_token');
$hooks->add_filter('auth_user_id', 'filter_auth_user_id');
$hooks->add_filter('auth_bypass', 'filter_auth_bypass');
$hooks->add_filter('auth_login', 'filter_auth_login');
$hooks->add_filter('render', 'filter_render');