本文整理汇总了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;
}