<?php
namespace Lia;
/**
* A class to organize all hook names across the main package.
* This class started on Aug 22, 2024. Pre-existing hooks may get added into here, but I have no explicit plans to do that.
* New hooks hopefully will all be added here.
*/
class Hooks {
/**
* Registered hooks should be:
* function receive_hook(Lia\Package\Server $package_routes_are_loaded_from, $array_of_patterns): array of patterns
*
* $array_of_patterns is array<string rel_file_name, string url> & return value should be same.
*/
const PACKAGE_ROUTE_PATTERNS_LOADED = 'lia:package.route_patterns_loaded';
/**
* Called after a view's content has been loaded. Provides an opportunity to modify this content.
* This only supports having one registered handler. More than one registered will throw exception
*
* @param $view is a file path or a callable. Callable may be an anonymous function or an array (`[$obj, 'method']`) or string 'some_function'.
* @return string content The original content will be replaced with whatever the hook handler returns
* function handle_view_loaded(?string $namespace, string $view_name, mixed $view, string $content): string
*
*/
const VIEW_LOADED = 'lia:server.view_loaded';
/**
* Called after the list of possible routes is reduced to one route, before the route is processed (before page content is rendered).
*
* You cannot modify the route, but you can throw an exception or `exit`, or check user access.
*
* @param $route the requested url, params, and target on the server
* function handle_routes_filtered(\Lia\Obj\Route $route): void {}
*
* @deprecated string value 'RoutesFiltered' will likely be removed at some point. This const var name will likely remain the same.
*/
const ROUTES_FILTERED = 'RoutesFiltered';
/**
* Called after a route is processed & page content is rendered, before the theme is applied. You can modify the response headers and content.
*
* @param $route the requested url, params, and target on the server
* @param $response HTTP Headers and response content (theme has not been applied yet).
* function handle_route_resolved(\Lia\Obj\Route $route, \Lia\Obj\Response $response): void {}
*/
const ROUTE_RESOLVED = 'RouteResolved';
}