本文整理汇总了PHP中Varien_Autoload类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Autoload类的具体用法?PHP Varien_Autoload怎么用?PHP Varien_Autoload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Autoload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setRevalidateFlagAction
/**
* Set revalidate flag
*/
public function setRevalidateFlagAction()
{
$flagFile = Varien_Autoload::getRevalidateFlagPath();
if (file_put_contents($flagFile, date(DATE_ISO8601))) {
echo "Success\n";
} else {
echo "Error while writing '{$flagFile}'\n";
exit(1);
}
}
示例3: revalidateCache
/**
* Revalidate all currently cached entries
*/
public function revalidateCache()
{
$start = microtime(true);
$cache = Varien_Autoload::getCache();
Varien_Autoload::setCache(array());
foreach ($cache as $className => $path) {
Varien_Autoload::getFullPath($className);
}
$duration = microtime(true) - $start;
Mage::log('[ClassPathCache] Revalidated ' . count($cache) . ' classes (duration: ' . round($duration, 2) . ' sec)', 6, self::LOG_FILE);
}
示例4: bootMagento
public static function bootMagento($path = '.')
{
if (!self::isLoaded()) {
foreach (self::$magento as $file) {
require_once $path . $file;
}
\Varien_Autoload::register();
require_once $path . '/app/Mage.php';
$app = \Mage::app('default', 'store', array());
$app->getConfig()->loadEventObservers('global');
$app->getConfig()->loadEventObservers('front');
self::$loaded = true;
}
}
示例5: 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;
}
示例6: 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);
}
示例7: 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;
}
示例8: testRegisterClassmap
public function testRegisterClassmap()
{
define('OPTIMIZED_COMPOSER', true);
$testClassname = 'c' . uniqid();
$testClassfilename = BP . '/lib/' . $testClassname . '.php';
$testClass = <<<CLASS
<?php
class {$testClassname} {}
CLASS;
testfuncs\create_structure();
file_put_contents($testClassfilename, $testClass);
// Generate the classmap
require BP . '/../src/classmap_generator.php';
Varien_Autoload::register();
$loader = (require __DIR__ . '/../vendor/autoload.php');
$classMap = $loader->getClassMap();
$this->assertArrayHasKey($testClassname, $classMap);
unlink($testClassfilename);
testfuncs\destroy_structure();
}
示例9: 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;
}
示例10: checkAndServeCachedPage
/**
* Checks cache for cached pages. If found the original response is served,
* otherwise normal processing will occur.
*
* Observes: controller_action_predispatch
*
* @param $observer
* @return void
*/
public function checkAndServeCachedPage(Varien_Event_Observer $observer)
{
/**
* @var $controllerAction Mage_Core_Controller_Varien_Action
* @var $engine Brim_PageCache_Model_Engine
*/
/*
* controller_action_predispatch occurs before the autoloader sets the scope for the compiler. When the compiler
* is enabled there is the possibility of creating a redeclare class fatal error if we need any class that is
* included in the compilers current scope file. ESP. an issue with the checkout scope. Registering the scope
* here prevents the fatal error from occurring.
*/
if (defined('COMPILER_INCLUDE_PATH')) {
$controllerAction = $observer->getControllerAction();
Varien_Autoload::registerScope($controllerAction->getRequest()->getRouteName());
}
$engine = Mage::getSingleton('brim_pagecache/engine');
if (!$engine->isEnabled()) {
return;
}
$engine->servePage($this);
}
示例11: 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'));
}
}
示例12: match
public function match(Zend_Controller_Request_Http $request)
{
if (Mage::app()->getStore()->isAdmin()) {
return false;
}
$pageId = $request->getPathInfo();
// remove suffix if any
$suffix = Mage::getStoreConfig('catalog/seo/category_url_suffix');
if ($suffix && '/' != $suffix) {
$pageId = str_replace($suffix, '', $pageId);
}
//add trailing slash
$pageId = trim($pageId, '/') . '/';
$reservedKey = Mage::getStoreConfig('amshopby/seo/key') . '/';
//check if we have reserved word in the url
if (false === strpos($pageId, '/' . $reservedKey)) {
if (substr($pageId, 0, strlen($reservedKey)) != $reservedKey) {
return false;
}
} else {
$reservedKey = '/' . $reservedKey;
}
// get layered navigation params as string
list($cat, $params) = explode($reservedKey, $pageId, 2);
$params = trim($params, '/');
if ($params) {
$params = explode('/', $params);
}
// remember for futire use in the helper
if ($params) {
Mage::register('amshopby_current_params', $params);
}
$cat = trim($cat, '/');
if ($cat) {
// normal category
// if somebody has old urls in the cache.
if (!Mage::getStoreConfig('amshopby/seo/urls')) {
return false;
}
Varien_Autoload::registerScope('catalog');
$cat = $cat . $suffix;
$urlRewrite = Mage::getModel('core/url_rewrite')->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($cat);
if (!$urlRewrite->getId()) {
$store = $request->getParam('___from_store');
$store = Mage::app()->getStore($store)->getId();
if (!$store) {
return false;
}
$urlRewrite = Mage::getModel('core/url_rewrite')->setStoreId($store)->loadByRequestPath($cat);
}
if (!$urlRewrite->getId()) {
return false;
}
$request->setPathInfo($cat);
$request->setModuleName('catalog');
$request->setControllerName('category');
$request->setActionName('view');
$request->setParam('id', $urlRewrite->getCategoryId());
$urlRewrite->rewrite($request);
} else {
// root category
$realModule = 'Amasty_Shopby';
$request->setPathInfo(trim($reservedKey, '/'));
$request->setModuleName('amshopby');
$request->setRouteName('amshopby');
$request->setControllerName('index');
$request->setActionName('index');
$request->setControllerModule($realModule);
$file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
include $file;
//compatibility with 1.3
$class = $realModule . '_IndexController';
$controllerInstance = new $class($request, $this->getFront()->getResponse());
$request->setDispatched(true);
$controllerInstance->dispatch('index');
}
return true;
}
示例13: 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;
}
示例14: cw_class_loader
function cw_class_loader($className)
{
return Varien_Autoload::instance()->autoload($className);
}
示例15: preDispatch
/**
* Dispatches event before action
*/
public function preDispatch()
{
if (!$this->getFlag('', self::FLAG_NO_CHECK_INSTALLATION)) {
if (!Mage::isInstalled()) {
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
$this->_redirect('install');
return;
}
}
// Prohibit disabled store actions
if (Mage::isInstalled() && !Mage::app()->getStore()->getIsActive()) {
Mage::app()->throwStoreException();
}
if ($this->_rewrite()) {
return;
}
if (!$this->getFlag('', self::FLAG_NO_START_SESSION)) {
$checkCookie = in_array($this->getRequest()->getActionName(), $this->_cookieCheckActions);
$checkCookie = $checkCookie && !$this->getRequest()->getParam('nocookie', false);
$cookies = Mage::getSingleton('core/cookie')->get();
if ($checkCookie && empty($cookies)) {
$this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true);
}
Mage::getSingleton('core/session', array('name' => $this->_sessionNamespace))->start();
}
Mage::app()->loadArea($this->getLayout()->getArea());
if ($this->getFlag('', self::FLAG_NO_COOKIES_REDIRECT) && Mage::getStoreConfig('web/browser_capabilities/cookies')) {
$this->_forward('noCookies', 'index', 'core');
return;
}
if ($this->getFlag('', self::FLAG_NO_PRE_DISPATCH)) {
return;
}
Mage::dispatchEvent('controller_action_predispatch', array('controller_action' => $this));
Mage::dispatchEvent('controller_action_predispatch_' . $this->getRequest()->getRouteName(), array('controller_action' => $this));
Varien_Autoload::registerScope($this->getRequest()->getRouteName());
Mage::dispatchEvent('controller_action_predispatch_' . $this->getFullActionName(), array('controller_action' => $this));
}