2021-11-06 12:18:46 +03:00
|
|
|
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
2024-01-01 01:14:38 +03:00
|
|
|
|
* MaketRandevu - MAKET Randevu Portalı
|
2021-11-06 12:18:46 +03:00
|
|
|
|
*
|
|
|
|
|
* @package EasyAppointments
|
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2021-12-18 19:43:45 +03:00
|
|
|
|
* @copyright Copyright (c) Alex Tselegidis
|
|
|
|
|
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
|
* @link https://easyappointments.org
|
2021-11-06 12:18:46 +03:00
|
|
|
|
* @since v1.3.0
|
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('route_api_resource')) {
|
2021-11-06 12:18:46 +03:00
|
|
|
|
/**
|
|
|
|
|
* Define a route for an API resource (includes index, store, update and delete callbacks).
|
|
|
|
|
*
|
|
|
|
|
* @param array $route Route config.
|
|
|
|
|
* @param string $resource Resource name.
|
2023-03-13 11:06:18 +03:00
|
|
|
|
* @param string $prefix URL prefix (e.g. api/v1/).
|
2021-11-06 12:18:46 +03:00
|
|
|
|
*/
|
2023-03-13 11:06:18 +03:00
|
|
|
|
function route_api_resource(array &$route, string $resource, string $prefix = ''): void
|
2021-11-06 12:18:46 +03:00
|
|
|
|
{
|
|
|
|
|
$route[$prefix . $resource]['post'] = 'api/v1/' . $resource . '_api_v1/store';
|
|
|
|
|
$route[$prefix . $resource . '/(:num)']['put'] = 'api/v1/' . $resource . '_api_v1/update/$1';
|
|
|
|
|
$route[$prefix . $resource . '/(:num)']['delete'] = 'api/v1/' . $resource . '_api_v1/destroy/$1';
|
|
|
|
|
$route[$prefix . $resource]['get'] = 'api/v1/' . $resource . '_api_v1/index';
|
|
|
|
|
$route[$prefix . $resource . '/(:num)']['get'] = 'api/v1/' . $resource . '_api_v1/show/$1';
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-17 10:45:28 +03:00
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('is_callback')) {
|
2021-12-17 10:45:28 +03:00
|
|
|
|
/**
|
2021-12-17 12:36:47 +03:00
|
|
|
|
* Check whether the current request matches the provided controller/method callback.
|
2021-12-17 10:45:28 +03:00
|
|
|
|
*
|
2023-11-29 12:24:09 +03:00
|
|
|
|
* @param string $class Controller class name.
|
2021-12-17 12:36:47 +03:00
|
|
|
|
* @param string $method Controller method name.
|
2023-11-29 12:24:09 +03:00
|
|
|
|
*
|
2021-12-17 12:36:47 +03:00
|
|
|
|
* @return bool
|
2021-12-17 10:45:28 +03:00
|
|
|
|
*/
|
2021-12-17 12:36:47 +03:00
|
|
|
|
function is_callback(string $class, string $method): bool
|
2021-12-17 10:45:28 +03:00
|
|
|
|
{
|
|
|
|
|
/** @var EA_Controller $CI */
|
2023-11-29 12:24:09 +03:00
|
|
|
|
$CI = &get_instance();
|
2021-12-17 10:45:28 +03:00
|
|
|
|
|
2021-12-17 12:36:47 +03:00
|
|
|
|
return $CI->router->class === $class && $CI->router->method === $method;
|
2021-12-17 10:45:28 +03:00
|
|
|
|
}
|
|
|
|
|
}
|