本文整理匯總了PHP中ShellDispatcher::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP ShellDispatcher::find方法的具體用法?PHP ShellDispatcher::find怎麽用?PHP ShellDispatcher::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ShellDispatcher
的用法示例。
在下文中一共展示了ShellDispatcher::find方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
/**
* Displays detailed help about a HeavyMetal shell command.
*
* @usage ./metal help your/command/uri
* @param $uri The URI of the shell command to display help about.
*/
public function index($uri)
{
try {
try {
$s = new ShellDispatcher($uri);
$f = $s->find();
} catch (Exception $ex) {
$s = new SysShellDispatcher($uri);
$f = $s->find();
}
} catch (Exception $ex) {
vomit($ex->getTrace());
echo "Could not find a suitable controller for {$uri} - are you sure you got it right?";
}
$method = new ReflectionMethod($f['classname'], $f['found_action']);
$help = $method->getDocComment();
$help = explode("\n", $help);
$description = '';
$switches = array();
$params = array();
$usage = '';
foreach ($help as $line) {
if (strpos(trim($line, "\t \n"), '/**') === FALSE && strpos(trim($line, "\t \n"), '*/') === FALSE) {
$line = trim($line, "\t* ");
if (strpos($line, '@') === FALSE) {
$description .= $line;
} else {
if (strpos($line, '@usage') === 0) {
$usage = substr($line, 6);
} else {
$matches = array();
preg_match_all('#([@a-z0-9]*) ([$a-z0-9]*) (.*)#', $line, $matches);
switch ($matches[1][0]) {
case '@switch':
$switches[$matches[2][0]] = $matches[3][0];
break;
case '@param':
$params[trim($matches[2][0], '$')] = $matches[3][0];
break;
}
}
}
}
}
return array('description' => $description, 'usage' => $usage, 'switches' => $switches, 'params' => $params);
}