(on Monday, 18 May 2009, 04:36 AM -0700):
> Any chance to migrate from 1.7.8 easily to 1.8.x?
> When I try do so I get: Notice: Zend_Loader::Zend_Loader::registerAutoload
> is deprecated as of 1.8.0 and will be removed with 2.0.0; use
> Zend_Loader_Autoloader instead in...
>
> Here is my index:
> require_once "Zend/Loader.php";
> Zend_Loader::registerAutoload('My_Loader');
>
> and here is my Loader:
> class My_Loader extends Zend_Loader
> {
> public static function loadClass($class, $dirs = null)
> {
> parent::loadClass($class, $dirs);
> }
>
> public static function autoload($class)
> {
> try {
> if ('ezcBase' == $class)
> {
> require_once 'eZ/Base/src/base.php';
> }
> elseif ('ezc' == substr($class, 0, 3))
> {
> ezcBase::autoload($class);
> }
> else
> {
> self::loadClass($class);
> }
>
> //self::loadClass($class);
> return $class;
> } catch (Exception $e) {
> return false;
> }
> }
> }
>
> I`m just not sure if I get any next notices like this.
> Thanks for any info.
There's an even better way to do this with Zend_Loader_Autoloader,
actually. :)
I'd suggest the following. First, create the following class:
class My_EzcLoader implements Zend_Loader_Autoloader_Interface
{
public function autoload($class)
{
if ('ezcBase' == $class) {
require_once 'eZ/Base/src/base.php';
} elseif ('ezc' == substr($class, 0, 3)) {
ezcBase::autoload($class);
} else {
return false;
}
return $class;
}
}
Then add it to Zend_Loader_Autoloader:
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');
$autoloader->pushAutoloader(new My_EzcLoader(), 'ezc');
This will trigger _before_ the internal autoloading mechanism, and only
try and match classes beginning with 'ezc'.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论