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(); } }
/** * 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); } }
/** * 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); }
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; } }
/** * @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; }
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); }
/** * @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 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(); }
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; }
/** * 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); }
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')); } }
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; }
/** * @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; }
function cw_class_loader($className) { return Varien_Autoload::instance()->autoload($className); }
/** * Register autoload scope * This process allow include scope file which can contain classes * definition which are used for this scope * * @param string $code scope code */ public static function registerScope($code) { self::$_scope = $code; @(include_once self::SCOPE_FILE_PREFIX . $code . '.php'); }
/** * 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)); }
/** * 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); }
include_once "Mage_Core_functions.php"; include_once "Varien_Autoload.php"; } else { /** * Set include path */ $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 . Mage::registry('original_include_path')); include_once "Mage/Core/functions.php"; include_once "Varien/Autoload.php"; } Varien_Autoload::register(); /** * Main Mage hub class * * @author Magento Core Team <*****@*****.**> */ final class Mage { /** * Registry collection * * @var array */ private static $_registry = array(); /** * Application root absolute path
/** * Setting cache content * * @param array $cache */ public static function setCache(array $cache) { self::$_cache = $cache; }
/** * Register autoload scope * This process allow include scope file which can contain classes * definition which are used for this scope * * @param string $code scope code */ static public function registerScope($code) { self::$_scope = $code; if (defined('COMPILER_INCLUDE_PATH')) { @include COMPILER_INCLUDE_PATH . DIRECTORY_SEPARATOR . self::SCOPE_FILE_PREFIX.$code.'.php'; } }
/** * 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')); }
/** * Implements database-centered URL rewrite logic (translates human friendly URLs into standard * module/controller/action/params form). * * @see Mage_Core_Model_Url_Rewrite::rewrite() * * This method is based on Mage_Core_Model_Url_Rewrite::rewrite() source. Modifications are marked with comments. */ public function rewrite(Zend_Controller_Request_Http $request = null, Zend_Controller_Response_Http $response = null) { /* @var $_core Mana_Core_Helper_Data */ $_core = Mage::helper(strtolower('Mana_Core')); $conditionalWord = $_core->getStoreConfig('mana_filters/seo/conditional_word'); $categorySuffix = Mage::helper('manapro_filterseolinks')->getCategoryUrlSuffix(); if (!Mage::isInstalled()) { return false; } if (is_null($request)) { $request = Mage::app()->getFrontController()->getRequest(); } if (is_null($response)) { $response = Mage::app()->getFrontController()->getResponse(); } if (is_null($this->getStoreId()) || false === $this->getStoreId()) { $this->setStoreId(Mage::app()->getStore()->getId()); } /** * We have two cases of incoming paths - with and without slashes at the end ("/somepath/" and "/somepath"). * Each of them matches two url rewrite request paths - with and without slashes at the end ("/somepath/" and "/somepath"). * Choose any matched rewrite, but in priority order that depends on same presence of slash and query params. */ $requestCases = array(); $pathInfo = urldecode($request->getPathInfo()); $origSlash = substr($pathInfo, -1) == '/' ? '/' : ''; $requestPath = trim($pathInfo, '/'); if ($conditionalWord && ($conditionPos = strpos($requestPath, $conditionalWord . '/')) === 0) { Varien_Autoload::registerScope('catalog'); Varien_Autoload::registerScope('cms'); $pageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE); $this->_setPageCategoryId($pageId); $parameters = substr($requestPath, $conditionPos + strlen($conditionalWord . '/')); $_SERVER['QUERY_STRING'] = http_build_query($this->_getQueryParameters($parameters), '', '&'); $request->setAlias(self::REWRITE_REQUEST_PATH_ALIAS, $this->getRequestPath()); if (Mage::getStoreConfig('web/url/use_store') && ($storeCode = Mage::app()->getStore()->getCode())) { $targetUrl = $request->getBaseUrl() . '/' . $storeCode; } else { $targetUrl = $request->getBaseUrl(); } if ($queryString = $this->_getQueryString()) { if (strrpos($targetUrl, '/') !== strlen($targetUrl) - 1) { $targetUrl .= '/'; } $targetUrl .= '?' . $queryString; } if ($parameters) { $request->setRequestUri($request->getBaseUrl() . str_replace('/' . $conditionalWord . '/' . $parameters, '', $request->getRequestString())); $request->setPathInfo(); } $request->setRequestUri($targetUrl); $request->setPathInfo(''); return true; } elseif ($conditionalWord && ($conditionPos = strpos($requestPath, '/' . $conditionalWord . '/')) != false) { Varien_Autoload::registerScope('catalog'); Varien_Autoload::registerScope('cms'); $cmsPath = substr($requestPath, 0, $conditionPos); $page = Mage::getModel('cms/page'); $pageId = $page->checkIdentifier($cmsPath, Mage::app()->getStore()->getId()); if ($pageId) { $this->_setPageCategoryId($pageId); $parameters = substr($requestPath, $conditionPos + strlen('/' . $conditionalWord . '/')); $_SERVER['QUERY_STRING'] = http_build_query($this->_getQueryParameters($parameters), '', '&'); $request->setAlias(self::REWRITE_REQUEST_PATH_ALIAS, $this->getRequestPath()); if (Mage::getStoreConfig('web/url/use_store') && ($storeCode = Mage::app()->getStore()->getCode())) { $targetUrl = $request->getBaseUrl() . '/' . $storeCode . '/' . $cmsPath; } else { $targetUrl = $request->getBaseUrl() . '/' . $cmsPath; } if ($queryString = $this->_getQueryString()) { $targetUrl .= '?' . $queryString; } if ($parameters) { $request->setRequestUri($request->getBaseUrl() . str_replace('/' . $conditionalWord . '/' . $parameters, '', $request->getRequestString())); $request->setPathInfo(); } $request->setRequestUri($targetUrl); $request->setPathInfo($cmsPath); return true; } } $altSlash = $origSlash ? '' : '/'; // If there were final slash - add nothing to less priority paths. And vice versa. $queryString = $this->_getQueryString(); // Query params in request, matching "path + query" has more priority if ($queryString) { $requestCases[] = $requestPath . $origSlash . '?' . $queryString; $requestCases[] = $requestPath . $altSlash . '?' . $queryString; } $requestCases[] = $requestPath . $origSlash; $requestCases[] = $requestPath . $altSlash; // MANA BEGIN: in case we have specially named segment in URL suspect it is layered navigation url. Then // add additional checks to $requestCases if ($conditionalWord && ($conditionPos = strpos($requestPath, '/' . $conditionalWord . '/')) != false && (!$categorySuffix || $categorySuffix == '/' || strrpos($requestPath, $categorySuffix) == strlen($requestPath) - strlen($categorySuffix))) { Varien_Autoload::registerScope('catalog'); $layeredPath = substr($requestPath, 0, $conditionPos) . ($categorySuffix != '/' ? $categorySuffix : ''); $requestCases[] = $layeredPath . $origSlash; $requestCases[] = $layeredPath . $altSlash; } else { $layeredPath = false; } // MANA END $this->loadByRequestPath($requestCases); /** * Try to find rewrite by request path at first, if no luck - try to find by id_path */ if (!$this->getId() && isset($_GET['___from_store'])) { try { $fromStoreId = Mage::app()->getStore($_GET['___from_store'])->getId(); } catch (Exception $e) { return false; } $this->setStoreId($fromStoreId)->loadByRequestPath($requestCases); if (!$this->getId()) { return false; } $this->setStoreId(Mage::app()->getStore()->getId())->loadByIdPath($this->getIdPath()); } if (!$this->getId()) { return false; } // MANA BEGIN: in case we found rewrite based on filtered navigation url, do some magic passes // around request object and $_SERVER['QUERY_STRING'] to make it look like // "apparel/shoes.html?shoe_type=52&shoe_type-show-all=1" $parameters = ''; if ($layeredPath !== false && in_array($this->getRequestPath(), array($layeredPath . $origSlash, $layeredPath . $altSlash)) && $this->getCategoryId()) { if ($categorySuffix && $categorySuffix != '/') { $parameters = substr($requestPath, $conditionPos + strlen('/' . $conditionalWord . '/'), strlen($requestPath) - strlen($categorySuffix) - $conditionPos - strlen('/' . $conditionalWord . '/')); } else { $parameters = substr($requestPath, $conditionPos + strlen('/' . $conditionalWord . '/')); } $_SERVER['QUERY_STRING'] = http_build_query($this->_getQueryParameters($parameters), '', '&'); } // MANA END $request->setAlias(self::REWRITE_REQUEST_PATH_ALIAS, $this->getRequestPath()); $external = substr($this->getTargetPath(), 0, 6); $isPermanentRedirectOption = $this->hasOption('RP'); if ($external === 'http:/' || $external === 'https:') { if ($isPermanentRedirectOption) { header('HTTP/1.1 301 Moved Permanently'); } header("Location: " . $this->getTargetPath()); exit; } else { $targetUrl = $request->getBaseUrl() . '/' . $this->getTargetPath(); } $isRedirectOption = $this->hasOption('R'); if ($isRedirectOption || $isPermanentRedirectOption) { if (Mage::getStoreConfig('web/url/use_store') && ($storeCode = Mage::app()->getStore()->getCode())) { $targetUrl = $request->getBaseUrl() . '/' . $storeCode . '/' . $this->getTargetPath(); } if ($isPermanentRedirectOption) { header('HTTP/1.1 301 Moved Permanently'); } header('Location: ' . $targetUrl); exit; } if (Mage::getStoreConfig('web/url/use_store') && ($storeCode = Mage::app()->getStore()->getCode())) { $targetUrl = $request->getBaseUrl() . '/' . $storeCode . '/' . $this->getTargetPath(); } $queryString = $this->_getQueryString(); if ($queryString) { $targetUrl .= '?' . $queryString; } if ($parameters) { $request->setRequestUri($request->getBaseUrl() . str_replace('/' . $conditionalWord . '/' . $parameters, '', $request->getRequestString())); $request->setPathInfo(); } $request->setRequestUri($targetUrl); $request->setPathInfo($this->getTargetPath()); $request->setActionName(''); return true; }
/** * Register autoload scope * This process allow include scope file which can contain classes * definition which are used for this scope * * @param string $code scope code */ public static function registerScope($code) { self::$_scope = $code; if (defined('COMPILER_INCLUDE_PATH')) { @(include_once self::SCOPE_FILE_PREFIX . $code . '.php'); } }
$_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'); }); }
/** * Dispatch event before action * * @return void */ 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) && !$this->getRequest()->getParam('nocookie', false); $cookies = Mage::getSingleton('core/cookie')->get(); /** @var $session Mage_Core_Model_Session */ $session = Mage::getSingleton('core/session', array('name' => $this->_sessionNamespace))->start(); if (empty($cookies)) { if ($session->getCookieShouldBeReceived()) { $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true); $session->unsCookieShouldBeReceived(); $session->setSkipSessionIdFlag(true); } elseif ($checkCookie) { if (isset($_GET[$session->getSessionIdQueryParam()]) && Mage::app()->getUseSessionInUrl() && $this->_sessionNamespace != Mage_Adminhtml_Controller_Action::SESSION_NAMESPACE) { $session->setCookieShouldBeReceived(true); } else { $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true); } } } } 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; } Varien_Autoload::registerScope($this->getRequest()->getRouteName()); Mage::dispatchEvent('controller_action_predispatch', array('controller_action' => $this)); Mage::dispatchEvent('controller_action_predispatch_' . $this->getRequest()->getRouteName(), array('controller_action' => $this)); Mage::dispatchEvent('controller_action_predispatch_' . $this->getFullActionName(), array('controller_action' => $this)); }
/** * This is here for backwards compatibility only * * @param string $code */ public static function registerScope($code) { self::$_scope = $code; }