本文整理汇总了PHP中Collection::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::set方法的具体用法?PHP Collection::set怎么用?PHP Collection::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test1_Queries
public function test1_Queries()
{
$this->assertEquals(TRUE, static::$collection->any());
$this->assertEquals('stuff', static::$collection->{'part1.item1'});
static::$collection['set'] = ['test' => 'set test'];
$this->assertEquals(static::$collection->get('set'), ['test' => 'set test']);
$this->assertEquals(NULL, static::$collection->set(999, 'set test'));
$this->assertEquals('default', static::$collection->search_and_replace('does-not-exist', 'default'));
$this->assertEquals(['test' => 'set test'], static::$collection->search_and_replace('set', 'default'));
$this->assertEquals(static::$collection->search_and_replace('set.test'), 'set test');
static::$collection->forget('set');
$this->assertTrue(!static::$collection->has('set'));
}
示例2: set
/**
* Set HTTP header value
*
* This method sets a header value. It replaces
* any values that may already exist for the header name.
*
* @param string $key The case-insensitive header name
* @param string $value The header value
*/
public function set($key, $value)
{
if (!is_array($value)) {
$value = [$value];
}
parent::set($this->normalizeKey($key), ['value' => $value, 'originalKey' => $key]);
}
示例3: set
/**
* @access public
* @param [type] $id [description]
* @param [type] $item [description]
*/
public function set($id, $item)
{
if ($id === 'slim.flash') {
return;
}
$id = str_replace('.', '_', $id);
$_SESSION[$id] = $item;
parent::set($id, $item);
}
示例4: set
/**
* /
* @param [type] $id [description]
* @param array $cookie [description]
*/
public function set($id, array $cookie)
{
if (!is_string($id)) {
throw new \Exception("Cookie index must be string", 01);
}
$newId = str_replace('.', '_', $id);
setcookie($newId, $cookie['value'], isset($cookie['expires']) ? $cookie['expires'] : null, isset($cookie['path']) ? $cookie['path'] : null, isset($cookie['domain']) ? $cookie['domain'] : null, isset($cookie['secure']) ? $cookie['secure'] : null, isset($cookie['httponly']) ? $cookie['httponly'] : null);
parent::set($id, $cookie);
}
示例5: addImageSize
/**
* Set (add) image size
*
* @param ImageSize $size
* @return boolean
*/
public function addImageSize(ImageSize $size)
{
if ($this->imageSizes->containsKey($size->getName())) {
return false;
} else {
$this->imageSizes->set($size->getName(), $size);
return true;
}
}
示例6: parseQueryString
/**
* Parses query string into a collection of parameters.
*
* @todo Think about better way of doing this
*
* @param string $queryString Query string to parse.
*
* @return \Students\Utility\Collection Collection of parsed data.
*/
public static function parseQueryString($queryString)
{
// Array with the results.
$result = new Collection([]);
// Explode the query string by '&' symbol.
$keyValue = !empty($queryString) ? explode('&', $queryString) : [];
foreach ($keyValue as $key => $value) {
$param = explode('=', $value);
$result->set($param[0], $param[1]);
}
return $result;
}
示例7: set
/**
* {@inheritdoc}
*/
public function set($key, $value)
{
$this->coll->set($key, $value);
$this->changed();
}
示例8: languages
public function languages()
{
$languages = new Collection();
$root = $this->roots()->languages();
foreach (dir::read($root) as $file) {
// skip invalid language files
if (f::extension($file) != 'php') {
continue;
}
// fetch all strings from the language file
$strings = (require $root . DS . $file);
// skip invalid language files
if (!is_array($strings)) {
continue;
}
// create the language object
$language = new Obj($strings);
$language->code = str_replace('.php', '', $file);
$languages->set($language->code, $language);
}
return $languages;
}
示例9: save
/**
* Helper function to create or update a Collection from the supplied data.
*
* @param array $data
* @return collection The newly created/updated collection
*/
public static function save($data)
{
if (array_key_exists('id', $data)) {
$id = $data['id'];
} else {
$id = 0;
}
$collection = new Collection($id, $data);
$collection->set('mtime', time());
$collection->commit();
return $collection;
// return newly created Collections id
}
示例10: addPerimeter
/**
* @param PerimeterInterface $perimeter
*/
public function addPerimeter(PerimeterInterface $perimeter)
{
$this->perimeters->set($perimeter->getType(), $perimeter);
}
示例11: set
/**
* {@inheritdoc}
*/
public function set($key, $value)
{
$this->_initialize();
$this->_coll->set($key, $value);
$this->_changed();
}
示例12: set
function set($key, $value)
{
Assert::isTrue($value instanceof $this->type, 'wrong type passed to %s, expected %s but %s found', get_class($this), $this->type, gettype($value));
parent::set($key, $value);
return $this;
}
示例13: set
/**
* {@inheritdoc}
*/
public function set($key, $value) : parent
{
if (isset($this->elements[$key])) {
$this->removeFromHistory($this->elements[$key]);
}
$this->added[] = $value;
return parent::set($key, $value);
}
示例14: set
/**
* Headers are allowed to have multiple values, so we must add support for that
*
* @inheritdoc
* @param string|array $values The value or values
* @param bool $shouldReplace Whether or not to replace the value
*/
public function set($name, $values, $shouldReplace = true)
{
$name = $this->normalizeName($name);
$values = (array) $values;
if ($shouldReplace || !$this->has($name)) {
parent::set($name, $values);
} else {
parent::set($name, array_merge($this->values[$name], $values));
}
}
示例15: languages
public function languages()
{
$languages = new Collection();
$root = $this->roots()->languages();
foreach (dir::read($root) as $file) {
$language = new Obj(require $root . DS . $file);
$language->code = str_replace('.php', '', $file);
$languages->set($language->code, $language);
}
return $languages;
}