@absolunet/ioc2.1.0

View on GitHub

ControllerRepository

Controller repository where controller registration and instantiation are done.

Members

(static) dependencies :Array.<string>

Source:
Class dependencies: ['app'].

actionPattern :RegExp

Source:
Action pattern for qualified action.

namespaceSeparator :string

Source:
Controller namespace separator.

coreNamespace :string

Source:
The namespace for core controllers.

Methods

add(name, controller)

Source:
Add a controller binding.
Parameters:
Name Type Description
name string The controller name.
controller http.controllers.Controller The controller class.
Returns:
The current controller repository instance.
Type
http.repositories.ControllerRepository

get(name)

Source:
Get the controller instance by name. If it was not registered into the repository, it will attempt to find it in the application folder.
Parameters:
Name Type Description
name string The controller name.
Returns:
The controller instance.
Type
http.controllers.Controller

has(name)

Source:
Check if the given controller was registered.
Parameters:
Name Type Description
name string The controller name.
Returns:
Indicates that the controller name was already registered into the repository.
Type
boolean

group(name, group)

Source:
Group controllers inside a given namespace.
Parameters:
Name Type Description
name string The group namespace.
group function The controller group closure.
Returns:
The current controller repository instance.
Type
http.repositories.ControllerRepository

getFromPath(controllerPath, name)

Source:
Make controller instance from base path and controller name. Mainly relies on path structure and file name.
Parameters:
Name Type Description
controllerPath string The controller file path.
name string The controller name.
Returns:
The resolved controller instance.
Type
http.controllers.Controller

buildName(name)

Source:
Resolve the name based on current groups and given name.
Parameters:
Name Type Description
name string The base name.
Returns:
The resolved, fully qualified, name.
Type
string

getName(name, withActionopt)

Source:
Get the name that is used for container binding.
Parameters:
Name Type Attributes Default Description
name string The controller name.
withAction boolean <optional>
false Indicates that the returned value should contain the action.
Returns:
The controller name into toe container.
Type
string

resolveName(name)

Source:
Get controller name without container prefix or action.
Parameters:
Name Type Description
name string The controller action.
Returns:
The controller name without the action method.
Type
string

resolveAction(name)

Source:
Get the action from the given qualified controller name.
Example
this.resolveAction('PostController@show'); // 'show'
Parameters:
Name Type Description
name string The controller action.
Returns:
The controller method name, without the controller name.
Type
string