Last active
August 29, 2015 14:27
-
-
Save devosc/8e884434160bd28602c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$plugin = $this->plugin($plugin, function($plugin) use($args, $callback) { | |
if (!is_callable($plugin)) { | |
return $this->call('service:event', [$plugin]); | |
} | |
return $plugin; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function call($config, array $args = [], callable $callback = null) | |
{ | |
if (!is_string($config)) { | |
return $config instanceof Event ? $this->trigger($config, $args, $callback ?: $this) | |
: $this->invoke($config, $args, $callback); | |
} | |
$config = explode(Args::CALL_SEPARATOR, $config); | |
$plugin = array_shift($config); | |
$method = array_pop($config); | |
$plugin = $this->plugin($plugin, function($plugin) use($args, $callback) { | |
if (!is_callable($plugin)) { | |
return $this->call('service:event', [$plugin]); | |
} | |
return $plugin; | |
}); | |
if ($plugin instanceof Event) { | |
return $this->trigger($plugin, $args, $callback ?: $this); | |
} | |
foreach($config as $name) { | |
$plugin = $this->invoke([$plugin, $name], $args, $callback); | |
} | |
return $this->invoke($method ? [$plugin, $method] : $plugin, $args, $callback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment