本文整理汇总了PHP中Varien_Autoload::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Autoload::instance方法的具体用法?PHP Varien_Autoload::instance怎么用?PHP Varien_Autoload::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Autoload
的用法示例。
在下文中一共展示了Varien_Autoload::instance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
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();
}
}
示例2: testRegisterStandard
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: getApplication
/**
* @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: register
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: getApplication
/**
* @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;
}
示例6: addAutoloader
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: register
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: getApplication
/**
* @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: getcwd
$_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: disable
/**
* 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'));
}
示例11: init
/**
* 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);
}
}
示例12: mageFindClassFile
function mageFindClassFile($class)
{
return Varien_Autoload::instance()->findFile($class);
}
示例13: cw_class_loader
function cw_class_loader($className)
{
return Varien_Autoload::instance()->autoload($className);
}