Re: [Template] Design issues

From: Date: Sat, 12 Jun 2004 14:51:55 +0000
Subject: Re: [Template] Design issues
References: 1 2 3 4 5 6 7 8 9  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30563@lists.php.net to get a copy of this message
Alan Knowles wrote:
Paul M Jones wrote: output buffering all the time is going to kill performance on large resultsets. I was thinking about filtering last night.. - made a brief reference to it in the email: class Template_Filtered extends Template {
    function Template_Filtered ( $options = array() ) {
        Template::Template($options);
    }
    function output()
    {
        $result =  $this->toString();
        foreach ($this->filters.....)
            $result = $this->filters[$i]->parse($result);
        }
    }
}
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> }

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