HOR-3275 improvement

This commit is contained in:
Roly Rudy Gutierrez Pinto
2017-05-24 11:26:13 -04:00
parent f3eaeff5bc
commit 39a18a2d96
4 changed files with 94 additions and 71 deletions

View File

@@ -122,6 +122,7 @@ class PMPluginRegistry
private $_restServiceEnabled = array();
private static $instance = null;
private static $stateSaved = null;
/**
* This function is the constructor of the PMPluginRegistry class
@@ -1946,4 +1947,28 @@ class PMPluginRegistry
}
}
/**
* Saves the state of instance, in the private property 'stateSaved'.
* Use the 'restoreState()' method to put the instance in the saved state.
*/
public static function saveState()
{
$pluginRegistry = PMPluginRegistry::getSingleton();
self::$stateSaved = $pluginRegistry->serializeInstance();
}
/**
* Restores the state of the instance that is in the private variable 'stateSaved'.
* You must save the state of the instacia with the method 'saveState()'
* before being called.
*/
public static function restoreState()
{
if (self::$stateSaved !== null) {
$pluginRegistry = PMPluginRegistry::getSingleton();
self::$instance = $pluginRegistry->unSerializeInstance(self::$stateSaved);
self::$stateSaved = null;
}
}
}