public function createBlock($block) { if (is_string($block)) { $block = Mage::getConfig()->getBlockClassName($block); if (Magento_Autoload::getInstance()->classExists($block)) { $block = new $block(array()); } } if (!$block instanceof Mage_Core_Block_Abstract) { Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Invalid block type: %s', $block)); } return $block; }
/** * Gets array of customer entities and appropriate behaviours * array( * <entity_code> => array( * 'token' => <behavior_class_name>, * 'code' => <behavior_model_code>, * ), * ... * ) * * @static * @return array */ public static function getEntityBehaviors() { $behaviourData = array(); $entitiesConfig = Mage::getConfig()->getNode(self::CONFIG_KEY_ENTITIES)->asArray(); foreach ($entitiesConfig as $entityCode => $entityData) { $behaviorToken = isset($entityData['behavior_token']) ? $entityData['behavior_token'] : null; if ($behaviorToken && Magento_Autoload::getInstance()->classExists($behaviorToken)) { /** @var $behaviorModel Mage_ImportExport_Model_Source_Import_BehaviorAbstract */ $behaviorModel = Mage::getModel($behaviorToken); $behaviourData[$entityCode] = array('token' => $behaviorToken, 'code' => $behaviorModel->getCode() . '_behavior'); } else { Mage::throwException(Mage::helper('Mage_ImportExport_Helper_Data')->__('Invalid behavior token for %s', $entityCode)); } } return $behaviourData; }
exit; } /** * Environment initialization */ error_reporting(E_ALL | E_STRICT); #ini_set('display_errors', 1); umask(0); /** * Require necessary files */ require_once BP . '/lib/Magento/Autoload.php'; require_once BP . '/app/code/core/Mage/Core/functions.php'; require_once BP . '/app/Mage.php'; if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) { Mage::setIsDeveloperMode(true); } Mage::register('original_include_path', get_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'; Magento_Autoload::getInstance()->addIncludePath($paths); $classMapPath = BP . DS . 'var/classmap.ser'; if (file_exists($classMapPath)) { Magento_Autoload::getInstance()->addFilesMap($classMapPath); } #Magento_Profiler::enable(); #Magento_Profiler::registerOutput(new Magento_Profiler_Output_Html()); #Magento_Profiler::registerOutput(new Magento_Profiler_Output_Firebug()); #Magento_Profiler::registerOutput(new Magento_Profiler_Output_Csvfile(__DIR__ . '/var/log/profiler.csv'));
* * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package performance_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $testsBaseDir = realpath(__DIR__ . '/..'); $magentoBaseDir = realpath($testsBaseDir . '/../../../'); require_once "{$magentoBaseDir}/app/bootstrap.php"; Magento_Autoload::getInstance()->addIncludePath("{$testsBaseDir}/framework"); $configFile = "{$testsBaseDir}/config.php"; $configFile = file_exists($configFile) ? $configFile : "{$configFile}.dist"; $configData = (require $configFile); $config = new Magento_Config($configData, $testsBaseDir); $installOptions = $config->getInstallOptions(); if ($installOptions) { // Populate install options with global options $baseUrl = 'http://' . $config->getApplicationUrlHost() . $config->getApplicationUrlPath(); $installOptions = array_merge($installOptions, array('url' => $baseUrl, 'secure_base_url' => $baseUrl)); $adminOptions = $config->getAdminOptions(); foreach ($adminOptions as $key => $val) { $installOptions['admin_' . $key] = $val; } // Install application $installer = new Magento_Installer($magentoBaseDir . '/dev/shell/install.php', new Magento_Shell(true));
/** * Set application Config model * * @param array $options */ protected static function _setConfigModel($options = array()) { if (isset($options['config_model']) && Magento_Autoload::getInstance()->classExists($options['config_model'])) { $alternativeConfigModelName = $options['config_model']; unset($options['config_model']); $alternativeConfigModel = new $alternativeConfigModelName($options); } else { $alternativeConfigModel = null; } if (!is_null($alternativeConfigModel) && $alternativeConfigModel instanceof Mage_Core_Model_Config) { self::$_config = $alternativeConfigModel; } else { self::$_config = new Mage_Core_Model_Config($options); } }
/** * Generate class name * * @param string $module * @param string $type * @param string $name * * @return string */ protected function _getClassName($module, $type, $name = null) { $className = implode('_', array_map('ucfirst', explode('_', $module . '_' . $type . '_' . $name))); if (Magento_Autoload::getInstance()->classExists($className)) { return $className; } return ''; }
public function testGetInstance() { $this->assertSame($this->_loader, Magento_Autoload::getInstance()); }
/** * Cleanup database use system configuration */ protected function _cleanUpDatabase() { $dbConfig = Mage::getConfig()->getResourceConnectionConfig(Mage_Core_Model_Resource::DEFAULT_SETUP_RESOURCE); $modelName = 'Mage_Install_Model_Installer_Db_' . ucfirst($dbConfig->model); if (!Magento_Autoload::getInstance()->classExists($modelName)) { $this->addError('Database uninstall is not supported for the ' . ucfirst($dbConfig->model) . '.'); return false; } /** @var $resourceModel Mage_Install_Model_Installer_Db_Abstract */ $resourceModel = Mage::getModel($modelName); $resourceModel->cleanUpDatabase($dbConfig); }
/** * Create block object instance based on block type * * @param string|Mage_Core_Block_Abstract $block * @param array $attributes * @return Mage_Core_Block_Abstract */ protected function _getBlockInstance($block, array $attributes = array()) { if ($block && is_string($block)) { $block = Mage::getConfig()->getBlockClassName($block); if (Magento_Autoload::getInstance()->classExists($block)) { $block = new $block($attributes); } } if (!$block instanceof Mage_Core_Block_Abstract) { Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Invalid block type: %s', $block)); } return $block; }
* to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category tests * @package js * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ define('RELATIVE_APP_ROOT', '../../..'); require_once normalize(RELATIVE_APP_ROOT . '/lib/Magento/Autoload.php'); Magento_Autoload::getInstance()->addIncludePath(normalize(RELATIVE_APP_ROOT . '/lib')); $userConfig = normalize('jsTestDriver.php'); $defaultConfig = normalize('jsTestDriver.php.dist'); $configFile = file_exists($userConfig) ? $userConfig : $defaultConfig; $config = (require $configFile); if (isset($config['JsTestDriver'])) { $jsTestDriver = $config['JsTestDriver']; } else { echo "Value for the 'JsTestDriver' configuration parameter is not specified." . PHP_EOL; showUsage(); } if (!file_exists($jsTestDriver)) { reportError('JsTestDriver jar file does not exist: ' . $jsTestDriver); } if (isset($config['Browser'])) { $browser = $config['Browser'];
* DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Tools * @package acl_db * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $rootDir = realpath(__DIR__ . '/../../../..'); require_once $rootDir . '/lib/Magento/Autoload.php'; $paths[] = $rootDir . '/lib'; $paths[] = $rootDir . '/dev'; Magento_Autoload::getInstance()->addIncludePath($paths); $defaultReportFile = 'report.log'; try { $options = new Zend_Console_Getopt(array('file=s' => "File containing json encoded acl identifier map (old => new)", 'mode|w' => "Application mode. Preview mode is default. If set to 'write' - database is updated.", 'output|f-w' => "Report output type. Report is flushed to console by default." . "If set to 'file', report is written to file /log/report.log", 'dbprovider=w' => "Database adapter class name. Default: Varien_Db_Adapter_Pdo_Mysql", 'dbhost=s' => "Database server host", 'dbuser=s' => "Database server user", 'dbpassword=s' => "Database server password", 'dbname=s' => "Database name", 'dbtable=s' => "Table containing resource ids")); $fileReader = new Tools_Migration_Acl_Db_FileReader(); $map = $fileReader->extractData($options->getOption('file')); $dbAdapterFactory = new Tools_Migration_Acl_Db_Adapter_Factory(); $dbAdapter = $dbAdapterFactory->getAdapter($dbConfig = array('host' => $options->getOption('dbhost'), 'username' => $options->getOption('dbuser'), 'password' => $options->getOption('dbpassword'), 'dbname' => $options->getOption('dbname')), $options->getOption('dbprovider')); $loggerFactory = new Tools_Migration_Acl_Db_Logger_Factory(); $logger = $loggerFactory->getLogger($options->getOption('output'), $defaultReportFile); $writer = new Tools_Migration_Acl_Db_Writer($dbAdapter, $options->getOption('dbtable')); $reader = new Tools_Migration_Acl_Db_Reader($dbAdapter, $options->getOption('dbtable')); $updater = new Tools_Migration_Acl_Db_Updater($reader, $writer, $logger, $options->getOption('mode')); $updater->migrate($map); $logger->report(); } catch (Zend_Console_Getopt_Exception $e) {
protected function _getMethod($code, $config, $store = null) { if (isset(self::$_methods[$code])) { return self::$_methods[$code]; } if (empty($config['model'])) { return false; } $modelName = $config['model']; $className = Mage::getConfig()->getModelClassName($modelName); if (!Magento_Autoload::getInstance()->classExists($className)) { return false; } $method = Mage::getModel($modelName); $method->setId($code)->setStore($store); self::$_methods[$code] = $method; return self::$_methods[$code]; }