Issue with Access to Private Static Method
Posted: Fri Apr 09, 2010 8:19 am
I'm working on a simple Template class (Mucklate) and I'm having a visibility problem with one of the methods. How can I allow the anonymous callback function for ob_start to access the parseTemplate method if I make the parseTemplate private static? I would rather it be invisible outside the class. Any other way I can achieve this?
(This isn't the whole class, and it's still in progress, so if it looks odd, that's why.)
(This isn't the whole class, and it's still in progress, so if it looks odd, that's why.)
Code: Select all
public function __construct($templatePath, $stripWhitespace = false){
if($templatePath && file_exists($templatePath)){
ob_start(function($buffer){ return Mucklate::parseTemplate($buffer); });
include($templatePath);
}
}
public static function parseTemplate($buffer){
foreach(Mucklate::$varSet as $var){
$buffer = str_replace(Mucklate::$delimiter . $var["var"] . strrev(Mucklate::$delimiter), $var["value"], $buffer);
}
return $buffer;
}