Example #1
0
 /**
  * @expectedException  \RuntimeException
  * @group Common
  */
 public function testReadOnlyReplace()
 {
     $c = new DataContainer(array(), true);
     $c->setContents(array('new' => 'stuff'));
 }
Example #2
0
 /**
  * Replaces the container's data
  *
  * @param array $data
  *
  * @throws \RuntimeException
  */
 public function setContents(array $data)
 {
     // make sure we have our expire data key
     if (isset($data[static::EXPIRE_DATA_KEY])) {
         // process the expiration settings
         foreach ($data[static::EXPIRE_DATA_KEY] as $key => $expiration) {
             // if it was set on the last request, make it as loaded
             if ($expiration[1] === static::EXPIRE_STATE_NEW) {
                 $data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_LOADED;
             } elseif ($expiration[0] === EXPIRE_ON_REQUEST and $expiration[1] === static::EXPIRE_STATE_LOADED) {
                 unset($data[static::EXPIRE_DATA_KEY][$key]);
                 \Arr::delete($data, $this->prefixKey($key));
             }
         }
     } else {
         // not set, create an empty one to start with
         $data[static::EXPIRE_DATA_KEY] = array();
     }
     // store the data
     parent::setContents($data);
 }
 /**
  * {@inheritdocs}
  */
 public function setContents(array $data)
 {
     $this->validate($data);
     return parent::setContents($data);
 }