Migration to 3.3
Version 3.3 is a major Tequila revision, many structural changes have been done and new functionalities added, your old code will need to be changed to work with version 3.3, list of required changes:
PLEASE BE EXTREMELY CAREFUL WHEN APPLYING THIS CHANGES, SPECIALLY IF YOU DO PROJECT WIDE REPLACEMENTS,
BEFORE STARTING:
- CREATE A BACKUP
- OR COMMIT YOUR LATEST VERSION TO THE REPOSITORY
- TRIPLE CHECK YOUR REPLACEMENT STRINGS!!
includes/config.php
Change to match new variable names and new regions
Multiple database support.
DB config is now an array (Change in config.php)
task_wrapper class removed.
All properties have been integrated into the controller or the task passed to the controller, make a search for task_wrapper and replace elements for the new ones, a list of possible ones.
Search your project for
taskWrapper
cache.inc.php moved to /temp
All runtime generated files are now stored in /temp folder, please set write permissions for this folder
REST support
Tequila now support REST this is a combination of pretty URL's, application state and proper headers setting, Tequila support simultaneous execution of REST and not REST calls. This means that URL's are now written by the view and are not part of the template.
Your old template files will keep working but will not support REST, you can see the supported templates by generating a sample file.
Model, controller naming.
A major naming change, as normally the model classes are named after real objects we consider that the suffix _model is unnecessary, for old application you will need to:
app/controllers. Add _controllers to all filenames and class names i.e.
products ----become----> products_controller.php
app/models. Remove _model i.e.
products_model ----become----> products.php
* This change has been canceled to avoid confusions.
New folder helpers
catalogs and appmenu have been moved from model to helpers
Default list template changed
The footer of the alternate table view now is a block, this block is called from view_alternate_table strategy, you can either:
1) Use the old view_alternate_table class
2) Add the block markers around the t_foot element of the list
In Block : List :
<!-- START BLOCK : listcontrolbox -->
Request and response
Apply to: Controllers
All request collections are now encapsulated in the request / response objects
This has BIG implications! Currently the preferred methods to access the post/get/cookies section is trough the safePost/safeGet/safeRequest/safeCookies methods, all this methods have also been moved to the object,
You can fix this issue by replacing all method calls like:
safePost('key'); ==== becomes ===> $this->request->safePost('key');
$_POST['key'] ==== becomes ===> $this->request->post('key');
isset($_POST['key']) ==== becomes ===> $this->request->is_set('post','key');
** Please notice that isset($this->request->post('key')) Will cause an error
U can replace this running a project replace in Netbeans or Dreamweaver (or a similar editor that supports operation on files)
Regex:
Replace:
([= (])safe(Post|Get|Request)
With:
$1\$this->request->safe$2
MVC Class removed
MVC class is now called frontController, it's responsibilities has been better defined (limited), the new execution path is:
index.php -> Tequila.php -> frontController
Tequila.php : Now contains more code to make execution and different instance customization easier
Multiple calls support is removed
In version 3.0 All method calls were mixed, in 3.2 we split REST calls from non rest calls, but allow still to make calls loading from xml or db together with default calls (convention). Now Tequila allow you and force you to define the proxy that you want to use to parse the request.
application_controller Task Result object is removed
application_controller->tr Is used to return task result, status and content to the processing filter, this class has been removed, you should use the response object instead.
Application_controller variable $mode renamed and scope changed
Apply to: Controllers
var exist still to hold the current mode, but the default mode is moved to a static variable $defaultmode.
This change is made so external classes can get the default code for non-determined calls and check the security of the task without creating it.
This change will cause your code to stop working!
You can fix using this replace rules:
Replace:
protected \$mode\s*=\s*['"](\w+)['"];
With:
public static \$defaultmode = '$1';
Be sure you are using regex
Function in controller receive $model and $view vars optionally
Apply to: Controllers
This is an optional change, perhaps in the future we stop passing this vars to simplify the creation of new functions, you can remove the existing calls using this regex:
Netbeans: Edit > Replace in Projects
Replace:
function\s*(\w+)\s*\(&\$model\s*,\s*&\$view\s*\)
With:
function $1()
And the the internal function references like:
Replace:
\$(model|view)->
With:
\$this->$1->