class Controller extends Controller

This is the base controller for all pages.

All requests that are prefixed with the admin URI pattern OR have not been handled by the router are sent here, then the URL is passed to the app controller for processing. For example, Request URI Find Controller In /admin/(any) admin, location or system app directory /admin/acme/cod/(any) Acme.Cod extension /(any) main app directory

Traits

Extendable Trait Allows for "Private traits"

Properties

protected array $extensionData from  ExtendableTrait
static protected array $extendableCallbacks from  ExtendableTrait
static protected array $extendableStaticMethods from  ExtendableTrait
static protected bool $extendableGuardProperties from  ExtendableTrait
static protected ClassLoader $extendableClassLoader from  ExtendableTrait
array $implement
static $class
static string $action
static array $segments
protected array|null $requestedCache

Stores the requested controller so that the constructor is only run once

Methods

extendableConstruct()

Constructor.

static void
extendableExtendCallback(callable $callback)

Helper method for ::extend() static method

static void
clearExtendedClasses()

Clear the list of extended classes so they will be re-extended.

string
extensionNormalizeClassName(string $name)

Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes

extendClassWith(string $extensionName)

Dynamically extend a class with a specified behavior

void
extensionExtractMethods(string $extensionName, object $extensionObject)

Extracts the available methods from a behavior and adds it to the list of callable methods.

addDynamicMethod(string $dynamicName, callable $method, string $extension = null)

Programmatically adds a method to the extendable class

addDynamicProperty(string $dynamicName, string $value = null)

Programatically adds a property to the extendable class

bool
isClassExtendedWith(string $name)

Check if extendable class is extended with a behavior object

mixed
getClassExtension(string $name)

Returns a behavior object from an extendable class, example:

mixed
asExtension(string $shortName)

Short hand for getClassExtension() method, except takes the short extension name, example:

bool
methodExists(string $name)

Checks if a method exists, extension equivalent of method_exists()

array
getClassMethods()

Get a list of class methods, extension equivalent of get_class_methods()

array
getDynamicProperties()

Returns all dynamic properties and their values

bool
propertyExists(string $name)

Checks if a property exists, extension equivalent of property_exists()

bool
extendableIsAccessible(mixed $class, string $propertyName)

Checks if a property is accessible, property equivalent of is_callabe()

string
extendableGet(string $name)

Magic method for __get()

string
extendableSet(string $name, string $value)

Magic method for __set()

mixed
extendableCall(string $name, array $params = null)

Magic method for __call()

static mixed
extendableCallStatic(string $name, array $params = null)

Magic method for __callStatic()

ClassLoader|null
extensionGetClassLoader()

Gets the class loader

__construct()

No description

array
getMiddleware()

Get the middleware assigned to the controller.

static 
extend(Closure $callback)

Extend this object properties upon construction.

string
run(string $url = '/')

Finds and serves the request using the main controller.

string
runAdmin(string $url = '/')

Finds and serves the request using the admin controller.

string
combineAssets(string $asset)

Combines JavaScript and StyleSheet assets.

locateController($url)

No description

locateControllerInPath(string $controller, string|array $modules, string $inPath)

This method is used internally.

string
processAction(string $actionName)

Process the action name, since dashes are not supported in PHP methods.

locateControllerInApp(array $segments)

No description

locateControllerInExtensions($segments)

No description

Details

in ExtendableTrait at line 55
extendableConstruct()

Constructor.

in ExtendableTrait at line 103
static void extendableExtendCallback(callable $callback)

Helper method for ::extend() static method

Parameters

callable $callback

Return Value

void

in ExtendableTrait at line 120
static void clearExtendedClasses()

Clear the list of extended classes so they will be re-extended.

Return Value

void

in ExtendableTrait at line 131
protected string extensionNormalizeClassName(string $name)

Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes

Parameters

string $name

Return Value

string

in ExtendableTrait at line 149
void|ExtendableTrait extendClassWith(string $extensionName)

Dynamically extend a class with a specified behavior

Parameters

string $extensionName

Return Value

void|ExtendableTrait

Exceptions

Exception

in ExtendableTrait at line 178
protected void extensionExtractMethods(string $extensionName, object $extensionObject)

Extracts the available methods from a behavior and adds it to the list of callable methods.

Parameters

string $extensionName
object $extensionObject

