Пример #1
0
 /**
  * @expectedException  \RuntimeException
  * @group Common
  */
 public function testReadOnly()
 {
     $c = new DataContainer(array('some' => array('data' => true)));
     $this->assertTrue($c->get('some.data'));
     $this->assertFalse($c->isReadOnly());
     $c->set('some.thing', true);
     $c->setReadOnly(true);
     $c->set('some.other.thing', true);
 }
Пример #2
0
 /**
  * Returns a key's value from this bag's data
  *
  * @param string $key
  * @param mixed  $default
  *
  * @return mixed
  */
 public function get($key, $default = null)
 {
     return parent::get($this->prefixKey($key), $default);
 }
Пример #3
0
 /**
  * Returns a key's value from this bag's data
  *
  * @param string $key
  * @param mixed  $default
  *
  * @return mixed
  */
 public function get($key, $default = null)
 {
     // check if we have this key
     if (parent::has($this->prefixKey($key))) {
         // do we have expiry information?
         if (!isset($this->data[static::EXPIRE_DATA_KEY][$key])) {
             // nope, simply return the data
             return parent::get($this->prefixKey($key), $default);
         }
         // return the data if we don't have expiry information or if the data is valid
         if ($this->data[static::EXPIRE_DATA_KEY][$key][1] !== static::EXPIRE_STATE_EXPIRED) {
             // check the expiry strategy
             if ($this->data[static::EXPIRE_DATA_KEY][$key][0] === EXPIRE_ON_GET) {
                 // expire on get, so expire it
                 $this->data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_EXPIRED;
             }
             // return the data
             return parent::get($this->prefixKey($key), $default);
         }
     }
     // no dice, return the default
     return $default;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function get($key = null, $default = null)
 {
     // Check if the property requested is a relation
     if ($this->provider !== null and $this->provider->hasRelation($key)) {
         return $this->loadRelations($key);
     }
     // Not a relation so throw the call up to the parent
     return parent::get($key, $default);
 }