2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
4 // Copyright (c) 2003 Laurent Bedubourg
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // Authors: Laurent Bedubourg <laurent.bedubourg@free.fr>
24 * Interface to PHPTAL cache system.
26 * Implement this interface and use PHPTAL_Template::setCacheManager() method
27 * to intercept macro and template execution with your own cache system.
29 * The aim of this system is to fine grain the caching of PHPTAL results
30 * allowing the php coder to use whatever cache system he prefers with a
31 * good granularity as he can cache result of specific templates execution,
32 * and specific macros calls.
34 * @see Documentation.txt
35 * @author Laurent Bedubourg <laurent.bedubourg@free.fr>
40 * Called each time a template has to be executed.
42 * This method must return the cache value or the template execution
45 * function template(&$tpl, $path, &$context)
47 * // return cache if exists
48 * // else realy process template
49 * $res = $tpl->_process();
50 * // cache the result if needed
55 * @param PHPTAL_Template -- the template that must be cached/executed
56 * @param string $path -- the template path
57 * @param PHPTAL_Context $ctx -- the execution context
61 function template(&$tpl, $path, &$context)
63 return $tpl->_process();
68 * Called each time a macro needs to be executed.
70 * This method allow cache on macro result. It must return the cache value
71 * or at least the macro execution result.
73 * function macro(&$macro, $file, $name, &$context)
75 * // return cache if exists
76 * // else really process macro
77 * $res = $macro->_process();
78 * // cache the result if needed
84 * @param PHPTAL_Macro -- the macro to executed
85 * @param string $file -- the macro source file
86 * @param string $name -- the macro name
87 * @param PHPTAL_Context $context -- the current execution context
91 function macro(&$macro, $file, $name, &$context)
93 return $macro->_process();