Loader
in package

This is the Loader class, a helper to build controllers models and services.

Controllers, models and services should be generated in SITE and FWK using this class as a general rule because it implements the logical mechanism that allows to overwrite the FWK classes in the SITE layer.
So, the Loader tries first to find the class in the SITE layer and instanciate it, and if it does not find it then the Loader instanciates the FWK class.

Tags
see
Loader::service()
see
Loader::viewHelper()
see
Loader::twigFunctions()
see
Loader::twigExtensions()
see
Loader::controller()
see
Loader::EnumInternalRouteType()
see
Loader::getClassFQN()
see
Loader::getInternalController()

Table of Contents

LOCATIONS  = [SITE_NAMESPACE, FWK_NAMESPACE]
controller() This method returns the Controller that corresponds to the given Route.  : Controller
EnumInternalRouteType() This method returns the path of the Enum that corresponds to the given internal route type.  : string
getClassFQN() This method validates the key and returns the concatenation of $namespace, $key and $suffix  : string
getInternalController() This method returns an array containing the internal Controller and the Route of the request.  : array<string|int, mixed>
service() This method returns the service that corresponds to the given service key.  : Service
twigExtensions() This method returns the TwigExtensions that corresponds to the given key.  : TwigExtensions
twigFunctions() This method returns the TwigFunctions that corresponds to the given key.  : TwigFunctions
viewHelper() This method returns the ViewHelper that corresponds to the given viewHelperName and path, and for the given languageSheet and theme.  : ViewHelper

Constants

LOCATIONS

public mixed LOCATIONS = [SITE_NAMESPACE, FWK_NAMESPACE]

Methods

controller()

This method returns the Controller that corresponds to the given Route.

public static controller(Route $route) : Controller

It first searches the Controller in the site and if it does not exist then it is searched in the framework.

Parameters
$route : Route
Tags
throws
CommerceException

if the controller is not found.

Return values
Controller

EnumInternalRouteType()

This method returns the path of the Enum that corresponds to the given internal route type.

public static EnumInternalRouteType(string $type) : string

It first searches the Enum in the site and if it does not exist then it is searched in the framework.

Parameters
$type : string
Tags
throws
CommerceException

if the type specified does not exist.

Return values
string

getClassFQN()

This method validates the key and returns the concatenation of $namespace, $key and $suffix

public static getClassFQN(string $key, string $namespace[, string $suffix = '' ]) : string
Parameters
$key : string
$namespace : string
$suffix : string = ''
Tags
throws
CommerceException

if the key is not valid.

Return values
string

getInternalController()

This method returns an array containing the internal Controller and the Route of the request.

public static getInternalController() : array<string|int, mixed>

It first searches the controller in the site and if it does not exist then it is searched in the framework.

Return values
array<string|int, mixed>

containing Controller and Route

service()

This method returns the service that corresponds to the given service key.

public static service(string $key[, string $namespace = 'Services\' ]) : Service

It first searches the service in the site and if it does not exist then it is searched in the framework.

Parameters
$key : string

of the service.

$namespace : string = 'Services\'

where to find the service.

Tags
throws
CommerceException

if no service class is found for the given service key in the given namespace

Return values
Service

twigExtensions()

This method returns the TwigExtensions that corresponds to the given key.

public static twigExtensions(string $key) : TwigExtensions

It first searches the TwigExtensions in the site and if it does not exist then it is searched in the framework.

Parameters
$key : string
Tags
throws
CommerceException

if a TwigExtensions referenced by the given key does not exist.

Return values
TwigExtensions

twigFunctions()

This method returns the TwigFunctions that corresponds to the given key.

public static twigFunctions(string $key) : TwigFunctions

It first searches the TwigFunctions in the site and if it does not exist then it is searched in the framework.

Parameters
$key : string
Tags
throws
CommerceException

if a TwigFunctions referenced by the given key does not exist.

Return values
TwigFunctions

viewHelper()

This method returns the ViewHelper that corresponds to the given viewHelperName and path, and for the given languageSheet and theme.

public static viewHelper(string $path, string $viewHelperName, Language $languageSheet, Theme $theme, Session|null $session) : ViewHelper

It first searches the ViewHelper in the site and if it does not exist then it is searched in the framework.

Parameters
$path : string

is the path of the ViewHelper

$viewHelperName : string

is the name of the ViewHelper

$languageSheet : Language
$theme : Theme
$session : Session|null
Tags
throws
CommerceException

if no ViewHelper class is found for the given path and viewHelperName.

Return values
ViewHelper

from ViewHelpers path

Search results