From bfef58672c851226654a145d236d820c511e5d87 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 17 Dec 2021 08:45:28 +0100 Subject: [PATCH] Added new "is_route" helper method --- application/helpers/routes_helper.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/application/helpers/routes_helper.php b/application/helpers/routes_helper.php index bc2179a2..1711101a 100644 --- a/application/helpers/routes_helper.php +++ b/application/helpers/routes_helper.php @@ -29,3 +29,19 @@ if ( ! function_exists('route_api_resource')) $route[$prefix . $resource . '/(:num)']['get'] = 'api/v1/' . $resource . '_api_v1/show/$1'; } } + +if ( ! function_exists('is_route')) +{ + /** + * Check whether the current request matches the provided routed URI. + * + * @param string $uri Routed URI (as in controller/method). + */ + function is_route(string $uri): bool + { + /** @var EA_Controller $CI */ + $CI =& get_instance(); + + return $CI->uri->ruri_string() === $uri; + } +}