BackendController
This is the master controller for all back-end pages.
class Backend\Classes\BackendController
extends Illuminate\Routing\Controller
All requests that are prefixed with the backend URI pattern are sent here, then the next URI segments are analysed and the request is routed to the relevant back-end controller.
For example, a request with the URL /backend/acme/blog/posts
will look
for the Posts
controller inside the Acme.Blog
plugin.
Traits
Trait | Description |
---|---|
ExtendableTrait
|
This extension trait is used when access to the underlying base class is not available, such as classes that belong to the foundation framework (Laravel). It is currently used by the Controller and Model classes. |
Properties
public static $action : string
Allows early access to page action.
public $implement : array
Behaviors implemented by this controller.
public static $params : array
Allows early access to page parameters.
protected
$cmsHandling
:
bool
= false
Flag to indicate that the CMS module is handling the current request
protected $requestedController : Backend\Classes\Controller
Stores the requested controller so that the constructor is only run once
protected
static
$extendableCallbacks
:
array
= []
Used to extend the constructor of an extendable class. Eg:
Class::extend(function($obj) { })
protected
static
$extendableClassLoader
:
ClassLoader
|
null
= null
Class loader instance.
protected
static
$extendableGuardProperties
:
bool
= true
Indicates if dynamic properties can be created.
protected
static
$extendableStaticMethods
:
array
= []
Collection of static methods used by behaviors.
protected
$extensionData
:
array
= {"extensions":[],"methods":[],"dynamicMethods":[],"dynamicProperties":[]}
Class reflection information, including behaviors.
Methods
public __call ($name, $params)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$params | mixed |
mixed
|
public static __callStatic ($name, $params)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$params | mixed |
mixed
|
public __construct ()
Instantiate a new BackendController instance.
public callAction ($method, $parameters)
Property | Type | Description |
---|---|---|
$method | mixed |
mixed
|
$parameters | mixed |
mixed
|
public
run (string $url = null
)
: string
Finds and serves the requested backend controller.
If the controller cannot be found, returns the Cms page with the URL /404. If the /404 page doesn't exist, returns the system 404 page.
Property | Type | Description |
---|---|---|
$url | string |
string
Specifies the requested page URL. If the parameter is omitted, the current URL used. |
Returns the processed page content.
protected findController (string $controller, string $action, string $inPath) : ControllerBase
This method is used internally.
Finds a backend controller with a callable action method.
Property | Type | Description |
---|---|---|
$controller | string |
string
Specifies a method name to execute. |
$action | string |
string
Specifies a method name to execute. |
$inPath | string |
string
Base path for class file location. |
Returns the backend controller object
protected getRequestedController (string $url) : array | null
Determines the controller and action to load in the backend via a provided URL.
If a suitable controller is found, this will return an array with the controller class name as a string, the action to call as a string and an array of parameters. If a suitable controller and action cannot be found, this method will return null.
Property | Type | Description |
---|---|---|
$url | string |
string
A URL to determine the requested controller and action for |
A suitable controller, action and parameters in an array if found, otherwise null.
protected static methodExcludedByOptions (string $method, array $options) : bool
Determine if the given options exclude a particular method.
Property | Type | Description |
---|---|---|
$method | string |
string
|
$options | array |
array
|
protected parseAction (string $actionName) : string
Process the action name, since dashes are not supported in PHP methods.
Property | Type | Description |
---|---|---|
$actionName | string |
string
|
protected passToCmsController (string $url) : Response
Pass unhandled URLs to the CMS Controller, if it exists
Property | Type | Description |
---|---|---|
$url | string |
string
|
public
addDynamicMethod (string $dynamicName, callable $method, string $extension = null
)
Programmatically adds a method to the extendable class
Property | Type | Description |
---|---|---|
$dynamicName | string |
string
|
$method | callable |
callable
|
$extension | string |
string
|
public
addDynamicProperty (string $dynamicName, mixed $value = null
)
: void
Programmatically adds a property to the extendable class
Property | Type | Description |
---|---|---|
$dynamicName | string |
string
The name of the property to add |
$value | mixed |
mixed
The value of the property |
public asExtension (string $shortName) : mixed
Short hand for getClassExtension()
method, except takes the short
extension name, example:
$this->asExtension('FormController')
Property | Type | Description |
---|---|---|
$shortName | string |
string
|
public static clearExtendedClasses () : void
Clear the list of extended classes so they will be re-extended.
public extendClassWith (string $extensionName) : void
Dynamically extend a class with a specified behavior
Property | Type | Description |
---|---|---|
$extensionName | string |
string
|
public
extendableCall (string $name, array $params = null
)
: mixed
Magic method for __call()
.
Callback priority is as follows:
- "Dynamic Methods" added locally to the object via addDynamicMethod($name, $callable)
- Methods available on Behaviors that have been implemented by the object
- Pass it to the parent's __call() method if it defines one
Property | Type | Description |
---|---|---|
$name | string |
string
|
$params | array |
array
|
public
static
extendableCallStatic (string $name, array $params = null
)
: mixed
Magic method for __callStatic()
Property | Type | Description |
---|---|---|
$name | string |
string
|
$params | array |
array
|
public extendableConstruct ()
This method should be called as part of the constructor.
public
static
extendableExtendCallback (callable $callback, boolean $scoped = false
, $outerScope = null
)
: void
Helper method for ::extend()
static method.
Property | Type | Description |
---|---|---|
$callback | callable |
callable
|
$scoped | boolean |
boolean
|
$outerScope | mixed |
mixed
|
public extendableGet (string $name) : mixed | null
Magic method for __get()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public extendableSet (string $name, mixed $value) : void
Magic method for __set()
Property | Type | Description |
---|---|---|
$name | string |
string
|
$value | mixed |
mixed
|
public getClassExtension (string $name) : mixed
Returns a behavior object from an extendable class, example:
$this->getClassExtension('Backend.Behaviors.FormController')
Property | Type | Description |
---|---|---|
$name | string |
string
Fully qualified behavior name |
public getClassMethods () : array
Get a list of class methods, extension equivalent of get_class_methods()
public getDynamicProperties () : array
Returns all dynamic properties and their values
['property' => 'value']
public isClassExtendedWith (string $name) : bool
Check if extendable class is extended with a behavior object
Property | Type | Description |
---|---|---|
$name | string |
string
Fully qualified behavior name |
public methodExists (string $name) : bool
Checks if a method exists, extension equivalent of method_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public propertyExists (string $name) : bool
Checks if a property exists, extension equivalent of property_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
protected extendableIsAccessible (mixed $class, string $propertyName) : bool
Checks if a property is accessible, property equivalent of is_callable()
Property | Type | Description |
---|---|---|
$class | mixed |
mixed
|
$propertyName | string |
string
|
protected extensionExtractMethods (string $extensionName, object $extensionObject) : void
Extracts the available methods from a behavior and adds it to the list of callable methods.
Property | Type | Description |
---|---|---|
$extensionName | string |
string
|
$extensionObject | object |
object
|
protected extensionGetClassLoader () : Winter\Storm\Support\ClassLoader | null
Gets the class loader
protected extensionNormalizeClassName (string $name) : string
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
Property | Type | Description |
---|---|---|
$name | string |
string
|