Skip to content

Commit

Permalink
Allow Robo::register to operate on multiple items (consolidation#1145)
Browse files Browse the repository at this point in the history
* Allow Robo::register to operate on multiple items

* Oops
  • Loading branch information
greg-1-anderson authored Apr 30, 2023
1 parent be88439 commit 7869a95
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Robo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 7869a95

Please sign in to comment.