The following method below works perfectly if $output is a string. Although in a rare case $output can be passed as an array.
How can I check if $output is an array and to only get the last part of the array.
/**
* Output writer.
*
* @param string $output
* @param Controller $oController
* @throws Output_Exception
*/
public static function factory($output,Controller $oController) {
$outtype = ucfirst(strtolower(str_replace(".","_",$output)));
$classname = __CLASS__ . "_" . $outtype;
try {
Zend_Loader::loadClass($classname);
$oOutputter = new $classname($oController);
if(! $oOutputter instanceof Output_Abstract )
throw new Output_Exception("class $classname is not an instance of Output_Abstract");
} catch (Zend_Exception $e) {
throw $e;
}
return $oOutputter;
}
Errors:
Warning: strtolower() expects parameter 1 to be string, array given in C:\wamp\www\cms\webapp\library\Output.php on line 16
Warning: include_once(Output.php) [function.include-once]: failed to open stream: No such file or directory in C:\wamp\php\includes\Zend\Loader.php on line 146
var_dump($output)
array(2) { [0]=> string(6) "xml" [1]=> string(6) "smarty" }