instance() публичный статический Метод

Singleton pattern implementation
public static instance ( ) : Varien_Autoload
Результат Varien_Autoload
Пример #1
0
 public static function register($base = false)
 {
     /* deprecated since 2.19.0
             if (defined('COMPILER_INCLUDE_PATH'))
             {
                 $paths = array();
                 $paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
                 $paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
                 #$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
                 #$paths[] = BP . DS . 'lib';
     
                 $appPath = implode(PS, $paths);
                 set_include_path($appPath . PS . get_include_path());
             }
             */
     $rewriter = new Aitoc_Aitsys_Model_Rewriter();
     $rewriter->preRegisterAutoloader($base);
     // unregistering all, and varien autoloaders to make our performing first
     $autoloaders = spl_autoload_functions();
     if ($autoloaders and is_array($autoloaders) && !empty($autoloaders)) {
         foreach ($autoloaders as $autoloader) {
             spl_autoload_unregister($autoloader);
         }
     }
     if (version_compare(Mage::getVersion(), '1.3.1', '>')) {
         spl_autoload_unregister(array(Varien_Autoload::instance(), 'autoload'));
     }
     spl_autoload_register(array(self::instance(), 'autoload'), false);
     if (version_compare(Mage::getVersion(), '1.3.1', '>')) {
         Varien_Autoload::register();
     } else {
         spl_autoload_register(array(self::instance(), 'performStandardAutoload'));
         #self::_loadOverwrittenClasses();
     }
 }
 public function testRegisterStandard()
 {
     Varien_Autoload::register();
     $functions = spl_autoload_functions();
     $matches = array_filter($functions, function ($function) {
         return $function == [Varien_Autoload::instance(), 'autoload'];
     });
     $this->assertNotCount(0, $matches);
     // TODO: find a way to use assertArraySubset
     // $this->assertArraySubset(
     //     [Varien_Autoload::instance(), 'autoload'], $functions);
     spl_autoload_unregister([Varien_Autoload::instance(), 'autoload']);
 }
Пример #3
0
 /**
  * @return PHPUnit_Framework_MockObject_MockObject|Application
  */
 public function getApplication()
 {
     if ($this->application === null) {
         $root = $this->getTestMagentoRoot();
         $this->application = $this->getMock('N98\\Magento\\Application', array('getMagentoRootFolder'));
         $loader = (require __DIR__ . '/../../../../../vendor/autoload.php');
         $this->application->setAutoloader($loader);
         $this->application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root));
         $this->application->init();
         $this->application->initMagento();
         if ($this->application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) {
             spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
         }
     }
     return $this->application;
 }
Пример #4
0
 public static function register()
 {
     if (self::instance()->getIsRegistered()) {
         return;
     }
     $path = BP . DS . 'var' . DS . 'goodahead' . DS . 'etm' . DS . 'includes';
     set_include_path($path . PS . get_include_path());
     if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
         spl_autoload_register(array(self::instance(), 'autoload'), false, true);
     } else {
         spl_autoload_register(array(self::instance(), 'autoload'), false);
         spl_autoload_unregister(array(Varien_Autoload::instance(), 'autoload'));
         Varien_Autoload::register();
     }
     self::instance()->setIsRegistered(true);
 }
Пример #5
0
 /**
  * @throws \RuntimeException
  * @return PHPUnit_Framework_MockObject_MockObject|\IMI\Contao\Application
  */
 public function getApplication()
 {
     if ($this->application === null) {
         $root = getenv('IMI_MAGERUN_TEST_MAGENTO_ROOT');
         if (empty($root)) {
             throw new \RuntimeException('Please specify environment variable IMI_MAGERUN_TEST_MAGENTO_ROOT with path to your test
                 contao installation!');
         }
         $this->application = $this->getMock('IMI\\Contao\\Application', array('getContaoRootFolder'));
         $loader = (require __DIR__ . '/../../../../../vendor/autoload.php');
         $this->application->setAutoloader($loader);
         $this->application->expects($this->any())->method('getContaoRootFolder')->will($this->returnValue($root));
         $this->application->init();
         $this->application->initContao();
         if ($this->application->getContaoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) {
             spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
         }
     }
     return $this->application;
 }
 public function addAutoloader()
 {
     if (!self::$shouldAdd) {
         return;
     }
     foreach ($this->getNamespacesToRegister() as $namespace) {
         if (is_dir(Mage::getBaseDir('lib') . DS . $namespace)) {
             $args = array($namespace, Mage::getBaseDir('lib') . DS . $namespace);
             $autoloader = Mage::getModel("psr0autoloader/splAutoloader", $args);
             $autoloader->register();
         }
     }
     if ($composerVendorPath = $this->getComposerVendorPath()) {
         require_once $composerVendorPath . '/autoload.php';
     }
     if ($this->shouldDisableBaseAutoloader()) {
         spl_autoload_unregister(array(Varien_Autoload::instance(), 'autoload'));
     }
     self::$shouldAdd = false;
 }
Пример #7
0
 public static function register($base = false)
 {
     Mage::register('aitsys_autoload_initialized', true);
     $rewriter = new Aitoc_Aitsys_Model_Rewriter();
     $rewriter->preRegisterAutoloader($base);
     // unregistering all, and varien autoloaders to make our performing first
     $autoloaders = spl_autoload_functions();
     if ($autoloaders and is_array($autoloaders) && !empty($autoloaders)) {
         foreach ($autoloaders as $autoloader) {
             spl_autoload_unregister($autoloader);
         }
     }
     if (version_compare(Mage::getVersion(), '1.3.1', '>')) {
         spl_autoload_unregister(array(Varien_Autoload::instance(), 'autoload'));
     }
     spl_autoload_register(array(self::instance(), 'autoload'), false);
     if (version_compare(Mage::getVersion(), '1.3.1', '>')) {
         Varien_Autoload::register();
     } else {
         spl_autoload_register(array(self::instance(), 'performStandardAutoload'));
     }
 }
Пример #8
0
 /**
  * @return Application|PHPUnit_Framework_MockObject_MockObject
  */
 public function getApplication()
 {
     if ($this->application === null) {
         $root = $this->getTestMagentoRoot();
         /** @var Application|PHPUnit_Framework_MockObject_MockObject $application */
         $application = $this->getMock('N98\\Magento\\Application', array('getMagentoRootFolder'));
         // Get the composer bootstrap
         if (defined('PHPUNIT_COMPOSER_INSTALL')) {
             $loader = (require PHPUNIT_COMPOSER_INSTALL);
         } elseif (file_exists(__DIR__ . '/../../../../../../autoload.php')) {
             // Installed via composer, already in vendor
             $loader = (require __DIR__ . '/../../../../../../autoload.php');
         } else {
             // Check if testing root package without PHPUnit
             $loader = (require __DIR__ . '/../../../../vendor/autoload.php');
         }
         $application->setAutoloader($loader);
         $application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root));
         spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
         $application->init();
         $application->initMagento();
         if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) {
             spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
         }
         $this->application = $application;
     }
     return $this->application;
 }
