本文整理汇总了PHP中Akeeba\Engine\Factory::getFactoryStorage方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getFactoryStorage方法的具体用法?PHP Factory::getFactoryStorage怎么用?PHP Factory::getFactoryStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akeeba\Engine\Factory
的用法示例。
在下文中一共展示了Factory::getFactoryStorage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepare
/**
* Implements the _prepare abstract method
*
* @return void
*/
protected function _prepare()
{
// Load parameters (description and comment)
$jpskey = '';
$angiekey = '';
if (!empty($this->_parametersArray)) {
$params = $this->_parametersArray;
if (isset($params['description'])) {
$this->description = $params['description'];
}
if (isset($params['comment'])) {
$this->comment = $params['comment'];
}
if (isset($params['jpskey'])) {
$jpskey = $params['jpskey'];
}
if (isset($params['angiekey'])) {
$angiekey = $params['angiekey'];
}
}
// Load configuration -- No. This is already done by the model. Doing it again removes all overrides.
// Platform::getInstance()->load_configuration();
// Initialize counters
$registry = Factory::getConfiguration();
if (!empty($jpskey)) {
$registry->set('engine.archiver.jps.key', $jpskey);
}
if (!empty($angiekey)) {
$registry->set('engine.installer.angie.key', $angiekey);
}
// Initialize temporary storage
Factory::getFactoryStorage()->reset();
// Force load the tag -- do not delete!
$kettenrad = Factory::getKettenrad();
$tag = $kettenrad->getTag();
// Yes, this is an unused variable by we MUST run this method. DO NOT DELETE.
// Push the comment and description in temp vars for use in the installer phase
$registry->set('volatile.core.description', $this->description);
$registry->set('volatile.core.comment', $this->comment);
$this->setState('prepared');
}
示例2: _finalize
protected function _finalize()
{
// Open the log
$logTag = $this->getLogTag();
Factory::getLog()->open($logTag);
if (!static::$registeredErrorHandler) {
static::$registeredErrorHandler = true;
set_error_handler('\\Akeeba\\Engine\\Core\\akeebaBackupErrorHandler');
}
// Kill the cached array
$this->array_cache = null;
// Remove the memory file
$tempVarsTag = $this->tag . (empty($this->backup_id) ? '' : '.' . $this->backup_id);
Factory::getFactoryStorage()->reset($tempVarsTag);
// All done.
Factory::getLog()->log(LogLevel::DEBUG, "Kettenrad :: Just finished");
$this->setState('finished');
//restore_error_handler();
}
示例3: _finalize
protected function _finalize()
{
// Open the log
$logTag = $this->getLogTag();
Factory::getLog()->open($logTag);
if (!static::$registeredErrorHandler) {
static::$registeredErrorHandler = true;
set_error_handler('\\Akeeba\\Engine\\Core\\akeebaBackupErrorHandler');
}
// Kill the cached array
$this->array_cache = null;
// Remove the memory file
$tempVarsTag = $this->tag . (empty($this->backup_id) ? '' : '.' . $this->backup_id);
Factory::getFactoryStorage()->reset($tempVarsTag);
// All done.
Factory::getLog()->log(LogLevel::DEBUG, "Kettenrad :: Just finished");
$this->setState('finished');
// Send a push message to mark the end of backup
$pushSubjectKey = $this->warnings_issued ? 'COM_AKEEBA_PUSH_ENDBACKUP_WARNINGS_SUBJECT' : 'COM_AKEEBA_PUSH_ENDBACKUP_SUCCESS_SUBJECT';
$pushBodyKey = $this->warnings_issued ? 'COM_AKEEBA_PUSH_ENDBACKUP_WARNINGS_BODY' : 'COM_AKEEBA_PUSH_ENDBACKUP_SUCCESS_BODY';
$platform = Platform::getInstance();
$timeStamp = date($platform->translate('DATE_FORMAT_LC2'));
$pushSubject = sprintf($platform->translate($pushSubjectKey), $platform->get_site_name(), $platform->get_host());
$pushDetails = sprintf($platform->translate($pushBodyKey), $platform->get_site_name(), $platform->get_host(), $timeStamp);
Factory::getPush()->message($pushSubject, $pushDetails);
//restore_error_handler();
}
示例4: _apiStepBackup
private function _apiStepBackup($config)
{
$defConfig = array('profile' => null, 'tag' => AKEEBA_BACKUP_ORIGIN, 'backupid' => null);
$config = array_merge($defConfig, $config);
$profile = $config['profile'];
$tag = $config['tag'];
$backupid = $config['backupid'];
// Try to set the profile from the setup parameters
if (!empty($profile)) {
$registry = Factory::getConfiguration();
$session = JFactory::getSession();
$session->set('profile', $profile, 'akeeba');
}
Factory::loadState($tag, $backupid);
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupid);
$registry = Factory::getConfiguration();
$session = JFactory::getSession();
$session->set('profile', $registry->activeProfile, 'akeeba');
$array = $kettenrad->tick();
$ret_array = $kettenrad->getStatusArray();
$array['Progress'] = $ret_array['Progress'];
try {
Factory::saveState(AKEEBA_BACKUP_ORIGIN, $backupid);
} catch (\RuntimeException $e) {
$array['Error'] = $e->getMessage();
}
if ($array['Error'] != '') {
// A backup error had occurred. Why are we here?!
$this->status = self::STATUS_ERROR;
$this->encapsulation = self::ENCAPSULATION_RAW;
return 'A backup error had occurred: ' . $array['Error'];
} elseif ($array['HasRun'] == false) {
Factory::nuke();
Factory::getFactoryStorage()->reset();
} else {
$statistics = Factory::getStatistics();
$array['BackupID'] = $statistics->getId();
}
return $array;
}
示例5: step
public function step()
{
// Check permissions
$this->_checkPermissions();
// Set the profile
$this->_setProfile();
// Get the backup ID
$backupId = $this->input->get('backupid', null, 'raw', 2);
if (empty($backupId)) {
$backupId = null;
}
Factory::loadState(AKEEBA_BACKUP_ORIGIN, $backupId);
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
$kettenrad->tick();
$array = $kettenrad->getStatusArray();
$kettenrad->resetWarnings();
// So as not to have duplicate warnings reports
try {
Factory::saveState(AKEEBA_BACKUP_ORIGIN, $backupId);
} catch (\RuntimeException $e) {
$array['Error'] = $e->getMessage();
}
if ($array['Error'] != '') {
@ob_end_clean();
echo '500 ERROR -- ' . $array['Error'];
flush();
JFactory::getApplication()->close();
} elseif ($array['HasRun'] == 1) {
// All done
Factory::nuke();
Factory::getFactoryStorage()->reset();
@ob_end_clean();
header('Content-type: text/plain');
header('Connection: close');
echo '200 OK';
flush();
JFactory::getApplication()->close();
} else {
$noredirect = $this->input->get('noredirect', 0, 'int');
if ($noredirect != 0) {
@ob_end_clean();
header('Content-type: text/plain');
header('Connection: close');
echo "301 More work required";
flush();
JFactory::getApplication()->close();
} else {
$curUri = JUri::getInstance();
$ssl = $curUri->isSSL() ? 1 : 0;
$tempURL = JRoute::_('index.php?option=com_akeeba', false, $ssl);
$uri = new JUri($tempURL);
$uri->setVar('view', 'backup');
$uri->setVar('task', 'step');
$uri->setVar('key', $this->input->get('key', '', 'none', 2));
$uri->setVar('profile', $this->input->get('profile', 1, 'int'));
if (!empty($backupId)) {
$uri->setVar('backupid', $backupId);
}
// Maybe we have a multilingual site?
$lg = F0FPlatform::getInstance()->getLanguage();
$languageTag = $lg->getTag();
$uri->setVar('lang', $languageTag);
$redirectionUrl = $uri->toString();
$this->_customRedirect($redirectionUrl);
}
}
}
示例6: runBackup
/**
* Starts or step a backup process
*
* @return array An Akeeba Engine return array
*/
public function runBackup()
{
$ret_array = array();
$ajaxTask = $this->getState('ajax');
$tag = $this->getState('tag');
$backupId = $this->getState('backupid');
switch ($ajaxTask) {
// Start a new backup
case 'start':
// Description is passed through a strict filter which removes HTML
$description = $this->getState('description');
// The comment is passed through the Safe HTML filter (note: use 2 to force no filtering)
$comment = $this->getState('comment');
$jpskey = $this->getState('jpskey');
$angiekey = $this->getState('angiekey');
if (is_null($backupId)) {
$db = $this->getDbo();
$query = $db->getQuery(true)->select('MAX(' . $db->qn('id') . ')')->from($db->qn('#__ak_stats'));
try {
$maxId = $db->setQuery($query)->loadResult();
} catch (Exception $e) {
$maxId = 0;
}
$backupId = 'id' . ($maxId + 1);
}
// Try resetting the engine
Factory::resetState(array('maxrun' => 0));
// Remove any stale memory files left over from the previous step
if (empty($tag)) {
$tag = Platform::getInstance()->get_backup_origin();
}
$tempVarsTag = $tag;
$tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
Factory::getFactoryStorage()->reset($tempVarsTag);
Factory::loadState($tag, $backupId);
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
$options = array('description' => $description, 'comment' => $comment, 'jpskey' => $jpskey, 'angiekey' => $angiekey);
$kettenrad->setup($options);
$kettenrad->tick();
$ret_array = $kettenrad->getStatusArray();
$kettenrad->resetWarnings();
// So as not to have duplicate warnings reports
try {
Factory::saveState($tag, $backupId);
} catch (\RuntimeException $e) {
$ret_array['Error'] = $e->getMessage();
}
break;
// Step through a backup
// Step through a backup
case 'step':
Factory::loadState($tag, $backupId);
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
$kettenrad->tick();
$ret_array = $kettenrad->getStatusArray();
$kettenrad->resetWarnings();
// So as not to have duplicate warnings reports
try {
Factory::saveState($tag, $backupId);
} catch (\RuntimeException $e) {
$ret_array['Error'] = $e->getMessage();
}
if ($ret_array['HasRun'] == 1) {
// Clean up
Factory::nuke();
$tempVarsTag = $tag;
$tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
Factory::getFactoryStorage()->reset($tempVarsTag);
}
break;
// Send a push notification for backup failure
// Send a push notification for backup failure
case 'pushFail':
Factory::loadState($tag, $backupId);
$errorMessage = $this->getState('errorMessage');
$platform = Platform::getInstance();
$pushSubject = sprintf($platform->translate('COM_AKEEBA_PUSH_ENDBACKUP_FAIL_SUBJECT'), $platform->get_site_name(), $platform->get_host());
$key = empty($errorMessage) ? 'COM_AKEEBA_PUSH_ENDBACKUP_FAIL_BODY' : 'COM_AKEEBA_PUSH_ENDBACKUP_FAIL_BODY_WITH_MESSAGE';
$pushDetails = sprintf($platform->translate($key), $platform->get_site_name(), $platform->get_host(), $errorMessage);
Factory::getPush()->message($pushSubject, $pushDetails);
break;
default:
break;
}
return $ret_array;
}
示例7: runBackup
/**
* Starts or step a backup process
*
* @return array An Akeeba Engine return array
*/
public function runBackup()
{
$ret_array = array();
$ajaxTask = $this->getState('ajax');
$tag = $this->getState('tag');
$backupId = $this->getState('backupid');
switch ($ajaxTask) {
case 'start':
// Description is passed through a strict filter which removes HTML
$description = $this->getState('description');
// The comment is passed through the Safe HTML filter (note: use 2 to force no filtering)
$comment = $this->getState('comment');
$jpskey = $this->getState('jpskey');
$angiekey = $this->getState('angiekey');
if (is_null($backupId)) {
$db = $this->getDbo();
$query = $db->getQuery(true)->select('MAX(' . $db->qn('id') . ')')->from($db->qn('#__ak_stats'));
try {
$maxId = $db->setQuery($query)->loadResult();
} catch (Exception $e) {
$maxId = 0;
}
$backupId = 'id' . ($maxId + 1);
}
// Try resetting the engine
Factory::resetState(array('maxrun' => 0));
// Remove any stale memory files left over from the previous step
if (empty($tag)) {
$tag = Platform::getInstance()->get_backup_origin();
}
$tempVarsTag = $tag;
$tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
Factory::getFactoryStorage()->reset($tempVarsTag);
Factory::loadState($tag, $backupId);
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
// Take care of System Restore Point setup
if ($tag == 'restorepoint') {
// Fetch the extension's version information
require_once JPATH_COMPONENT_ADMINISTRATOR . '/assets/xmlslurp/xmlslurp.php';
$slurp = new LiveUpdateXMLSlurp();
$exttype = $this->getState('type');
switch ($exttype) {
case 'component':
$extname = 'com_';
break;
case 'file':
$extname = 'file';
break;
case 'library':
$extname = 'lib_';
break;
case 'module':
$extname = 'mod_';
break;
case 'package':
$extname = 'pkg_';
break;
case 'plugin':
$extname = 'plg_';
break;
case 'template':
$extname = 'tpl_';
break;
default:
$extname = '';
break;
}
$extname .= $this->getState('name');
$info = $slurp->getInfo($extname, '');
// Get the configOverrides for this extension
$configOverrides = $this->getConfigOverridesForSRP($extname, $info);
// Create an SRP descriptor
$srpdescriptor = array('type' => $this->getState('type'), 'name' => $this->getState('name'), 'group' => $this->getState('group'), 'version' => $info['version'], 'date' => $info['date']);
// Set the description and comment
$description = "System Restore Point - " . JText::_($exttype) . ": {$extname}";
$comment = "---BEGIN SRP---\n" . json_encode($srpdescriptor) . "\n---END SRP---";
$jpskey = '';
$angiekey = '';
// Set a custom finalization action queue
$configOverrides['volatile.core.finalization.action_handlers'] = array(new Akeeba\Engine\Finalization\Srpquotas());
$configOverrides['volatile.core.finalization.action_queue'] = array('remove_temp_files', 'update_statistics', 'update_filesizes', 'apply_srp_quotas');
// Apply the configuration overrides, please
$platform = Platform::getInstance();
$platform->configOverrides = $configOverrides;
}
$options = array('description' => $description, 'comment' => $comment, 'jpskey' => $jpskey, 'angiekey' => $angiekey);
$kettenrad->setup($options);
$kettenrad->tick();
if ($kettenrad->getState() != 'running' && $tag == 'restorepoint') {
Factory::saveState($tag, $backupId);
Factory::loadState($tag, $backupId);
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
$kettenrad->tick();
//.........这里部分代码省略.........
示例8: runBackup
/**
* Starts or step a backup process
*
* @return array An Akeeba Engine return array
*/
public function runBackup()
{
$ret_array = array();
$ajaxTask = $this->getState('ajax');
$tag = $this->getState('tag');
$backupId = $this->getState('backupid');
switch ($ajaxTask) {
case 'start':
// Description is passed through a strict filter which removes HTML
$description = $this->getState('description');
// The comment is passed through the Safe HTML filter (note: use 2 to force no filtering)
$comment = $this->getState('comment');
$jpskey = $this->getState('jpskey');
$angiekey = $this->getState('angiekey');
if (is_null($backupId)) {
$db = $this->getDbo();
$query = $db->getQuery(true)->select('MAX(' . $db->qn('id') . ')')->from($db->qn('#__ak_stats'));
try {
$maxId = $db->setQuery($query)->loadResult();
} catch (Exception $e) {
$maxId = 0;
}
$backupId = 'id' . ($maxId + 1);
}
// Try resetting the engine
Factory::resetState(array('maxrun' => 0));
// Remove any stale memory files left over from the previous step
if (empty($tag)) {
$tag = Platform::getInstance()->get_backup_origin();
}
$tempVarsTag = $tag;
$tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
Factory::getFactoryStorage()->reset($tempVarsTag);
Factory::loadState($tag, $backupId);
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
$options = array('description' => $description, 'comment' => $comment, 'jpskey' => $jpskey, 'angiekey' => $angiekey);
$kettenrad->setup($options);
$kettenrad->tick();
$ret_array = $kettenrad->getStatusArray();
$kettenrad->resetWarnings();
// So as not to have duplicate warnings reports
Factory::saveState($tag, $backupId);
break;
case 'step':
Factory::loadState($tag, $backupId);
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
$kettenrad->tick();
$ret_array = $kettenrad->getStatusArray();
$kettenrad->resetWarnings();
// So as not to have duplicate warnings reports
Factory::saveState($tag, $backupId);
if ($ret_array['HasRun'] == 1) {
// Clean up
Factory::nuke();
$tempVarsTag = $tag;
$tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
Factory::getFactoryStorage()->reset($tempVarsTag);
}
break;
default:
break;
}
return $ret_array;
}
示例9: parseScanArray
private function parseScanArray($array)
{
$kettenrad = \Akeeba\Engine\Factory::getKettenrad();
$kettenrad->resetWarnings();
if ($array['HasRun'] != 1 && empty($array['Error'])) {
// Still have work to do
return array('status' => true, 'done' => false, 'error' => '');
} elseif (!empty($array['Error'])) {
// Error!
return array('status' => false, 'done' => true, 'error' => $array['Error']);
} else {
// All done
\Akeeba\Engine\Factory::getFactoryStorage()->reset(AKEEBA_BACKUP_ORIGIN);
return array('status' => true, 'done' => true, 'error' => '');
}
}
示例10: stepBackup
/**
* Steps through a backup.
*
* State variables expected (MUST be set):
* backupid The ID of the backup.
* tag The backup tag, e.g. "frontend".
* profile (optional) The profile ID of the backup.
*
* @param bool $requireBackupId Should the backup ID be required?
*
* @return array An Akeeba Engine return array
*/
public function stepBackup($requireBackupId = true)
{
// Get the tag. If not specified use the AKEEBA_BACKUP_ORIGIN constant.
$tag = $this->getState('tag', null, 'string');
if (is_null($tag) && defined('AKEEBA_BACKUP_ORIGIN')) {
$tag = AKEEBA_BACKUP_ORIGIN;
}
// Get the Backup ID. If not specified use the AKEEBA_BACKUP_ID constant.
$backupId = $this->getState('backupid', null, 'string');
if (is_null($backupId) && defined('AKEEBA_BACKUP_ID')) {
$backupId = AKEEBA_BACKUP_ID;
}
// Get the profile from the session, the AKEEBA_PROFILE constant or the model state – in this order
$session = $this->container->session;
$profile = $session->get('profile', null);
$profile = defined('AKEEBA_PROFILE') ? AKEEBA_PROFILE : $profile;
$profile = $this->getState('profile', $profile, 'int');
$profile = max(0, (int) $profile);
if (empty($profile)) {
$profile = $this->getLastBackupProfile($tag, $backupId);
}
// Set the active profile
$session->set('profile', $profile);
if (!defined('AKEEBA_PROFILE')) {
define('AKEEBA_PROFILE', $profile);
}
// Run a backup step
$ret_array = array('Error' => '');
try {
// Reload the configuration
Platform::getInstance()->load_configuration($profile);
// Load the engine from storage
Factory::loadState($tag, $backupId, $requireBackupId);
// Set the backup ID and run a backup step
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
$kettenrad->tick();
$ret_array = $kettenrad->getStatusArray();
// Prevent duplicate reporting of warnings
$kettenrad->resetWarnings();
} catch (\Exception $e) {
$ret_array['Error'] = $e->getMessage();
}
try {
if (empty($ret_array['Error']) && $ret_array['HasRun'] != 1) {
Factory::saveState($tag, $backupId);
}
} catch (\RuntimeException $e) {
$ret_array['Error'] = $e->getMessage();
}
if (!empty($ret_array['Error']) || $ret_array['HasRun'] == 1) {
// Clean up
Factory::nuke();
$tempVarsTag = $tag;
$tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
Factory::getFactoryStorage()->reset($tempVarsTag);
}
return $ret_array;
}
示例11: processEngineReturnArray
/**
* Used by the tasks to process Akeeba Engine's return array. Depending on the result and the component options we
* may throw text output or send an HTTP redirection header.
*
* @param array $array The return array to process
* @param string $backupId The backup ID (used to step the backup process)
*/
private function processEngineReturnArray($array, $backupId)
{
if ($array['Error'] != '') {
@ob_end_clean();
echo '500 ERROR -- ' . $array['Error'];
flush();
$this->container->platform->closeApplication();
}
if ($array['HasRun'] == 1) {
// All done
Factory::nuke();
Factory::getFactoryStorage()->reset();
@ob_end_clean();
header('Content-type: text/plain');
header('Connection: close');
echo '200 OK';
flush();
$this->container->platform->closeApplication();
}
$noredirect = $this->input->get('noredirect', 0, 'int');
if ($noredirect != 0) {
@ob_end_clean();
header('Content-type: text/plain');
header('Connection: close');
echo "301 More work required -- BACKUPID ###{$backupId}###";
flush();
$this->container->platform->closeApplication();
}
$curUri = JUri::getInstance();
$ssl = $curUri->isSSL() ? 1 : 0;
$tempURL = JRoute::_('index.php?option=com_akeeba', false, $ssl);
$uri = new JUri($tempURL);
$uri->setVar('view', 'Backup');
$uri->setVar('task', 'step');
$uri->setVar('key', $this->input->get('key', '', 'none', 2));
$uri->setVar('profile', $this->input->get('profile', 1, 'int'));
if (!empty($backupId)) {
$uri->setVar('backupid', $backupId);
}
// Maybe we have a multilingual site?
$language = $this->container->platform->getLanguage();
$languageTag = $language->getTag();
$uri->setVar('lang', $languageTag);
$redirectionUrl = $uri->toString();
$this->customRedirect($redirectionUrl);
}