From 7869a95ed07269bc5427616b6ed193cccb2f2442 Mon Sep 17 00:00:00 2001 From: Greg Anderson Date: Sun, 30 Apr 2023 14:47:30 -0700 Subject: [PATCH] Allow Robo::register to operate on multiple items (#1145) * Allow Robo::register to operate on multiple items * Oops --- src/Robo.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Robo.php b/src/Robo.php index 99ecc022..d5536d89 100644 --- a/src/Robo.php +++ b/src/Robo.php @@ -513,13 +513,30 @@ public static function process(Process $process) return ProcessExecutor::create(static::getContainer(), $process); } + /** + * @param \Robo\Application $app + * @param string|object $handler + * + * @return array + */ + public static function register($app, $handlers) + { + if (!is_array($handlers)) { + $handlers = [ $handlers ]; + } + + foreach ($handlers as $handler) { + static::registerSingle($app, $handler); + } + } + /** * @param \Robo\Application $app * @param string|object $handler * * @return null|object */ - public static function register($app, $handler) + protected static function registerSingle($app, $handler) { $container = static::getContainer(); $instance = static::instantiate($handler); @@ -548,7 +565,7 @@ public static function register($app, $handler) * * @return null|object */ - protected static function instantiate($handler) + public static function instantiate($handler) { $container = Robo::getContainer();