本文整理汇总了PHP中XLite::setCleanUpCacheFlag方法的典型用法代码示例。如果您正苦于以下问题:PHP XLite::setCleanUpCacheFlag方法的具体用法?PHP XLite::setCleanUpCacheFlag怎么用?PHP XLite::setCleanUpCacheFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite
的用法示例。
在下文中一共展示了XLite::setCleanUpCacheFlag方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: finalizeUpgrade
/**
* Final operations after upgrade has been completed
*
* @return void
*/
protected function finalizeUpgrade()
{
if ($this->isForce()) {
if ($this->isNextStepAvailable()) {
$target = 'installed';
$entries = \XLite\Upgrade\Cell::getInstance()->getEntries();
$this->showInfo(null, 1 < count($entries) ? static::t('Modules have been successfully installed') : static::t('Module has been successfully installed'));
if ($this->isOnlySkins()) {
$target = 'layout';
} elseif ($this->getPaymentMethodToInstall()) {
$target = 'payment_settings';
} else {
$target = 'addons_list_installed';
}
} else {
$target = 'addons_list_marketplace';
$this->showError(__FUNCTION__);
}
$this->setReturnURL($this->buildURL('upgrade', '', $this->getActionParamsCommon() + array('redirect' => $target)));
}
// Set cell status
\XLite\Upgrade\Cell::getInstance()->clear(true, false, false);
\XLite\Upgrade\Cell::getInstance()->setUpgraded(true);
// Rebuild cache
if (!($this->isForce() && $this->isOnlySkins())) {
\XLite::setCleanUpCacheFlag(true);
}
}
示例2: doActionSwitch
/**
* Switch module
*
* @return void
*/
protected function doActionSwitch()
{
$changed = false;
$data = (array) \XLite\Core\Request::getInstance()->switch;
$modules = array();
foreach ($this->getModules('switch') as $module) {
$old = !empty($data[$module->getModuleId()]['old']);
$new = !empty($data[$module->getModuleId()]['new']);
if ($old !== $new) {
$module->setEnabled(!$old);
$modules[] = $module;
$changed = true;
}
}
// Flag to rebuild cache
if ($changed) {
\XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->updateInBatch($modules);
\XLite::setCleanUpCacheFlag(true);
}
}
示例3: doActivateFreeLicense
/**
* We send the free license activation key
*
* @return void
*/
protected function doActivateFreeLicense()
{
$info = \XLite\Core\Marketplace::getInstance()->activateFreeLicense(\XLite\Core\Request::getInstance()->email);
if (\XLite\Core\Marketplace::getInstance()->getError()) {
// Marketplace returned an error
$message = \XLite\Core\Marketplace::getInstance()->getError();
if (\XLite\Core\Marketplace::ERROR_CODE_FREE_LICENSE_REGISTERED == \XLite\Core\Marketplace::getInstance()->getLastErrorCode()) {
// Free license is already registered: prepare specific error message
$message = static::t('Free license key for this email is already registered', array('email' => \XLite\Core\Request::getInstance()->email, 'url' => $this->buildURL('activate_free_license', 'resend_key', array('email' => \XLite\Core\Request::getInstance()->email))));
}
\XLite\Core\TopMessage::addError($message);
} elseif ($info && isset($info[\XLite\Core\Marketplace::XC_FREE_LICENSE_KEY])) {
// License key is successfully activated: register the key in database
$key = $info[\XLite\Core\Marketplace::XC_FREE_LICENSE_KEY][0];
// Get key value from the response field 'key' or (if empty) use default value
$keyValue = !empty($key[\XLite\Core\Marketplace::FIELD_KEY]) ? $key[\XLite\Core\Marketplace::FIELD_KEY] : \XLite\Core\Marketplace::XC_FREE_LICENSE_KEY;
\XLite\Core\Database::getRepo('\\XLite\\Model\\ModuleKey')->insert($key + array('keyValue' => $keyValue));
// Clear cache for proper installation
\XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST);
// Search for modules from non-free edition
$nonFreeModules = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getNonFreeEditionModulesList(false);
if ($nonFreeModules) {
// Try to uninstall these modules...
foreach ($nonFreeModules as $module) {
$messages = array();
$res = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->uninstallModule($module, $messages);
if ($messages) {
foreach ($messages as $message) {
$method = $res ? 'Info' : 'Error';
\XLite\Upgrade\Logger::getInstance()->{'log' . $method}($message, array(), false);
}
}
}
// Initialize rebuild cache routine as a next step
\XLite::setCleanUpCacheFlag(true);
}
\XLite\Core\TopMessage::addInfo('Free license is activated successfully');
$this->setReturnURL($this->buildURL());
} else {
\XLite\Core\TopMessage::addError('Can\'t connect to the marketplace server');
}
}
示例4: restoreDatabase
/**
* Common restore database method used by actions
*
* @param mixed $sqlFile File with SQL data for loading into database
*
* @return boolean
*/
protected function restoreDatabase($sqlFile)
{
$result = false;
// File to create temporary backup to be able rollback database
$backupSQLFile = LC_DIR_BACKUP . sprintf('sqldump.backup.%d.sql', \XLite\Core\Converter::time());
// Make the process of restoring database verbose
$verbose = true;
// Start
$this->startDump();
// Making the temporary backup file
\Includes\Utils\Operator::flush(static::t('Making backup of the current database state ... '), true);
$result = \XLite\Core\Database::getInstance()->exportSQLToFile($backupSQLFile, $verbose);
\Includes\Utils\Operator::flush(static::t('done') . LC_EOL . LC_EOL, true);
// Loading specified SQL-file to the database
\Includes\Utils\Operator::flush(static::t('Loading the database from file .'));
$result = \Includes\Utils\Database::uploadSQLFromFile($sqlFile, $verbose);
$restore = false;
if ($result) {
// If file has been loaded into database successfully
$message = static::t('Database restored successfully!');
// Prepare the cache rebuilding
\XLite::setCleanUpCacheFlag(true);
} else {
// If an error occured while loading file into database
$message = static::t('The database has not been restored because of the errors');
$restore = true;
}
// Display the result message
\Includes\Utils\Operator::flush(' ' . static::t('done') . LC_EOL . LC_EOL . $message . LC_EOL);
if ($restore) {
// Restore database from temporary backup
\Includes\Utils\Operator::flush(LC_EOL . static::t('Restoring database from the backup .'));
\Includes\Utils\Database::uploadSQLFromFile($backupSQLFile, $verbose);
\Includes\Utils\Operator::flush(' ' . static::t('done') . LC_EOL . LC_EOL);
}
// Display Javascript to cancel scrolling page to bottom
func_refresh_end();
// Display the bottom HTML part
$this->displayPageFooter();
// Remove temporary backup file
unlink($backupSQLFile);
return $result;
}
示例5: doActionRebuild
/**
* doActionRebuild
*
* @return void
*/
public function doActionRebuild()
{
\XLite::setCleanUpCacheFlag(true);
// To avoid the infinite loop
$this->setReturnURL($this->buildURL());
}
示例6: doActionInstallUpgrades
/**
* Third step: install downloaded upgrades
*
* @return void
*/
protected function doActionInstallUpgrades()
{
$this->setReturnURL($this->buildURL('upgrade'));
if (\XLite\Upgrade\Cell::getInstance()->isUnpacked()) {
\Includes\SafeMode::sendNotification();
$restorePoint = \Includes\Utils\ModulesManager::getEmptyRestorePoint();
//write current state
$current = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->findBy(array('enabled' => true));
foreach ($current as $module) {
$restorePoint['current'][$module->getModuleId()] = $module->getActualName();
}
\Includes\Utils\Operator::showMessage('Installing updates, please wait...');
if (\XLite\Core\Request::getInstance()->preUpgradeWarningModules) {
\XLite\Upgrade\Cell::getInstance()->setPreUpgradeWarningModules(array_keys(array_filter(\XLite\Core\Request::getInstance()->preUpgradeWarningModules, function ($value) {
return 0 == $value;
})));
}
// Disable selected modules
$modules = array();
foreach (\XLite\Upgrade\Cell::getInstance()->getIncompatibleModules(true) as $module) {
$module->setEnabled(false);
$modules[] = $module;
$restorePoint['disabled'][$module->getModuleId()] = $module->getActualName();
}
\XLite\Core\Database::getRepo('XLite\\Model\\Module')->updateInBatch($modules);
// Do actions according the admin choice for the disabled modules with hooks
$modulesToEnable = array();
/** @var \XLite\Model\Module $module */
foreach (\XLite\Upgrade\Cell::getInstance()->getDisabledModulesHooks() as $marketplaceId => $module) {
$action = \XLite\Core\Request::getInstance()->disabledModulesHooks[$marketplaceId];
$module = \XLite\Core\Database::getEM()->merge($module);
if (1 == $action) {
// Enable module
$module->setEnabled(true);
$modulesToEnable[] = $module;
$restorePoint['enabled'][$module->getModuleId()] = $module->getActualName();
} elseif (0 == $action) {
// Uninstall module
\XLite\Upgrade\Cell::getInstance()->removeModuleEntry($module);
$this->uninstallModule($module);
$restorePoint['deleted'][] = $module->getActualName();
}
}
\XLite\Core\Database::getRepo('XLite\\Model\\Module')->updateInBatch($modulesToEnable);
if (\XLite\Upgrade\Cell::getInstance()->getEntries()) {
foreach (\XLite\Upgrade\Cell::getInstance()->getEntries() as $module) {
$restorePoint['installed'][] = $module->getActualName();
}
// Perform upgrade
// pre_upgrade / post_upgrade hooks will be proceeded here
$this->runStep('upgrade', array(false, $this->getFilesToOverWrite()));
if ($this->isForce()) {
if ($this->isNextStepAvailable()) {
$target = 'installed';
$this->showInfo(null, 1 < count($modules) ? static::t('Modules have been successfully installed') : static::t('Module has been successfully installed'));
if ($this->isOnlySkins()) {
$target = 'layout';
} elseif ($this->getPaymentMethodToInstall()) {
$target = 'payment_settings';
} else {
$target = 'addons_list_installed';
}
} else {
$target = 'addons_list_marketplace';
$this->showError(__FUNCTION__);
}
$this->setReturnURL($this->buildURL('upgrade', '', $this->getActionParamsCommon() + array('redirect' => $target)));
}
} else {
// All modules for upgrade were set for uninstallation
// There are no upgrade procedures to perform
\XLite\Core\Marketplace::getInstance()->clearActionCache();
$this->setReturnURL($this->buildURL('addons_list_installed'));
}
// Set cell status
\XLite\Upgrade\Cell::getInstance()->clear(true, false, false);
\XLite\Upgrade\Cell::getInstance()->setUpgraded(true);
\Includes\Utils\ModulesManager::updateModuleMigrationLog($restorePoint);
// Rebuild cache
if (!($this->isForce() && $this->isOnlySkins())) {
\XLite::setCleanUpCacheFlag(true);
}
} else {
$this->showWarning(__FUNCTION__, static::t('unable to install: not all archives were unpacked. Please, try again', array('list' => $this->getErrorEntriesHTML())));
}
}
示例7: doActionRegisterKey
/**
* Action of license key registration
*
* @return void
*/
protected function doActionRegisterKey()
{
$key = \XLite\Core\Request::getInstance()->key;
if ($key) {
$keysInfo = \XLite\Core\Marketplace::getInstance()->checkAddonKey($key);
} else {
$keysInfo = null;
$emptyKey = true;
}
$this->setReturnURL($this->buildURL('addons_list_marketplace'));
if ($keysInfo && $keysInfo[$key]) {
$keysInfo = $keysInfo[$key];
$repo = \XLite\Core\Database::getRepo('\\XLite\\Model\\ModuleKey');
foreach ($keysInfo as $info) {
if (\XLite\Model\ModuleKey::KEY_TYPE_XCN == $info['keyType']) {
$xcnPlan = $info['xcnPlan'];
$keyData = $info['keyData'];
// Unset some fields which is not in database
unset($info['xcnPlan']);
unset($info['keyData']);
unset($info['key']);
$entity = $repo->findOneBy($info);
if (!$entity) {
$entity = new \XLite\Model\ModuleKey();
$entity->map($info);
}
$entity->setKeyValue($key);
$entity->setXcnPlan($xcnPlan);
$entity->setKeyData($keyData);
if (!empty($keyData['wave'])) {
$this->updateUpgradeWaveOption($keyData['wave']);
}
$isValid = true;
if (\XLite::isFreeLicense($entity)) {
if (0 == \XLite\Core\Database::getRepo('XLite\\Model\\Module')->hasMarketplaceModules(true)) {
$isValid = false;
$this->showError(__FUNCTION__, static::t('Cannot gather modules from the marketplace. Please try later.'));
}
}
if ($isValid) {
// Save entity (key) in the database
\XLite\Core\Database::getEM()->persist($entity);
\XLite\Core\Database::getEM()->flush();
if (\XLite::isFreeLicense()) {
// Search for modules from non-free edition
$nonFreeModules = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getNonFreeEditionModulesList(false);
if ($nonFreeModules) {
// Try to uninstall these modules...
foreach ($nonFreeModules as $module) {
$messages = array();
$res = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->uninstallModule($module, $messages);
if ($messages) {
foreach ($messages as $message) {
$method = $res ? 'Info' : 'Error';
\XLite\Upgrade\Logger::getInstance()->{'log' . $method}($message, array(), false);
}
}
}
}
\XLite::setCleanUpCacheFlag(true);
}
if (empty($keyData['message'])) {
$this->showInfo(__FUNCTION__, static::t('X-Cart license key has been successfully verified'));
} else {
$this->showWarning(__FUNCTION__, static::t('X-Cart license key has been successfully verified and activated. But this key has expired and do not allow upgrade store.'));
}
// Clear cache for proper installation
\XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST);
$this->setHardRedirect();
}
} else {
$keyData = $info['keyData'];
$module = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->findOneBy(array('author' => $info['author'], 'name' => $info['name']));
if ($module) {
$entity = $repo->findKey($info['author'], $info['name']);
if ($entity) {
$entity->setKeyValue($key);
$repo->update($entity);
} else {
$entity = $repo->insert($info + array('keyValue' => $key));
}
if (!empty($keyData['wave'])) {
$this->updateUpgradeWaveOption($keyData['wave']);
}
// Clear cache for proper installation
\XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST);
if (empty($keyData['message'])) {
$this->showInfo(__FUNCTION__, static::t('License key has been successfully verified for "{{name}}" module by "{{author}}" author', array('name' => $module->getModuleName(), 'author' => $module->getAuthorName())));
} else {
$this->showWarning(__FUNCTION__, static::t('License key has been successfully verified and activated for "{{name}}" module by "{{author}}" author. But this key has expired and do not allow upgrade store.', array('name' => $module->getModuleName(), 'author' => $module->getAuthorName())));
}
// We install the addon after the successfull key verification
$this->setReturnURL($this->buildURL('upgrade', 'install_addon_force', array('moduleIds[]' => $module->getModuleID(), 'agree' => 'Y')));
} else {
$this->showError(__FUNCTION__, static::t('Key is validated, but the module X was not found', array('module' => implode(',', $info))));
//.........这里部分代码省略.........
示例8: doActionSwitch
//.........这里部分代码省略.........
unset($data[$module->getModuleId()]);
unset($switchModules[$key]);
break;
}
}
}
}
} elseif ($toEnable) {
// Get the list of modules which current module depends on
$list = $this->getAllDisabledModuleDependencies($module);
if ($list) {
foreach ($list as $m) {
if (empty($data[$m->getModuleId()]) || empty($data[$m->getModuleId()]['delete']) && empty($data[$m->getModuleId()]['new'])) {
$data[$m->getModuleId()] = array('old' => 0, 'new' => 1);
$additionalSwitchModules[$m->getModuleId()] = $m;
}
}
} elseif (false === $list) {
// Remove current module from the actions list as it can't be enabled
$excludedEnableModules[] = $module->getModuleName();
unset($data[$module->getModuleId()]);
}
}
}
if ($excludedModules) {
\XLite\Core\TopMessage::addWarning('The following selected modules cannot be disabled or uninstalled as they have dependent modules', array('list' => implode(', ', $excludedModules)));
// Selection has excluded modules - this is a critical case, break an entire operation
return;
}
if ($excludedEnableModules) {
\XLite\Core\TopMessage::addWarning('The following selected modules cannot be enabled as they depend on disabled modules which cannot be enabled', array('list' => implode(', ', $excludedEnableModules)));
// Selection has excluded modules - this is a critical case, break an entire operation
return;
}
if (!empty($additionalSwitchModules)) {
// Extend $switchModules list by additional modules
foreach ($additionalSwitchModules as $k => $am) {
if (!in_array($k, $switchModulesKeys)) {
$switchModules[] = $am;
}
}
}
foreach ($switchModules as $module) {
if (!empty($data[$module->getModuleId()]['delete'])) {
$old = $new = null;
$delete = true;
} else {
$old = !empty($data[$module->getModuleId()]['old']);
$new = !empty($data[$module->getModuleId()]['new']);
$delete = false;
}
if ($delete) {
// Uninstall module
if ($module->getEnabled()) {
$module->setEnabled(false);
$module->callModuleMethod('callDisableEvent');
}
if (!defined('LC_MODULE_CONTROL')) {
define('LC_MODULE_CONTROL', true);
}
if ($this->uninstallModule($module)) {
$deleted = true;
$restorePoint['deleted'][] = $module->getActualName();
}
} elseif ($old !== $new) {
// Change module status
$module->setEnabled($new);
// Call disable event to make some module specific changes
if ($old) {
$module->callModuleMethod('callDisableEvent');
} elseif (is_null($firstModule)) {
$firstModule = $module;
}
if ($new) {
$restorePoint['enabled'][$module->getModuleId()] = $module->getActualName();
} else {
$restorePoint['disabled'][$module->getModuleId()] = $module->getActualName();
}
$modules[] = $module;
$changed = true;
}
}
// Flag to rebuild cache
if ($changed) {
// We redirect the admin to the modules page on the activated module anchor
// The first module in a batch which is available now
\XLite\Core\Session::getInstance()->returnURL = $firstModule ? $this->getModulePageURL($firstModule) : (\XLite\Core\Request::getInstance()->return ?: '');
\XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->updateInBatch($modules);
}
if ($deleted) {
// Refresh marketplace modules cache
\XLite\Core\Marketplace::getInstance()->saveAddonsList(0);
\XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_CHECK_FOR_UPDATES);
}
if ($changed || $deleted) {
// Flag to rebuild classes cache
\XLite::setCleanUpCacheFlag(true);
}
\Includes\Utils\ModulesManager::updateModuleMigrationLog($restorePoint);
}