Пример #9
0
    $_baseDir = getcwd();
}
// Include Mage file by detecting app root
require_once $_baseDir . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Mage.php';
if (!Mage::isInstalled()) {
    echo 'Magento Unit Tests can run only on installed version';
    exit(1);
}
/* Replace server variables for proper file naming */
$_SERVER['SCRIPT_NAME'] = $_baseDir . DS . 'index.php';
$_SERVER['SCRIPT_FILENAME'] = $_baseDir . DS . 'index.php';
// This fix allows running Magento Unit Tests
// from remote PHPUnit execution in vagrant box over PHPStorm
if (!empty($_GET)) {
    $_GET = array();
}
Mage::app('admin');
Mage::getConfig()->init();
// Removing Varien Autoload, to prevent errors with PHPUnit components
spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload'));
// It is possible to include custom bootstrap file by specifying env variable shell
// or in server
if (isset($_SERVER['ECOMDEV_PHPUNIT_CUSTOM_BOOTSTRAP'])) {
    include $_SERVER['ECOMDEV_PHPUNIT_CUSTOM_BOOTSTRAP'];
}
if (!defined('ECOMDEV_PHPUNIT_NO_AUTOLOADER')) {
    spl_autoload_register(function ($className) {
        $filePath = strtr(ltrim($className, '\\'), array('\\' => '/', '_' => '/'));
        @(include $filePath . '.php');
    });
}
Пример #10
0
 /**
  * Removes current autoload class and
  * registers Varien_Autoload is the spl autoload queue
  */
 public static function disable()
 {
     spl_autoload_unregister(array(self::getInstance(), 'autoload'));
     spl_autoload_register(array(Varien_Autoload::instance(), 'autoload'));
 }
 /**
  * init Interface
  *
  * @param array emConf
  */
 public function init($config)
 {
     // init Config Array
     $this->config = $config;
     // include Mage
     if (!class_exists('Mage', false)) {
         require_once $this->config['path'] . 'app/Mage.php';
     }
     // disable Notices
     error_reporting(E_ALL & ~E_NOTICE);
     // overwrite Magento Autoload Funktion
     if (class_exists('Varien_Autoload', false)) {
         spl_autoload_unregister(array(Varien_Autoload::instance(), 'autoload'));
     }
     spl_autoload_register(array(&$this, 'autoload'));
     // Init Mage
     $store = tx_fbmagento_tools::getFELangStoreCode();
     Mage::app()->setCurrentStore(Mage::app()->getStore($store));
     restore_error_handler();
     if ($GLOBALS['TSFE']->cObj instanceof tslib_cObj) {
         $cObj = $GLOBALS['TSFE']->cObj;
         $baseUrl = $cObj->getTypoLink_URL($GLOBALS['TSFE']->id);
         // get rid of trailing .html because of Real URL
         $pos = strrpos($baseUrl, '.');
         $extension = substr($baseUrl, $pos);
         if (strpos($extension, '/') === false) {
             $baseUrl = substr($baseUrl, 0, $pos);
         }
     }
     // Init Typo3connect
     $params = array('enabled' => true);
     if ('' != $baseUrl) {
         $params['_typo3BaseUrl'] = t3lib_div::locationHeaderUrl($baseUrl);
     }
     $this->connector = Mage::getSingleton('Flagbit_Typo3connect/Core', $params);
     if (null !== $cObj) {
         $this->connector->setcObj($cObj);
     }
 }
function mageFindClassFile($class)
{
    return Varien_Autoload::instance()->findFile($class);
}
Пример #13
0
 function cw_class_loader($className)
 {
     return Varien_Autoload::instance()->autoload($className);
 }