本文整理汇总了PHP中Zend_Session::setExpirationHops方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session::setExpirationHops方法的具体用法?PHP Zend_Session::setExpirationHops怎么用?PHP Zend_Session::setExpirationHops使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Session
的用法示例。
在下文中一共展示了Zend_Session::setExpirationHops方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addMessage
/**
* addMessage() - Add a message to flash message
*
* @param string $message
* @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
*/
public function addMessage($message)
{
if (self::$_messageAdded === false) {
self::$_session->setExpirationHops(1, null, true);
}
if (!is_array(self::$_session->{$this->_namespace})) {
self::$_session->{$this->_namespace} = array();
}
self::$_session->{$this->_namespace}[] = $message;
return $this;
}
示例2: addMessage
/**
* addMessage() - Add a message to flash message
*
* @param string $message
* @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
*/
public function addMessage($message, $namespace = null)
{
if (!is_string($namespace) || $namespace == '') {
$namespace = $this->getNamespace();
}
if (self::$_messageAdded === false) {
self::$_session->setExpirationHops(1, null, true);
}
if (!is_array(self::$_session->{$namespace})) {
self::$_session->{$namespace} = array();
}
self::$_session->{$namespace}[] = $message;
self::$_messageAdded = true;
return $this;
}
示例3: addVar
/**
* addVar() - Add a message to flash message
*
* @param string $var
* @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
*/
public function addVar($var, $name = false)
{
if (self::$_varAdded === false) {
self::$_session->setExpirationHops(1, null, true);
}
if (!is_array(self::$_session->{$this->_namespace})) {
self::$_session->{$this->_namespace} = array();
}
if ($name) {
self::$_session->{$this->_namespace}[$name] = $var;
} else {
self::$_session->{$this->_namespace}[] = $var;
}
return $this;
}
示例4: setMessage
/**
* setMessage() - method set message and type
*
* @param string $type
* @param string $message
* @param mixed $value
* @param int $len
* @return \Extlib\Controller\Action\Helper\FlashMessage
*/
public function setMessage($type, $message, $value = null, $len = 25)
{
if (!in_array(strtolower($type), self::$_allowedTypes)) {
throw new \Zend_Controller_Action_Exception('Incorrect type of message!');
}
if (!\Zend_Validate::is($len, 'Int')) {
throw new \Zend_Controller_Action_Exception("Param 'len' must be a int value!");
}
if (null !== $this->_translator) {
$message = $this->_translator->translate($message);
}
if (null !== $value) {
if (strlen($value) > $len) {
$value = mb_substr($value, 0, $len, 'UTF-8') . '..';
}
$message = str_replace(self::VALUE_PATTERN, $value, $message);
}
self::$_session->setExpirationHops(1, null, true);
self::$_session->{$this->_namespace} = array(strtolower($type) => $message);
self::$_messageAdded = true;
return $this;
}
示例5: testSetExpireSessionVarsByHopsOnUse
/**
* test expiration of namespace variables by hops
* expect expiration of specified keys in the proper number of hops
*/
public function testSetExpireSessionVarsByHopsOnUse()
{
$s = new Zend_Session('expireGuava');
$expireBeforeHop = 2;
$s->setExpirationHops($expireBeforeHop, 'g', true);
// only count a hop, when namespace is used
$s->g = 'guava';
$s->p = 'peach';
$s->p = 'plum';
$id = session_id();
session_write_close();
// release session so process below can use it
// we are not accessing (using) the "expireGuava" namespace, so these hops should have no effect
for ($i = 1; $i <= $expireBeforeHop + 2; $i++) {
exec($this->script . "expireAll {$id} notused", $result);
$result = $this->sortResult($result);
$this->assertTrue($result === '', "iteration over named Zend_Session namespace failed (result='{$result}'; hop #{$i})");
}
for ($i = 1; $i <= $expireBeforeHop + 2; $i++) {
exec($this->script . "expireAll {$id} expireGuava", $result);
$result = $this->sortResult($result);
if ($i > $expireBeforeHop) {
$expect = ';p === plum';
$this->assertTrue($result === $expect, "unexpected results iterating over named Zend_Session namespace (result='{$result}'; expected '{$expect}'; hop #{$i})");
} else {
$expect = ';g === guava;p === plum';
$this->assertTrue($result === $expect, "unexpected results iterating over named Zend_Session namespace (result='{$result}'; expected '{$expect}'; hop #{$i})");
}
}
session_start();
// resume artificially suspended session
$core = Zend_Session_Core::getInstance();
$core->destroy();
}
示例6: setExpireSessionVarsByHops
/**
* test expiration of namespace variables by hops
* expect expiration of specified keys in the proper number of hops
*/
public function setExpireSessionVarsByHops()
{
$s = new Zend_Session('expireGuava');
$expireBeforeHop = 4;
$s->setExpirationHops($expireBeforeHop, 'g');
$s->g = 'guava';
$s->p = 'peach';
$s->p = 'plum';
$id = session_id();
session_write_close();
// release session so process below can use it
for ($i = 1; $i <= $expireBeforeHop + 2; $i++) {
exec($this->script . "expireAll {$id} expireGuava", $result);
$result = $this->sortResult($result);
if ($i > $expireBeforeHop) {
$this->assertTrue($result === ';p === plum', "iteration over named Zend_Session namespace failed (result='{$result}'; hop #{$i})");
} else {
$this->assertTrue($result === ';g === guava;p === plum', "iteration over named Zend_Session namespace failed (result='{$result}'; hop #{$i})");
}
}
session_start();
// resume artificially suspended session
}