Return Value

void

in ExtendableTrait at line 206
addDynamicMethod(string $dynamicName, callable $method, string $extension = null)

Programmatically adds a method to the extendable class

Parameters

string $dynamicName
callable $method
string $extension

in ExtendableTrait at line 225
addDynamicProperty(string $dynamicName, string $value = null)

Programatically adds a property to the extendable class

Parameters

string $dynamicName
string $value

in ExtendableTrait at line 249
bool isClassExtendedWith(string $name)

Check if extendable class is extended with a behavior object

Parameters

string $name

Fully qualified behavior name

Return Value

bool

in ExtendableTrait at line 265
mixed getClassExtension(string $name)

Returns a behavior object from an extendable class, example:

$this->getClassExtension('Admin.Actions.FormController')

Parameters

string $name

Fully qualified behavior name

Return Value

mixed

in ExtendableTrait at line 280
mixed asExtension(string $shortName)

Short hand for getClassExtension() method, except takes the short extension name, example:

$this->asExtension('FormController')

Parameters

string $shortName

Return Value

mixed

in ExtendableTrait at line 301
bool methodExists(string $name)

Checks if a method exists, extension equivalent of method_exists()

Parameters

string $name

Return Value

bool

in ExtendableTrait at line 313
array getClassMethods()

Get a list of class methods, extension equivalent of get_class_methods()

Return Value

array

in ExtendableTrait at line 326
array getDynamicProperties()

Returns all dynamic properties and their values

Return Value

array

['property' => 'value']

in ExtendableTrait at line 344
bool propertyExists(string $name)

Checks if a property exists, extension equivalent of property_exists()

Parameters

string $name

Return Value

bool

in ExtendableTrait at line 370
protected bool extendableIsAccessible(mixed $class, string $propertyName)

Checks if a property is accessible, property equivalent of is_callabe()

Parameters

mixed $class
string $propertyName

Return Value

bool

in ExtendableTrait at line 385
string extendableGet(string $name)

Magic method for __get()

Parameters

string $name

Return Value

string

in ExtendableTrait at line 410
string extendableSet(string $name, string $value)

Magic method for __set()

Parameters

string $name
string $value

Return Value

string

in ExtendableTrait at line 444
mixed extendableCall(string $name, array $params = null)

Magic method for __call()

Parameters

string $name
array $params

Return Value

mixed

in ExtendableTrait at line 483
static mixed extendableCallStatic(string $name, array $params = null)

Magic method for __callStatic()

Parameters

string $name
array $params

Return Value

mixed

in ExtendableTrait at line 552
protected ClassLoader|null extensionGetClassLoader()

Gets the class loader

Return Value

ClassLoader|null

at line 57
__construct()

No description

at line 67
array getMiddleware()

Get the middleware assigned to the controller.

Return Value

array

at line 79
static extend(Closure $callback)

Extend this object properties upon construction.

Parameters

Closure $callback

at line 91
string run(string $url = '/')

Finds and serves the request using the main controller.

Parameters

string $url

Specifies the requested page URL.

Return Value

string

Returns the processed page content.

at line 108
string runAdmin(string $url = '/')

Finds and serves the request using the admin controller.

Parameters

string $url

Specifies the requested page URL. If the parameter is omitted, the dashboard URL used.

Return Value

string

Returns the processed page content.

at line 130
string combineAssets(string $asset)

Combines JavaScript and StyleSheet assets.

Parameters

string $asset

Return Value

string

at line 145
protected locateController($url)

No description

Parameters

$url

at line 172
protected bool|AdminController|MainController locateControllerInPath(string $controller, string|array $modules, string $inPath)

This method is used internally.

Finds a controller with a callable action method.

Parameters

string $controller

Specifies a controller name to locate.

string|array $modules

Specifies a list of modules to look in.

string $inPath

Base path to search the class file.

Return Value

bool|AdminController|MainController

Returns the backend controller object

at line 204
protected string processAction(string $actionName)

Process the action name, since dashes are not supported in PHP methods.

Parameters

string $actionName

Return Value

string

at line 213
protected locateControllerInApp(array $segments)

No description

Parameters

array $segments

at line 232
protected locateControllerInExtensions($segments)

No description

Parameters

$segments

at line 257
protected pushRequestedControllerMiddleware()

No description