本文整理汇总了PHP中lithium\util\Set::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::insert方法的具体用法?PHP Set::insert怎么用?PHP Set::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\util\Set
的用法示例。
在下文中一共展示了Set::insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* Write a value to the session.
*
* @param string $key Key of the item to be stored.
* @param mixed $value The value to be stored.
* @param array $options Options array. Not used for this adapter method.
* @return closure Function returning boolean `true` on successful write, `false` otherwise.
*/
public static function write($key, $value, array $options = array())
{
if (!static::isStarted() && !static::_start()) {
throw new RuntimeException("Could not start session.");
}
$class = __CLASS__;
return function ($self, $params) use($class) {
return $class::overwrite($_SESSION, Set::insert($_SESSION, $params['key'], $params['value']));
};
}
示例2: write
/**
* Write a value to the session.
*
* @param string $key Key of the item to be stored.
* @param mixed $value The value to be stored.
* @param array $options Options array. Not used for this adapter method.
* @return closure Function returning boolean `true` on successful write, `false` otherwise.
*/
public function write($key, $value, array $options = array())
{
if (!$this->isStarted() && $this->_startup() === false) {
throw new RuntimeException("Could not start session");
}
$class = get_called_class();
return function ($self, $params) use($class) {
if (!isset($_SESSION)) {
return false;
}
return $class::overwrite($_SESSION, Set::insert($_SESSION, $params['key'], $params['value']));
};
}
示例3: testInsertAndRemoveWithFunkyKeys
public function testInsertAndRemoveWithFunkyKeys() {
$set = Set::insert(array(), 'Session Test', "test");
$result = Set::extract($set, '/Session Test');
$this->assertEqual($result, array('test'));
$set = Set::remove($set, 'Session Test');
$this->assertFalse(Set::check($set, 'Session Test'));
$this->assertTrue($set = Set::insert(array(), 'Session Test.Test Case', "test"));
$this->assertTrue(Set::check($set, 'Session Test.Test Case'));
}
示例4: write
/**
* Write a value to the session.
*
* @param string $key Key of the item to be stored.
* @param mixed $value The value to be stored.
* @param array $options Options array. Not used for this adapter method.
* @return \Closure Function returning boolean `true` on successful write, `false` otherwise.
*/
public function write($key, $value, array $options = array())
{
if (!$this->isStarted() && !$this->_start()) {
throw new RuntimeException('Could not start session.');
}
$self = $this;
return function ($class, $params) use($self) {
return $self->overwrite($_SESSION, Set::insert($_SESSION, $params['key'], $params['value']));
};
}