Skip to content

Instantly share code, notes, and snippets.

@code-poel
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save code-poel/9608459 to your computer and use it in GitHub Desktop.

Select an option

Save code-poel/9608459 to your computer and use it in GitHub Desktop.
Magento Autoload
<?php
static public function register()
{
spl_autoload_register(array(self::instance(), 'autoload'));
}
/**
* Load class source code
*
* @param string $class
*/
public function autoload($class)
{
if ($this->_collectClasses) {
$this->_arrLoadedClasses[self::$_scope][] = $class;
}
if ($this->_isIncludePathDefined) {
$classFile = COMPILER_INCLUDE_PATH . DIRECTORY_SEPARATOR . $class;
} else {
$classFile = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $class)));
}
$classFile.= '.php';
//echo $classFile;die();
return include $classFile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment