プロジェクト

全般

プロフィール

Bug(バグ) #1609 » opTestLoader.class.php

Hidenori Goto, 2010-09-24 19:48

 
<?php
class opTestLoader
{
/**
* Autoload classes.
* This method replaces Zend_Loader::registerAutoload() because it's been deprecated from zf 1.8.0
* and will be removed from 2.0.0.
*
* @param string $class
* @param mixed $enabled
* @return
*/
public static function registerAutoload($class = 'Zend_Loader', $enabled = true)
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);

if ('Zend_Loader' != $class)
{
Zend_Loader::loadClass($class);
$methods = get_class_methods($class);
if (!in_array('autoload', (array) $methods))
{
require_once 'Zend/Exception.php';
throw new Zend_Exception("The class \"$class\" does not have an autoload() method");
}

$callback = array($class, 'autoload');

if ($enabled)
{
$autoloader->pushAutoloader($callback);
} else
{
$autoloader->removeAutoloader($callback);
}
}
else
{
Zend_Loader_Autoloader::resetInstance();
}
}
}
    (1-1/1)