This small patch implements PHP autoloading so you just need to use Zend_* classes into your modules, no need to initialize nor anything.

It will work for any class whose name starts with 'Zend_*' and needs PHP > 5.1.2. About PHP autoload, see http://www.php.net/manual/en/function.spl-autoload-register.php

It also gets rid of the global variable, which I don't see why it's needed, and makes it a static one.

CommentFileSizeAuthor
zend_autoload.patch1.25 KBjose reyero

Comments

robloach’s picture

Status: Active » Needs work

Thanks a lot! I love it.

/**
 * Autoload implementation
 */
function zend_autoload($class) {dsm($class);
  // Just for classes starting with 'Zend'
  if (strpos($class, 'Zend_') === 0) {
    zend_initialize($class);

We probably don't want that dsm in there ;-) . Applies cleanly to HEAD too!

robloach’s picture

Actually, we might want to look into Autoload Drupal module and possibly add it as a dependency.

jose reyero’s picture

The issue with Autoload is that you need to define all classes previously (hook_autoload_info), while in this case we are doing class autoloading using only class name.

This patch is compatible with Autoload, actually I'm using both in the same install.

mfer’s picture

Why not just use the Zend_Loader to do the heavy lifting for Zend?

mfer’s picture

Status: Needs work » Fixed

This is what the 2.x branch and Drupal 7 versions already do.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.