本文整理汇总了PHP中Arr::callback方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::callback方法的具体用法?PHP Arr::callback怎么用?PHP Arr::callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::callback方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_callback
public function test_callback()
{
$callback = 'foo::bar(one,two,three)';
// The valid callback and params
$expect = array(array('foo', 'bar'), array('one', 'two', 'three'));
$this->assert_equal(Arr::callback($callback), $expect);
}
示例2: test_callback
/**
* Tests Arr::callback()
*
* @test
* @dataProvider provider_callback
* @param string $str String to parse
* @param array $expected Callback and its parameters
*/
public function test_callback($str, $expected)
{
$result = Arr::callback($str);
$this->assertSame(2, count($result));
$this->assertSame($expected, $result);
}
示例3: _bulk_update
/**
* Bulk updates
*
* @param array $post
* @uses Post::bulk_actions
* @uses Arr::callback
*/
private function _bulk_update($post)
{
$operations = Post::bulk_actions(FALSE, 'blog');
$operation = $operations[$post['operation']];
$blogs = array_filter($post['blogs']);
// Filter out unchecked pages
if ($operation['callback']) {
list($func, $params) = Arr::callback($operation['callback']);
if (isset($operation['arguments'])) {
$args = array_merge(array($blogs), $operation['arguments']);
} else {
$args = array($blogs);
}
// set model name
$args['type'] = 'blog';
// execute the bulk operation
call_user_func_array($func, $args);
}
}
示例4: _action_callback
/**
* Performs a callback on the error
*
* @param array $options Options from config
* @return void
*/
protected function _action_callback(array $options = array())
{
$callback = Arr::get($options, 'callback');
@list($method,) = Arr::callback($callback);
if (is_callable($method))
{
call_user_func($method, $this);
}
}
示例5: _bulk_update
/**
* Bulk update
*
* Executes the bulk operation
*
* @param array $post Array of comments
* @uses Comment::bulk_actions
* @uses Arr::callback
* @uses Arr::merge
*/
private function _bulk_update($post)
{
// Filter out unchecked comments
$comments = array_filter($post['comments']);
$operations = Comment::bulk_actions(FALSE);
$operation = $operations[$post['operation']];
if ($operation['callback']) {
list($func, $params) = Arr::callback($operation['callback']);
if (isset($operation['arguments'])) {
$args = Arr::merge(array($comments), $operation['arguments']);
} else {
$args = array($comments);
}
// Execute the bulk operation
call_user_func_array($func, $args);
}
}