本文整理汇总了PHP中Mage_Core_Model_Resource_Setup::applyAllDataUpdates方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Resource_Setup::applyAllDataUpdates方法的具体用法?PHP Mage_Core_Model_Resource_Setup::applyAllDataUpdates怎么用?PHP Mage_Core_Model_Resource_Setup::applyAllDataUpdates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Resource_Setup
的用法示例。
在下文中一共展示了Mage_Core_Model_Resource_Setup::applyAllDataUpdates方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testApplyAllDataUpdates
/**
* @covers Mage_Core_Model_Resource_Setup::applyAllUpdates
* @covers Mage_Core_Model_Resource_Setup::applyAllDataUpdates
*/
public function testApplyAllDataUpdates()
{
/*reset versions*/
Mage::getResourceModel('Mage_Core_Model_Resource_Resource')->setDbVersion('adminnotification_setup', false);
Mage::getResourceModel('Mage_Core_Model_Resource_Resource')->setDataVersion('adminnotification_setup', false);
$this->_model->deleteTableRow('core_resource', 'code', 'adminnotification_setup');
$this->_model->getConnection()->dropTable($this->_model->getTable('adminnotification_inbox'));
try {
$this->_model->applyAllUpdates();
$this->_model->applyAllDataUpdates();
} catch (Exception $e) {
$this->fail("Impossible to continue other tests, because database is broken: {$e}");
}
$this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'version'));
$this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'data_version'));
}
示例2: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getApplication()->setAutoExit(false);
$this->detectMagento($output);
if (!$this->initMagento()) {
return;
}
try {
if (false === $input->getOption('no-implicit-cache-flush')) {
$this->flushCache();
}
/**
* Put output in buffer. \Mage_Core_Model_Resource_Setup::_modifyResourceDb should print any error
* directly to stdout. Use execption which will be thrown to show error
*/
\ob_start();
\Mage_Core_Model_Resource_Setup::applyAllUpdates();
if (is_callable(array('\\Mage_Core_Model_Resource_Setup', 'applyAllDataUpdates'))) {
\Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
}
\ob_end_clean();
$output->writeln('<info>done</info>');
} catch (Exception $e) {
\ob_end_clean();
$this->printException($output, $e);
$this->printStackTrace($output, $e->getTrace());
$this->printFile($output, $e);
return 1;
// exit with error status
}
}
示例3: execute
public function execute()
{
Mage::app('admin');
\Mage_Core_Model_Resource_Setup::applyAllUpdates();
\Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
try {
$this->setup();
} catch (Exception $e) {
$msg .= $e->getMessage() . ' (' . $e->getFile() . ' l. ' . $e->getLine() . ")\n";
Logger::error('An error occured while initializing InitGermanSetup:', array(), false);
Logger::log('%s (%s, line %s)', array($e->getMessage(), $e->getFile(), $e->getLine()));
}
}
示例4: execute
/**
* @see vendor/symfony/src/Symfony/Component/Console/Command/Symfony\Component\Console\Command.Command::execute()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->preExecute($input, $output);
$this->createExtensionFolder();
foreach ($this->config->getExtensions() as $name => $extension) {
$this->installExtension($name, $extension);
}
$this->initMagento();
\Mage_Core_Model_Resource_Setup::applyAllUpdates();
\Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
\Mage::getModel('core/cache')->flush();
Logger::notice('Done');
}
示例5: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getApplication()->setAutoExit(false);
$this->detectMagento($output);
if ($this->initMagento()) {
try {
/**
* Get events before cache flush command is called.
*/
$reflectionApp = new \ReflectionObject(\Mage::app());
$appEventReflectionProperty = $reflectionApp->getProperty('_events');
$appEventReflectionProperty->setAccessible(true);
$eventsBeforeCacheFlush = $appEventReflectionProperty->getValue(\Mage::app());
$this->getApplication()->run(new StringInput('cache:flush'), new NullOutput());
/**
* Restore initially loaded events which was reset during setup script run
*/
$appEventReflectionProperty->setValue(\Mage::app(), $eventsBeforeCacheFlush);
/**
* Put output in buffer. \Mage_Core_Model_Resource_Setup::_modifyResourceDb should print any error
* directly to stdout. Use execption which will be thrown to show error
*/
\ob_start();
\Mage_Core_Model_Resource_Setup::applyAllUpdates();
if (is_callable(array('\\Mage_Core_Model_Resource_Setup', 'applyAllDataUpdates'))) {
\Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
}
\ob_end_clean();
$output->writeln('<info>done</info>');
} catch (\Exception $e) {
\ob_end_clean();
$this->printException($output, $e);
$this->printStackTrace($output, $e->getTrace());
$this->printFile($output, $e);
return 1;
// exit with error status
}
}
return 0;
}
示例6: cleanCache
protected function cleanCache()
{
$result = true;
$message = '';
try {
if ($this->isInstalled()) {
if (!empty($_REQUEST['clean_sessions'])) {
Mage::app()->cleanAllSessions();
$message .= 'Session cleaned successfully. ';
}
Mage::app()->cleanCache();
// reinit config and apply all updates
Mage::app()->getConfig()->reinit();
Mage_Core_Model_Resource_Setup::applyAllUpdates();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
$message .= 'Cache cleaned successfully';
} else {
$result = true;
}
} catch (Exception $e) {
$result = false;
$message = "Exception during cache and session cleaning: " . $e->getMessage();
$this->session()->addMessage('error', $message);
}
if ($result && $this->_getMaintenanceFlag()) {
$maintenance_filename = 'maintenance.flag';
$config = $this->config();
if (!$this->isWritable() && strlen($config->__get('remote_config')) > 0) {
$ftpObj = new Mage_Connect_Ftp();
$ftpObj->connect($config->__get('remote_config'));
$ftpObj->delete($maintenance_filename);
$ftpObj->close();
} else {
@unlink($this->_getMaintenanceFilePath());
}
}
return array('result' => $result, 'message' => $message);
}
示例7: install
/**
* Install Magento
*
* @param array $options
* @return string|boolean
*/
public function install(array $options)
{
try {
$options = $this->_getInstallOptions($options);
if (!$options) {
return false;
}
/**
* Check if already installed
*/
if (Mage::isInstalled()) {
$this->addError('ERROR: Magento is already installed.');
return false;
}
/**
* Skip URL validation, if set
*/
$this->_getDataModel()->setSkipUrlValidation($options['skip_url_validation']);
$this->_getDataModel()->setSkipBaseUrlValidation($options['skip_url_validation']);
/**
* Locale settings
*/
$this->_getDataModel()->setLocaleData(array('locale' => $options['locale'], 'timezone' => $options['timezone'], 'currency' => $options['default_currency']));
/**
* Database and web config
*/
$this->_getDataModel()->setConfigData(array('db_model' => $options['db_model'], 'db_host' => $options['db_host'], 'db_name' => $options['db_name'], 'db_user' => $options['db_user'], 'db_pass' => $options['db_pass'], 'db_prefix' => $options['db_prefix'], 'use_rewrites' => $this->_getFlagValue($options['use_rewrites']), 'use_secure' => $this->_getFlagValue($options['use_secure']), 'unsecure_base_url' => $options['url'], 'secure_base_url' => $options['secure_base_url'], 'use_secure_admin' => $this->_getFlagValue($options['use_secure_admin']), 'session_save' => $this->_checkSessionSave($options['session_save']), 'backend_frontname' => $this->_checkBackendFrontname($options['backend_frontname']), 'admin_no_form_key' => $this->_getFlagValue($options['admin_no_form_key']), 'skip_url_validation' => $this->_getFlagValue($options['skip_url_validation']), 'enable_charts' => $this->_getFlagValue($options['enable_charts']), 'order_increment_prefix' => $options['order_increment_prefix']));
/**
* Primary admin user
*/
$this->_getDataModel()->setAdminData(array('firstname' => $options['admin_firstname'], 'lastname' => $options['admin_lastname'], 'email' => $options['admin_email'], 'username' => $options['admin_username'], 'new_password' => $options['admin_password']));
$installer = $this->_getInstaller();
/**
* Install configuration
*/
$installer->installConfig($this->_getDataModel()->getConfigData());
if (!empty($options['cleanup_database'])) {
$this->_cleanUpDatabase();
}
if ($this->hasErrors()) {
return false;
}
/**
* Install database
*/
$installer->installDb();
if ($this->hasErrors()) {
return false;
}
// apply data updates
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
/**
* Validate entered data for administrator user
*/
$user = $installer->validateAndPrepareAdministrator($this->_getDataModel()->getAdminData());
if ($this->hasErrors()) {
return false;
}
/**
* Prepare encryption key and validate it
*/
$encryptionKey = empty($options['encryption_key']) ? $this->generateEncryptionKey() : $options['encryption_key'];
$this->_getDataModel()->setEncryptionKey($encryptionKey);
$installer->validateEncryptionKey($encryptionKey);
if ($this->hasErrors()) {
return false;
}
/**
* Create primary administrator user
*/
$installer->createAdministrator($user);
if ($this->hasErrors()) {
return false;
}
/**
* Save encryption key or create if empty
*/
$installer->installEnryptionKey($encryptionKey);
if ($this->hasErrors()) {
return false;
}
/**
* Installation finish
*/
$installer->finish();
if ($this->hasErrors()) {
return false;
}
/**
* Change directories mode to be writable by apache user
*/
$this->_filesystem->changePermissions(Mage::getBaseDir('var'), 0777, true);
return $encryptionKey;
} catch (Exception $e) {
//.........这里部分代码省略.........
示例8: run
/**
* Run application. Run process responsible for request processing and sending response.
* List of supported parameters:
* scope_code - code of default scope (website/store_group/store code)
* scope_type - type of default scope (website/group/store)
* options - configuration options
*
* @param array $params application run parameters
* @return Mage_Core_Model_App
*/
public function run($params)
{
$options = isset($params['options']) ? $params['options'] : array();
$this->baseInit($options);
Mage::register('application_params', $params);
if ($this->_cache->processRequest()) {
$this->getResponse()->sendResponse();
} else {
$this->_initModules();
$this->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
if ($this->_config->isLocalConfigLoaded()) {
$scopeCode = isset($params['scope_code']) ? $params['scope_code'] : '';
$scopeType = isset($params['scope_type']) ? $params['scope_type'] : 'store';
$this->_initCurrentStore($scopeCode, $scopeType);
$this->_initRequest();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
}
$this->getFrontController()->dispatch();
}
return $this;
}
示例9: install
/**
* Install Magento
*
* @return boolean
*/
public function install()
{
try {
/**
* Check if already installed
*/
if (Mage::isInstalled()) {
$this->addError('ERROR: Magento is already installed');
return false;
}
/**
* Skip URL validation, if set
*/
$this->_getDataModel()->setSkipUrlValidation($this->_args['skip_url_validation']);
$this->_getDataModel()->setSkipBaseUrlValidation($this->_args['skip_url_validation']);
/**
* Prepare data
*/
$this->_prepareData();
if ($this->hasErrors()) {
return false;
}
$installer = $this->_getInstaller();
/**
* Install configuration
*/
$installer->installConfig($this->_getDataModel()->getConfigData());
if ($this->hasErrors()) {
return false;
}
/**
* Reinitialize configuration (to use new config data)
*/
$this->_app->cleanCache();
Mage::getConfig()->reinit();
/**
* Install database
*/
$installer->installDb();
if ($this->hasErrors()) {
return false;
}
// apply data updates
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
/**
* Validate entered data for administrator user
*/
$user = $installer->validateAndPrepareAdministrator($this->_getDataModel()->getAdminData());
if ($this->hasErrors()) {
return false;
}
/**
* Prepare encryption key and validate it
*/
$encryptionKey = empty($this->_args['encryption_key']) ? md5(Mage::helper('core')->getRandomString(10)) : $this->_args['encryption_key'];
$this->_getDataModel()->setEncryptionKey($encryptionKey);
$installer->validateEncryptionKey($encryptionKey);
if ($this->hasErrors()) {
return false;
}
/**
* Create primary administrator user
*/
$installer->createAdministrator($user);
if ($this->hasErrors()) {
return false;
}
/**
* Save encryption key or create if empty
*/
$installer->installEnryptionKey($encryptionKey);
if ($this->hasErrors()) {
return false;
}
/**
* Installation finish
*/
$installer->finish();
if ($this->hasErrors()) {
return false;
}
/**
* Change directories mode to be writable by apache user
*/
@chmod('var/cache', 0777);
@chmod('var/session', 0777);
} catch (Exception $e) {
$this->addError('ERROR: ' . $e->getMessage());
return false;
}
return true;
}
示例10: _install
/**
* Install application using temporary directory and vendor-specific database settings
*
* @throws Magento_Exception
*/
protected function _install()
{
$this->_ensureDirExists($this->_installDir);
$this->_ensureDirExists($this->_installEtcDir);
$this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'media');
$this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'theme');
/* Copy *.xml configuration files */
$dirs = array($this->_installEtcDir => $this->_globalEtcFiles, $this->_installEtcDir . '/modules' => $this->_moduleEtcFiles);
foreach ($dirs as $targetEtcDir => $sourceEtcFiles) {
$this->_ensureDirExists($targetEtcDir);
foreach ($sourceEtcFiles as $sourceEtcFile) {
$targetEtcFile = $targetEtcDir . '/' . basename($sourceEtcFile);
copy($sourceEtcFile, $targetEtcFile);
}
}
/* Make sure that local.xml contains an invalid installation date */
$installDate = (string) $this->_localXml->global->install->date;
if ($installDate && strtotime($installDate)) {
throw new Magento_Exception("Configuration file '{$this->_localXmlFile}' must contain an invalid installation date.");
}
/* Replace local.xml */
$targetLocalXml = $this->_installEtcDir . '/local.xml';
$this->_localXml->asNiceXml($targetLocalXml);
/* Initialize an application in non-installed mode */
$this->initialize();
/* Run all install and data-install scripts */
Mage_Core_Model_Resource_Setup::applyAllUpdates();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
/* Enable configuration cache by default in order to improve tests performance */
Mage::app()->getCacheInstance()->saveOptions(array('config' => 1));
/* Fill installation date in local.xml to indicate that application is installed */
$localXml = file_get_contents($targetLocalXml);
$localXml = str_replace($installDate, date('r'), $localXml, $replacementCount);
if ($replacementCount != 1) {
throw new Magento_Exception("Unable to replace installation date properly in '{$targetLocalXml}' file.");
}
file_put_contents($targetLocalXml, $localXml, LOCK_EX);
/* Add predefined admin user to the system */
$this->_createAdminUser();
/* Switch an application to installed mode */
$this->initialize();
}
示例11: _runNamedSetupResource
/**
* Runs a single named setup resource
*
* This method nukes the global/resources node in the global config
* and then repopulates it with **only** the $name resource. Then it
* calls the standard Contao `applyAllUpdates` method.
*
* The benefit of this approach is we don't need to recreate the entire
* setup resource running logic ourselves. Yay for code reuse
*
* The downside is we should probably exit quickly, as anything else that
* uses the global/resources node is going to behave weird.
*
* @todo Repopulate global config after running? Non trivial since setNode escapes strings
*
* @param string $name
* @param bool $needsUpdate
* @param string $type
* @throws \Exception
* @internal param $string
*/
protected function _runNamedSetupResource($name, $needsUpdate, $type)
{
$output = $this->_output;
if (!in_array($type, array(self::TYPE_MIGRATION_STRUCTURE, self::TYPE_MIGRATION_DATA))) {
throw new \Exception('Invalid Type [' . $type . ']: structure, data are valid');
}
if (!array_key_Exists($name, $needsUpdate)) {
$output->writeln('<error>No updates to run for ' . $name . ', skipping </error>');
return;
}
//remove all other setup resources from configuration
//(in memory, do not persist this to cache)
$realConfig = \Mage::getConfig();
$resources = $realConfig->getNode('global/resources');
foreach ($resources->children() as $resource) {
if (!$resource->setup) {
continue;
}
unset($resource->setup);
}
//recreate our specific node in <global><resources></resource></global>
//allows for theoretical multiple runs
$setupResource = $needsUpdate[$name];
$setupResourceConfig = $this->_secondConfig->getNode('global/resources/' . $name);
$moduleName = $setupResourceConfig->setup->module;
$className = $setupResourceConfig->setup->class;
$specificResource = $realConfig->getNode('global/resources/' . $name);
$setup = $specificResource->addChild('setup');
if ($moduleName) {
$setup->addChild('module', $moduleName);
} else {
$output->writeln('<error>No module node configured for ' . $name . ', possible configuration error </error>');
}
if ($className) {
$setup->addChild('class', $className);
}
//and finally, RUN THE UPDATES
try {
ob_start();
if ($type == self::TYPE_MIGRATION_STRUCTURE) {
$this->_stashEventContext();
\Mage_Core_Model_Resource_Setup::applyAllUpdates();
$this->_restoreEventContext();
} else {
if ($type == self::TYPE_MIGRATION_DATA) {
\Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
}
}
$exceptionOutput = ob_get_clean();
$this->_output->writeln($exceptionOutput);
} catch (\Exception $e) {
$exceptionOutput = ob_get_clean();
$this->_processExceptionDuringUpdate($e, $name, $setupResource, $exceptionOutput);
if ($this->_input->getOption('stop-on-error')) {
throw new \RuntimeException('Setup stopped with errors');
}
}
}
示例12: _install
/**
* Install application using temporary directory and vendor-specific database settings
*/
protected function _install()
{
$this->_ensureDirExists($this->_installDir);
$this->_ensureDirExists($this->_installEtcDir);
$this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'media');
$this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'skin');
/* Copy *.xml configuration files */
$dirs = array($this->_installEtcDir => $this->_globalEtcFiles, $this->_installEtcDir . '/modules' => $this->_moduleEtcFiles);
foreach ($dirs as $targetEtcDir => $sourceEtcFiles) {
$this->_ensureDirExists($targetEtcDir);
foreach ($sourceEtcFiles as $sourceEtcFile) {
$targetEtcFile = $targetEtcDir . '/' . basename($sourceEtcFile);
copy($sourceEtcFile, $targetEtcFile);
}
}
/* Make sure that local.xml contains an invalid installation date */
$installDate = (string) $this->_localXml->global->install->date;
if ($installDate && strtotime($installDate)) {
throw new Exception("Configuration file '{$this->_localXmlFile}' must contain an invalid installation date.");
}
/* Replace local.xml */
$targetLocalXml = $this->_installEtcDir . '/local.xml';
copy($this->_localXmlFile, $targetLocalXml);
/* Initialize an application in non-installed mode */
$this->initialize();
/* Run all install and data-install scripts */
Mage_Core_Model_Resource_Setup::applyAllUpdates();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
/* Enable configuration cache by default in order to improve tests performance */
Mage::app()->getCacheInstance()->saveOptions(array('config' => 1));
/* Fill installation date in local.xml to indicate that application is installed */
$localXml = file_get_contents($targetLocalXml);
$localXml = str_replace($installDate, date('r'), $localXml, $replacementCount);
if ($replacementCount != 1) {
throw new Exception("Unable to replace installation date properly in '{$targetLocalXml}' file.");
}
file_put_contents($targetLocalXml, $localXml, LOCK_EX);
/* Make a database backup to be able to restore it to initial state any time */
$this->_db->createBackup(self::DB_BACKUP_NAME);
/* Switch an application to installed mode */
$this->initialize();
/**
* Initialization of front controller with all routers.
* Should be here as needed only once after installation process.
*/
Mage::app()->getFrontController();
}
示例13: endInstall
/**
* End install package(s)
*
*/
public function endInstall()
{
if ($this->isInstalled()) {
try {
if (!empty($_GET['clean_sessions'])) {
Mage::app()->cleanAllSessions();
}
Mage::app()->cleanCache();
} catch (Exception $e) {
$this->session()->addMessage('error', "Exception during cache and session cleaning: " . $e->getMessage());
}
// reinit config and apply all updates
Mage::app()->getConfig()->reinit();
Mage_Core_Model_Resource_Setup::applyAllUpdates();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
}
if ($this->_getMaintenanceFlag()) {
$maintenance_filename = 'maintenance.flag';
$config = $this->config();
if (!$this->isWritable() && strlen($config->__get('remote_config')) > 0) {
$ftpObj = new Mage_Connect_Ftp();
$ftpObj->connect($config->__get('remote_config'));
$ftpObj->delete($maintenance_filename);
$ftpObj->close();
} else {
@unlink($this->_getMaintenanceFilePath());
}
}
}
示例14: initTest
/**
* Initializes test scope for PHPUnit
*
* @return Mage_PHPUnit_Model_App
*/
public function initTest()
{
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
// If garbage collector is not enabled,
// we enable it for tests
if (!gc_enabled()) {
gc_enable();
}
}
$this->_config = Mage::getConfig();
$this->_initBaseConfig();
$this->_initCache();
// Set using cache
// for things that shouldn't be reloaded each time
$this->setCacheOptions(array('eav' => 1, 'layout' => 1, 'translate' => 1));
// Clean cache before the whole suite is running
$this->getCache()->clean();
// Init modules runs install process for table structures,
// It is required for setting up proper setup script
$this->_initModules();
$this->loadAreaPart(self::AREA_GLOBAL, self::AREA_PART_EVENTS);
if ($this->_config->isLocalConfigLoaded()) {
$this->_initCurrentStore(self::ADMIN_STORE_CODE, self::RUN_TYPE_STORE);
$this->_initRequest();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
}
$layoutModel = $this->_getModelFromConfig(self::XML_PATH_LAYOUT_MODEL_FOR_TEST, self::INTERFACE_ISOLATION, 'Layout model');
$this->replaceRegistry(self::REGISTRY_PATH_LAYOUT_SINGLETON, $layoutModel);
$designPackageModel = $this->_getModelFromConfig(self::XML_PATH_DESIGN_PACKAGE_MODEL_FOR_TEST, self::INTERFACE_ISOLATION, 'Design package model');
$this->replaceRegistry(self::REGISTRY_PATH_DESIGN_PACKAGE_SINGLETON, $designPackageModel);
$this->loadAreaPart(self::AREA_TEST, self::AREA_PART_EVENTS);
$this->replaceRegistry(self::REGISTRY_PATH_SHARED_STORAGE, new Varien_Object());
return $this;
}