Controller
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
Helper method for ::extend() static method
Clear the list of extended classes so they will be re-extended.
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
Dynamically extend a class with a specified behavior
Extracts the available methods from a behavior and adds it to the list of callable methods.
Programmatically adds a method to the extendable class
Programatically adds a property to the extendable class
Check if extendable class is extended with a behavior object
Returns a behavior object from an extendable class, example:
Short hand for getClassExtension() method, except takes the short extension name, example:
Checks if a method exists, extension equivalent of method_exists()
Get a list of class methods, extension equivalent of get_class_methods()
Checks if a property exists, extension equivalent of property_exists()
Checks if a property is accessible, property equivalent of is_callabe()
Magic method for __call()
Magic method for __callStatic()
No description
Get the middleware assigned to the controller.
Finds and serves the request using the main controller.
Finds and serves the request using the admin controller.
Combines JavaScript and StyleSheet assets.
No description
This method is used internally.
Process the action name, since dashes are not supported in PHP methods.
No description
No description
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
in
ExtendableTrait at line 120
static void
clearExtendedClasses()
Clear the list of extended classes so they will be re-extended.
in
ExtendableTrait at line 131
protected string
extensionNormalizeClassName(string $name)
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
in
ExtendableTrait at line 149
void|ExtendableTrait
extendClassWith(string $extensionName)
Dynamically extend a class with a specified behavior
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.
in
ExtendableTrait at line 206
addDynamicMethod(string $dynamicName, callable $method, string $extension = null)
Programmatically adds a method to the extendable class
in
ExtendableTrait at line 225
addDynamicProperty(string $dynamicName, string $value = null)
Programatically adds a property to the extendable class
in
ExtendableTrait at line 249
bool
isClassExtendedWith(string $name)
Check if extendable class is extended with a behavior object
in
ExtendableTrait at line 265
mixed
getClassExtension(string $name)
Returns a behavior object from an extendable class, example:
$this->getClassExtension('Admin.Actions.FormController')
in
ExtendableTrait at line 280
mixed
asExtension(string $shortName)
Short hand for getClassExtension() method, except takes the short extension name, example:
$this->asExtension('FormController')
in
ExtendableTrait at line 301
bool
methodExists(string $name)
Checks if a method exists, extension equivalent of method_exists()
in
ExtendableTrait at line 313
array
getClassMethods()
Get a list of class methods, extension equivalent of get_class_methods()
in
ExtendableTrait at line 326
array
getDynamicProperties()
Returns all dynamic properties and their values
in
ExtendableTrait at line 344
bool
propertyExists(string $name)
Checks if a property exists, extension equivalent of property_exists()
in
ExtendableTrait at line 370
protected bool
extendableIsAccessible(mixed $class, string $propertyName)
Checks if a property is accessible, property equivalent of is_callabe()
in
ExtendableTrait at line 385
string
extendableGet(string $name)
Magic method for __get()
in
ExtendableTrait at line 410
string
extendableSet(string $name, string $value)
Magic method for __set()
in
ExtendableTrait at line 444
mixed
extendableCall(string $name, array $params = null)
Magic method for __call()
in
ExtendableTrait at line 483
static mixed
extendableCallStatic(string $name, array $params = null)
Magic method for __callStatic()
in
ExtendableTrait at line 552
protected ClassLoader|null
extensionGetClassLoader()
Gets the class loader
at line 57
__construct()
No description
at line 67
array
getMiddleware()
Get the middleware assigned to the controller.
at line 79
static
extend(Closure $callback)
Extend this object properties upon construction.
at line 91
string
run(string $url = '/')
Finds and serves the request using the main controller.
at line 108
string
runAdmin(string $url = '/')
Finds and serves the request using the admin controller.
at line 128
string
combineAssets(string $asset)
Combines JavaScript and StyleSheet assets.
at line 143
protected
locateController($url)
No description
at line 170
protected bool|AdminController|MainController
locateControllerInPath(string $controller, string|array $modules, string|array $inPath)
This method is used internally.
Finds a controller with a callable action method.
at line 207
protected string
processAction(string $actionName)
Process the action name, since dashes are not supported in PHP methods.
at line 216
protected
locateControllerInApp(array $segments)
No description
at line 235
protected
locateControllerInExtensions($segments)
No description
at line 260
protected
pushRequestedControllerMiddleware()
No description