Repository navigation
Internals Controller Controller
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/controller/Controller.php · Snapshot 8411f4287706.
Controllers extend View and receive package context, paths and the dispatcher from their runtime or object factory. Route execution selects an action method.
use context\Context;
use /**
* Interface IController
*
* Defines the contract for controllers within the application.
* Controllers implementing this interface are responsible for
* handling requests and returning appropriate responses.
*/
controller\interfaces\IController;
use /**
* The View class is responsible for rendering templates and managing the output display.
* This class typically handles the dynamic content replacement in templates and
* facilitates the interaction between the controller and the user interface.
*/
view\View;abstract class Controller extends View implements IControllerSource description (behavioral corrections are recorded in Known discrepancies):
Abstract class representing a controller, which implements the IController interface.
This class provides functionality for managing controller-related properties, including the controller name, the root directory path, and shared data. It also defines methods for setting paths necessary for view rendering.
Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.
| Member | Declaration | Purpose or source contract |
|---|---|---|
| $controllerName | public string $controllerName; |
@var string $controllerName The name of the controller. |
| $rootDirPath | public string $rootDirPath; |
@var string $rootDirPath The root directory path for the controller. |
| $context | private ?Context $context = null; |
Used by setContext(), getContext(). |
| $shared | public array $shared = []; |
Declared extension/state field; no own method directly consumes it in this source file. |
| Method | Signature |
|---|---|
| setContext | public function setContext(Context $context): void |
| getContext | public function getContext(): ?Context |
| setRootPath | final public function setRootPath(string $rootDirPath): void |
| setViewPath | final public function setViewPath(string $path): void |
| setName | final public function setName(string $name): void |
public function setContext(Context $context): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$context |
Context $context |
Package context object or package name according to the declared type. |
State writes: $this->context.
Implementation, validation guards and interaction order
public function setContext(Context $context): void
{
$this->context = $context;
}public function getContext(): ?ContextReturn expressions (including local callbacks): $this->context.
Implementation, validation guards and interaction order
public function getContext(): ?Context
{
return $this->context;
}final public function setRootPath(string $rootDirPath): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$rootDirPath |
string $rootDirPath |
The root directory path to set. |
Sets the root directory path for the controller.
This method allows the root directory path to be set, which can be used to locate views or other resources relative to this path.
@param string $rootDirPath The root directory path to set. @return void
State writes: $this->rootDirPath.
Implementation, validation guards and interaction order
/**
* Sets the root directory path for the controller.
*
* This method allows the root directory path to be set, which can be
* used to locate views or other resources relative to this path.
*
* @param string $rootDirPath The root directory path to set.
* @return void
*/
final public function setRootPath(string $rootDirPath): void
{
$this->rootDirPath = $rootDirPath;
}final public function setViewPath(string $path): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$path |
string $path |
The relative path to the view directory. |
Sets the view directory path for the controller.
This method constructs the full path to the view directory by concatenating the root directory path with the provided relative path.
@param string $path The relative path to the view directory. @return void
State writes: $this->viewDirectory.
Implementation, validation guards and interaction order
/**
* Sets the view directory path for the controller.
*
* This method constructs the full path to the view directory by
* concatenating the root directory path with the provided relative
* path.
*
* @param string $path The relative path to the view directory.
* @return void
*/
final public function setViewPath(string $path): void
{
$this->viewDirectory = $this->rootDirPath . $path;
}final public function setName(string $name): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$name |
string $name |
* @return void |
Sets the name for controller. @param string $name @return void
State writes: $this->controllerName.
Implementation, validation guards and interaction order
/**
* Sets the name for controller.
* @param string $name
* @return void
*/
final public function setName(string $name): void
{
$this->controllerName = $name;
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes