Documentation
Attributes
Table of Contents ▼
Presentation
Temma offers optional PHP attributes to control access to controllers and actions.
These attributes can be added together, so you can add several different attributes (and sometimes the same attribute several times, with different parameters) to the same controller or action.
More, you can create your own attributes to manage access to controllers and actions.
Attributes provided by Temma
Temma provides several attributes, which documentation is available in the "Helpers" sections:
write your own attributes
You can create your own attributes to manage access to controllers and actions.
Inheritance
Your attributes must derive from the \Temma\Web\Attribute object, which offers several features relatively similar to those of controllers:
-
Access to template variables via the hooked notion.
For example: $this['var'] = 'value'; to define a variable, and $var = $this['var']; to read the value of a variable. -
Access to data sources in the form of direct object properties.
For example: $this->db to access a database named db. -
Methods $this->_httpCode() and $this->_httpError()
to define the HTTP return code, or HTTP error code.
Methods $this->_getHttpCode() and $this->_getHttpError() to retrieve the HTTP code previously defined. - Methods $this->_redirect() and $this->_redirect301() to define redirection commands.
- Methods $this->_view() to define the view, $this->_template() to define the template, and $this->_templatePrefix() to define the template prefix.
Execution flow
To modify the flow of execution, an attribute must raise a specific exception:
- \Temma\Exceptions\FlowHalt: Stops the flow of execution. No other plugins or controllers will be executed, and the framework moves straight on to processing the view or redirection.
- \Temma\Exceptions\FlowRestart: Restarts processing of the current phase (pre-plugins, controller or post-plugins).
- \Temma\Exceptions\FlowReboot: Restarts the entire processing chain (pre-plugins + controller + post-plugins).
- \Temma\ExceptionsFlowQuit: Stops execution of the framework. No further plugins or controllers will be executed. The view will not be executed and redirection requests are ignored.
Previous: | Plugins |
Next: | Command-line interface |
Table of Contents
- Migration : How to upgrade from Temma 1.x to version 2
- Installation : Download Temma and install it to start your web project
- Configuration : All the configuration directives of the etc/temma.json file and the optional environment variables
- External libraries : How to use external function libraries
- Routing : Temma's default routing system, and advanced routing
- Log : Use of the log system, management by criticality levels
- Controllers : Essential parts of your web application
- Views : Smarty templates or JSON/CSV/RSS/iCal/INI exports
- Dependency injection : The backbone of your application developments
- Sessions : Extension of user sessions managed by PHP
- Data sources : Unified data access management
- Model : How to use DAOs to access databases
- Execution flow : How to manage the execution flow, between plugins and the controller
- Plugins : How to use plugins, and create your own plugins to modularize your code
- Attributes : How to filter access to controllers and actions
- Tests : To write automated integration tests.
- Command-line interface : To create executable scripts on the command line, automatically initialized by Temma
- Helpers : Items offered by Temma to help you in various circumstances