public function addAsyncMethods($methods, $scope, $aliases = array(), array $options = array())
{
$aliasPrefix = '';
if (is_string($aliases)) {
$aliasPrefix = $aliases;
if ($aliasPrefix !== '') {
$aliasPrefix .= '_';
}
$aliases = array();
} else {
if (!empty($aliases) && empty($options) && array_keys($methods) != array_key($aliases)) {
$options = $aliases;
$aliases = array();
}
}
if (empty($aliases)) {
foreach ($methods as $k => $method) {
$aliases[$k] = $aliasPrefix . $method;
}
}
if (count($methods) != count($aliases)) {
throw new Exception('The count of methods is not matched with aliases');
}
foreach ($methods as $k => $method) {
$func = array($scope, $method);
if (is_callable($func)) {
$this->addAsyncFunction($func, $aliases[$k], $options);
}
}
return $this;
}