Exemple #1
0
 public static function boot()
 {
     // force include Base.php file (compatibility and specific functions)
     require_once SJB_BASE_DIR . 'system/core/Base.php';
     require_once SJB_BASE_DIR . 'system/ext/Zend/Loader/ClassMapAutoloader.php';
     $loader = new Zend_Loader_ClassMapAutoloader();
     $loader->registerAutoloadMap(SJB_BASE_DIR . 'system/core/.classmapcache.php');
     $loader->register();
     set_include_path(SJB_System::getSystemSettings('EXT_LIBRARY_DIR') . PATH_SEPARATOR . SJB_System::getSystemSettings('LIBRARY_DIR') . PATH_SEPARATOR . get_include_path());
 }
 public function testAllowsRegisteringArrayAutoloadMapViaConstructor()
 {
     $map = array('Zend_Loader_Exception' => dirname(__FILE__) . '/../../../library/Zend/Loader/Exception.php');
     $loader = new Zend_Loader_ClassMapAutoloader(array($map));
     $test = $loader->getAutoloadMap();
     $this->assertSame($map, $test);
 }
 public function autoload($class)
 {
     // manual aliasing
     $classAliases = ["Pimcore\\Resource" => "Pimcore\\Db", "Pimcore_Resource" => "Pimcore\\Db", "Pimcore\\Resource\\Mysql" => "Pimcore\\Db", "Pimcore_Resource_Mysql" => "Pimcore\\Db", "Pimcore\\Log\\Log" => "Pimcore\\Log\\ApplicationLogger", "Pimcore\\Log\\Writer\\Db" => "Pimcore\\Log\\Handler\\ApplicationLoggerDb", "Pimcore\\Model\\Cache" => "Pimcore\\Cache"];
     if (array_key_exists($class, $classAliases)) {
         class_alias($classAliases[$class], $class);
         return;
     }
     parent::autoload($class);
     // compatibility from Resource => Dao
     if (strpos($class, "Resource") && !class_exists($class, false) && !interface_exists($class, false)) {
         $daoClass = str_replace("Resource", "Dao", $class);
         if (Tool::classExists($daoClass) || Tool::interfaceExists($daoClass)) {
             if (!class_exists($class, false) && !interface_exists($class, false)) {
                 class_alias($daoClass, $class);
             }
         }
     }
     // reverse compatibility from namespaced to prefixed class names e.g. Pimcore\Model\Document => Document
     if (strpos($class, "Pimcore\\") === 0) {
         // first check for a model, if it doesnt't work fall back to the default autoloader
         if (!class_exists($class, false) && !interface_exists($class, false)) {
             if (!$this->loadModel($class)) {
                 $loader = \Zend_Loader_Autoloader::getInstance();
                 $loader->autoload($class);
             }
         }
         if (class_exists($class, false) || interface_exists($class, false)) {
             // create an alias
             $alias = str_replace("\\", "_", $class);
             $alias = preg_replace("/_Abstract([^_]+)/", "_Abstract", $alias);
             $alias = preg_replace("/_[^_]+Interface/", "_Interface", $alias);
             $alias = str_replace("_Listing_", "_List_", $alias);
             $alias = preg_replace("/_Listing\$/", "_List", $alias);
             $alias = str_replace("Object_ClassDefinition", "Object_Class", $alias);
             if (strpos($alias, "Pimcore_Model") === 0) {
                 if (!preg_match("/^Pimcore_Model_(Abstract|List|Resource|Cache)/", $alias)) {
                     $alias = str_replace("Pimcore_Model_", "", $alias);
                 }
             }
             if (!class_exists($alias, false) && !interface_exists($alias, false)) {
                 class_alias($class, $alias);
                 return;
                 // skip here, nothing more to do ...
             }
         }
     }
     // compatibility layer from prefixed to namespaced e.g. Document => Pimcore\Model\Document
     $isLegacyClass = preg_match("/^(Pimcore_|Asset|Dependency|Document|Element|Glossary|Metadata|Object|Property|Redirect|Schedule|Site|Staticroute|Tool|Translation|User|Version|Webservice|WebsiteSetting|Search)/", $class);
     if (!class_exists($class, false) && !interface_exists($class, false) && $isLegacyClass) {
         // this is for debugging purposes, to find legacy class names
         if (PIMCORE_DEBUG) {
             $backtrace = debug_backtrace();
             foreach ($backtrace as $step) {
                 if (isset($step["file"]) && !empty($step["file"]) && $step["function"] != "class_exists") {
                     $logName = "legacy-class-names";
                     if (preg_match("@^" . preg_quote(PIMCORE_PATH, "@") . "@", $step["file"])) {
                         $logName .= "-admin";
                     }
                     \Pimcore\Log\Simple::log($logName, $class . " used in " . $step["file"] . " at line " . $step["line"]);
                     break;
                 }
             }
         }
         $namespacedClass = $class;
         $namespacedClass = str_replace("_List", "_Listing", $namespacedClass);
         $namespacedClass = str_replace("Object_Class", "Object_ClassDefinition", $namespacedClass);
         $namespacedClass = preg_replace("/([^_]+)_Abstract\$/", "\$1_Abstract\$1", $namespacedClass);
         $namespacedClass = preg_replace("/([^_]+)_Interface\$/", "\$1_\$1Interface", $namespacedClass);
         $namespacedClass = str_replace("_", "\\", $namespacedClass);
         if (strpos($namespacedClass, "Pimcore") !== 0) {
             $namespacedClass = "Pimcore\\Model\\" . $namespacedClass;
         }
         // check if the class is a model, if so, load it
         $this->loadModel($namespacedClass);
         if (Tool::classExists($namespacedClass) || Tool::interfaceExists($namespacedClass)) {
             if (!class_exists($class, false) && !interface_exists($class, false)) {
                 class_alias($namespacedClass, $class);
             }
         }
     }
 }
Exemple #4
0
<?php

// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../../../application'));
// define('APPLICATION_ENV','testing');
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
// // require_once 'ModelTestCase.php';
// // require_once 'ControllerTestCase.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
$loader = new Zend_Loader_ClassMapAutoloader();
$loader->registerAutoloadMap(APPLICATION_PATH . '/../data/classmap/autoload_classmap.php');
$loader->register();
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap();