From 83af6f099d42227806ecfa42476c36d632ba6c75 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 10 Feb 2015 04:50:46 -0800 Subject: [PATCH] Add Civi\Core\Resolver::call() helper --- Civi/Core/Resolver.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Civi/Core/Resolver.php b/Civi/Core/Resolver.php index 0654acc2fb..bf3845f8d6 100644 --- a/Civi/Core/Resolver.php +++ b/Civi/Core/Resolver.php @@ -50,6 +50,7 @@ class Resolver { * A callback expression; any of the following. * @return array * A PHP callback. Do not serialize (b/c it may include an object). + * @throws \RuntimeException */ public function get($id) { if (!is_string($id)) { @@ -95,6 +96,19 @@ class Resolver { } } + /** + * Invoke a callback expression. + * + * @param string|callable $id + * @param array $args + * Ordered parameters. To call-by-reference, set an array-parameter by reference. + * @return mixed + */ + public function call($id, $args) { + $cb = $this->get($id); + return $cb ? call_user_func_array($cb, $args) : NULL; + } + } /** -- 2.25.1