- Table of Contents
7. API Reference - 6.3. Smarty™
« Previous - 7.1. Opt_Class class
Next »
7. API Reference
Table of Contents
- 7.1. Opt_Class class
- 7.2. Opt_View class
- 7.3. Opt_Output_Http class
- 7.4. Opt_Output_Return class
- 7.5. Opt_Compiler_Class class
- 7.6. Opt_Compiler_Format class
- 7.7. Opt_Compiler_Processor class
- 7.8. Opt_Xml_Attribute class
- 7.9. Opt_Xml_Buffer class
- 7.10. Opt_Xml_Cdata class
- 7.11. Opt_Xml_Comment class
- 7.12. Opt_Xml_Dtd class
- 7.13. Opt_Xml_Element class
- 7.14. Opt_Xml_Expression class
- 7.15. Opt_Xml_Node class
- 7.16. Opt_Xml_Prolog class
- 7.17. Opt_Xml_Root class
- 7.18. Opt_Xml_Scannable class
- 7.19. Opt_Xml_Text class
- 7.20. Opt_Block_Interface
- 7.21. Opt_Caching_Interface
- 7.22. Opt_Component_Interface
- 7.23. Opt_Generator_Interface
- 7.24. Opt_Output_Interface class
In this chapter we would like to present the Open Power Template API reference. The methods available for the end-user can be found in the Opt_Class, Opt_View, Opt_Output_Http and Opt_Output_Return classes. The rest describes the compiler interface that allows to extend OPT with the new features.
How to use the code?
Open Power Template is a part of Open Power Libs and it requires the core OPL package in order to work. It is provided together with the library. Once you copied the library to the project directory structure, you will find OPT in /path/to/libs/Opt and OPL in /path/to/libs/Opl. Firstly, you have to load the /Opl/Base.php file manually and to initialize the autoloader. Then, you create the object of Opt_Class and configure it.
<?php // Load the basic code require('./lib/Opl/Base.php'); // Set the OPL files path Opl_Base::setDirectory('./lib/'); // Initialize the autoloader spl_autoload_register(array('Opl_Loader', 'autoload')); // Create the main OPT object $tpl = new Opt_Class; ?>
Alternatively, you may use the PHAR archives that do some of the basic configuration on their own:
<?php require('./libs/opl.phar'); require('./libs/opt.phar'); $tpl = new Opt_Class; ?>
The detailed information can be found in the OPL core manual.
Conventions
In Open Power Template, there are some conventions concerning the code and naming style:
- All the protected and private class elements have names that begin with an underscore:
_name(). - The methods that should return a particular data, return NULL, if it has not been found or the task has not been completed. Note that this is a bit different, contrary to the PHP standard library where false values are preferred. However, note that sometimes false is a valid value, and in our case, it is always interpreted correctly.
- The exceptions are used to report errors.
Code reference issues
In the manual, we make use of several status and type names. Below, you can find their descriptions.
Status
- abstract
- An abstract method, you have to extend it in the child class.
- final
- The method cannot be extended.
- extendable
- The method should be extended, but it is not necessary.
- public
- Public element
- protected
- Protected element
- private
- Private element
- static
- Static element
Types
- string
- Any valid string
- int
- An integer
- array
- A PHP array
- bool
- A logical value (true or false)
- mixed
- More than one valid type. The documentation specified the available types in the description.
- void
- This pseudo-type informs that the method does not return a value.
Moreover, the class/interface names are also used as types.
- 7. API Reference
Table of Contents - « Previous
6.3. Smarty™ - Next »
7.1. Opt_Class class