cvs: pear /Template/Template Provider.php
| From: | Alan Knowles | Date: | Mon, 14 Jun 2004 07:16:20 +0000 |
| Subject: | cvs: pear /Template/Template Provider.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-20630@lists.php.net to get a copy of this message | ||
alan_k Mon Jun 14 03:16:20 2004 EDT
Added files:
/pear/Template/Template Provider.php
Log:
add example Provider
http://cvs.php.net/co.php/pear/Template/Template/Provider.php?r=1.1&p=1
Index: pear/Template/Template/Provider.php
+++ pear/Template/Template/Provider.php
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt.
|
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: alan@akkbhome.com |
// +----------------------------------------------------------------------+
//
// $Id: Provider.php,v 1.1 2004/06/14 07:16:20 alan_k Exp $
//
// Example of how a Provider can be written.
//
class Template_Provider
{
/**
* Default options related to this provider.
* Please document these...!!!
*
* @var array
* @access public
*/
var $options = array(
'provider.use_something' => true // an example of an option.
)
/**
* A reference to the instantated template.
*
* @var object Template
* @access public
*/
var $template = null;
/**
* initialize the Provider.
*
* when the provider is created by the template, this method is called, with a
* reference to the template.
*
* Why not use PHP Constructors?
* unfortunatly this would make using a Provider as a Factory base class almost
* impossible (if not a little messy.
*
* Why not use a static Construct method?
* a) this may limit the same pattern in any subclasses.
* b) it gives you the posiblility to extend a base class, that does the same as this.
*
*
* @param object Template The instantated template.
*
* @return none (it may return a PEAR::Error)
* @access public
*/
function initProvider(&$template)
{
// if you need to access template variables (Eg. options/data/providers)
// you should store a reference to the template object.
$this->template = &$template;
// if you add default options, merge your options.
$this->template->options =
array_merge($this->template->options,$this->options);
// if you change any of the default options
// (you may be overriding the user specifed ones.)
$this->template->options['output.no_extract'] = true;
return true;
}
}