$applicationInstance = $this->getResolverInstance()->getApplicationInstance();
// Get a RNG instance (Random Number Generator)
+ // @TODO Rewrite this code to make use of generateRandomString() from 'hub' project
$rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
// Generate a pseudo-random string
*/
private function generateSalt () {
// Get a random string from the RNG
- $randomString = $this->getRngInstance()->randomString();
+ $randomString = $this->getRngInstance()->randomString() . $this->createUuid();
// Get config entry for salt length
$length = $this->getConfigInstance()->getConfigEntry('salt_length');
$this->salt = substr(sha1($randomString), -$length, $length);
}
+ /**
+ * Returns a UUID (Universal Unique IDentifier) if PECL extension uuid was
+ * found or an empty string it not.
+ *
+ * @return $uuid UUID with leading dash or empty string
+ */
+ public function createUuid () {
+ // Init empty UUID
+ $uuid = '';
+
+ // Is the UUID extension loaded? (see pecl)
+ if ((extension_loaded('uuid')) && (function_exists('uuid_create'))) {
+ // Then add it as well
+ $uuid = uuid_create();
+ } // END - if
+
+ // Return it
+ return $uuid;
+ }
+
/**
* Hashes a string with salt and returns the hash. If an old previous hash
* is supplied the method will use the first X chars of that hash for hashing
$this->setTemplateInstance($templateInstance);
// Load the menu template for all
- $this->getTemplateInstance()->loadMenuTemplate('generic_menu_entries');
+ $templateInstance->loadMenuTemplate('generic_menu_entries');
// Get the 'page' from request instance
$page = $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page');
// Load the menu template for this page
try {
- $this->getTemplateInstance()->loadMenuTemplate($page . '_menu_entries');
+ $templateInstance->loadMenuTemplate($page . '_menu_entries');
} catch (FileIoException $e) {
// @TODO Should we log it here? We should, because it will be silently ignored.
}
// Get the prepared content
- $menuContent = $this->getTemplateInstance()->getRawTemplateData();
+ $menuContent = $templateInstance->getRawTemplateData();
// Render it here
- $this->getTemplateInstance()->renderXmlContent($menuContent);
+ $templateInstance->renderXmlContent($menuContent);
//exit(__METHOD__ . ':!OK');
}
*/
private $rndStrLen = 0;
+ /**
+ * Self instance
+ */
+ private static $selfInstance = NULL;
+
/**
* Protected constructor
*
* @return $rngInstance An instance of this random number generator
*/
public static final function createRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) {
- // Get a new instance
- $rngInstance = new RandomNumberGenerator();
+ // Is self instance set?
+ if (is_null(self::$selfInstance)) {
+ // Get a new instance
+ $rngInstance = new RandomNumberGenerator();
- // Initialize the RNG now
- $rngInstance->initRng($extraInstance);
+ // Initialize the RNG now
+ $rngInstance->initRng($extraInstance);
+
+ // Set it "self"
+ self::$selfInstance = $rngInstance;
+ } else {
+ // Use from self instance
+ $rngInstance = self::$selfInstance;
+ }
// Return the instance
return $rngInstance;