本文整理汇总了PHP中Jam::permit方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::permit方法的具体用法?PHP Jam::permit怎么用?PHP Jam::permit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::permit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modified_params
public static function modified_params(array $modified, array $expected = NULL)
{
if ($expected) {
$modified = Jam::permit($expected, $modified);
}
$modified = array_filter($modified);
return array_map(function ($param) {
return $param === '__clear' ? FALSE : (is_array($param) ? Tart_Request::modified_params($param) : $param);
}, $modified);
}
示例2: test_permit
public function test_permit()
{
$data = array('test' => 10, 'test2' => 20, 'test_object' => array('var1' => 5, 'var2' => 10), 'test_array' => array(array('name' => 8, 'id' => 1), array('name' => 9, 'id' => 2)));
$clean = Jam::permit(array('test'), $data);
$this->assertEquals(array('test' => 10), $clean);
$clean = Jam::permit(array('test', 'test2'), $data);
$this->assertEquals(array('test' => 10, 'test2' => 20), $clean);
$clean = Jam::permit(array('test', 'test2', 'test_object', 'test_array'), $data);
$this->assertEquals($data, $clean);
$clean = Jam::permit(array('test', 'test2', 'test_object' => array('var1')), $data);
$this->assertEquals(array('test' => 10, 'test2' => 20, 'test_object' => array('var1' => 5)), $clean);
$clean = Jam::permit(array('test', 'test2', 'test_array' => array('name')), $data);
$this->assertEquals(array('test' => 10, 'test2' => 20, 'test_array' => array(array('name' => 8), array('name' => 9))), $clean);
}