public function data($data = array())
{
$bind =& $this->_entity;
if ($data) {
$bind ? $bind->set($data) : ($this->_data = array_merge($this->_data, $data));
return $this;
}
$data = $bind ? $bind->data() : $this->_data;
return ($list = $this->_config['whitelist']) ? array_intersect_key($data, $list) : $data;
}
/** * Tests that assigning a whitelist to a query properly restricts the list of data fields that * the query exposes. * * @return void */ public function testWhitelisting() { $data = array('foo' => 1, 'bar' => 2, 'baz' => 3); $query = new Query(compact('data')); $this->assertEqual($data, $query->data()); $query = new Query(compact('data') + array('whitelist' => array('foo', 'bar'))); $this->assertEqual(array('foo' => 1, 'bar' => 2), $query->data()); }