本文整理匯總了PHP中Silex\Application::generatePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::generatePath方法的具體用法?PHP Application::generatePath怎麽用?PHP Application::generatePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Silex\Application
的用法示例。
在下文中一共展示了Application::generatePath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: editlink
/**
* Creates a link to EDIT this record, if the user is logged in.
*
* @return string
*/
public function editlink()
{
$perm = 'contenttype:' . $this->contenttype['slug'] . ':edit:' . $this->id;
if ($this->app['users']->isAllowed($perm)) {
return $this->app->generatePath('editcontent', ['contenttypeslug' => $this->contenttype['slug'], 'id' => $this->id]);
} else {
return false;
}
}
示例2: ymllink
/**
* Create a link to edit a .yml file, if a filename is detected in the string. Mostly
* for use in Flashbag messages, to allow easy editing.
*
* @param string $str
* @param boolean $safe
*
* @return string Resulting string
*/
public function ymllink($str, $safe)
{
// There is absolutely no way anyone could possibly need this in a "safe" context
if ($safe) {
return null;
}
$matches = [];
if (preg_match('/ ([a-z0-9_-]+\\.yml)/i', $str, $matches)) {
$path = $this->app->generatePath('fileedit', ['namespace' => 'config', 'file' => $matches[1]]);
$link = sprintf(' <a href="%s">%s</a>', $path, $matches[1]);
$str = preg_replace('/ ([a-z0-9_-]+\\.yml)/i', $link, $str);
}
return $str;
}