本文整理匯總了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);
}
}