コード例 #1
0
 /**
  * Returns all parameters (GET, POST, named, and cookies) that match the mask
  *
  * Takes an optional mask param that contains the names of any params
  * you'd like this method to exclude in the returned array
  *
  * @see \Klein\DataCollection\DataCollection::all()
  * @param array $mask               The parameter mask array
  * @param boolean $fill_with_nulls  Whether or not to fill the returned array
  *  with null values to match the given mask
  * @access public
  * @return array
  */
 public function params($mask = null, $fill_with_nulls = true)
 {
     /*
      * Make sure that each key in the mask has at least a
      * null value, since the user will expect the key to exist
      */
     if (null !== $mask && $fill_with_nulls) {
         $attributes = array_fill_keys($mask, null);
     } else {
         $attributes = array();
     }
     // Merge our params in the get, post, cookies, named order
     return array_merge($attributes, $this->params_get->all($mask, false), $this->params_post->all($mask, false), $this->cookies->all($mask, false), $this->params_named->all($mask, false));
 }
コード例 #2
0
ファイル: Request.php プロジェクト: botatoes/admin
 /**
  * Returns all parameters (GET, POST, named, and cookies) that match the mask
  *
  * Takes an optional mask param that contains the names of any params
  * you'd like this method to exclude in the returned array
  *
  * @see \Klein\DataCollection\DataCollection::all()
  * @param array $mask  The parameter mask array
  * @access public
  * @return array
  */
 public function params($mask = null)
 {
     // Merge our params in the get, post, cookies, named order
     return array_merge($this->params_get->all($mask), $this->params_post->all($mask), $this->cookies->all($mask), $this->params_named->all($mask));
 }
コード例 #3
0
 public function testSet()
 {
     // Test data
     $data = array('dog' => 'cooper');
     // Create our collection with NO data
     $data_collection = new DataCollection();
     // Make sure its first empty
     $this->assertSame(array(), $data_collection->all());
     // Set our data from our test data
     $return_val = $data_collection->set(key($data), current($data));
     // Make sure the set worked
     $this->assertSame(current($data), $data_collection->get(key($data)));
     // Make sure it returned the instance during "set"
     $this->assertEquals($return_val, $data_collection);
     $this->assertSame($return_val, $data_collection);
 }