set() public method

public set ( $key, $value )
Example #1
0
 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'));
 }
Example #2
0
 /**
  * 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]);
 }
Example #3
0
 /**
  * @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);
 }
Example #4
0
 /**
  * /
  * @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);
 }
Example #5
0
 /**
  * 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;
     }
 }
Example #6
0
 /**
  * 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;
 }
 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     $this->coll->set($key, $value);
     $this->changed();
 }
Example #8
0
 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;
 }
Example #9
0
 /**
  * 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
 }
 /**
  * @param PerimeterInterface $perimeter
  */
 public function addPerimeter(PerimeterInterface $perimeter)
 {
     $this->perimeters->set($perimeter->getType(), $perimeter);
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     $this->_initialize();
     $this->_coll->set($key, $value);
     $this->_changed();
 }
 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;
 }
Example #13
0
 /**
  * {@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);
 }
Example #14
0
 /**
  * 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));
     }
 }
Example #15
0
 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;
 }
Example #16
0
 public static function languages()
 {
     $languages = new Collection();
     foreach (dir::read(root('panel.app.languages')) as $file) {
         $language = new Obj(require root('panel.app.languages') . DS . $file);
         $language->code = str_replace('.php', '', $file);
         $languages->set($language->code, $language);
     }
     return $languages;
 }
 /**
  * Add an element.
  *
  * @param string                    $id
  * @param GraphCommons\Graph\Signal $signal
  */
 public final function add(Signal $signal) : self
 {
     parent::set($this->count(), $signal);
     return $this;
 }
Example #18
0
 /**
  * Sets an attribute
  *
  * @param string $attribute The name of an attribute
  * @param string $value     [optional] The value of an attribute
  *
  * @return Tag
  */
 public function setAttribute($attribute, $value = null)
 {
     $this->attributes->set($attribute, $value);
     return $this;
 }
 /**
  * @param string $name
  * @param ArgumentDescriptor $argument
  */
 public function addArgument($name, ArgumentDescriptor $argument)
 {
     $argument->setMethod($this);
     $this->arguments->set($name, $argument);
 }
Example #20
0
 /**
  * Create a new collection in this library
  *
  * @param string $name the name of the new item
  * @param Item $parent the optional parent collection for the new collection
  * @return Zotero_Response
  */
 public function createCollection($name, $parent = false)
 {
     $collection = new Collection(null, $this);
     $collection->set('name', $name);
     $collection->set('parentCollectionKey', $parent);
     return $this->collections->writeCollection($collection);
 }