Re: [Template] Design issues

From: Date: Sat, 12 Jun 2004 14:58:08 +0000
Subject: Re: [Template] Design issues
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30564@lists.php.net to get a copy of this message
On Jun 12, 2004, at 9:51 AM, Philippe Jausions wrote:
Hummm... Why not doing something like that, we avoid an inheritance without losing performance... or may be even better... class Template { <snip> function _output() {
       // Previous output() method
} function output() {
      // Any registered filters?
      if ($this->filters) {
          if (is_a($r = $this->toString(), 'PEAR_Error') {
              return $r;
          }
          foreach ($this->filters ...) {
	      ...
          }
      } else {
        return $this->_output();
      }
} function toString() {
       ob_start();
       if (is_a($r = $this->_output(), 'PEAR_Error')) {
           ob_end_clean();
           return $r;
       }
       if (function_exists('ob_get_clean')) {
           return ob_get_clean();
       } else {
           $data = ob_get_contents();
           ob_end_clean();
           return $data;
       }
} </snip> }
I can live with that very easily. Alan? Two notes: If we stay with PEAR_Error, we'll need a strtolower() on the is_a(). Howeer, I think we ought to move to PEAR_ErrorStack if at all possible. -- Paul M. Jones Savant: the simple alternative to Smarty for PHP. http://phpsavant.com/ DB_Table: build RDBMS tables and XHTML forms in one PHP class. http://wiki.ciaweb.net/yawiki/index.php?area=DB_Table Yawiki: your collaborative online documentation system. http://yawiki.com/ Yawp: a single-file foundation for PHP applications. http://phpyawp.com/

« previous php.pear.dev (#30564) next »