本文整理汇总了PHP中Nette\Http\Url::getQueryParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getQueryParameter方法的具体用法?PHP Url::getQueryParameter怎么用?PHP Url::getQueryParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\Url
的用法示例。
在下文中一共展示了Url::getQueryParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVideoByUrl
/**
* Fetches video data by youtube url
* @param string $videoUrl YouTube url
* @return Video
*/
public function getVideoByUrl($videoUrl)
{
$url = new Nette\Http\Url($videoUrl);
if (stripos($url->host, 'youtu.be') !== false) {
return $this->getVideo(trim($url->getPath(), '/'));
}
$videoId = $url->getQueryParameter('v');
if (stripos($url->host, 'youtube.com') === false || $videoId === null) {
throw new Nette\InvalidArgumentException('videoUrl must be valid youtube url.');
}
return $this->getVideo($videoId);
}
示例2: createFileRoute
private function createFileRoute(array $route)
{
$web = $route['metadata']['web'][Nette\Application\Routers\Route::VALUE];
unset($route['metadata']['web']);
return new Nette\Application\Routers\Route(...array_values(array_merge_recursive(['mask' => self::FILE_MASK] + $route, ['metadata' => ['file' => [Nette\Application\Routers\Route::PATTERN => '[a-z0-9.-/]+'], NULL => [Nette\Application\Routers\Route::FILTER_IN => function (array $params) {
$webDir = implode(DIRECTORY_SEPARATOR, [$this->wwwDir, 'web', $params['web']]);
$domainDir = implode(DIRECTORY_SEPARATOR, [$webDir, 'domain', $domain = $params['domain']]);
$webFile = implode(DIRECTORY_SEPARATOR, [$webDir, $file = $params['file']]);
$domainFile = implode(DIRECTORY_SEPARATOR, [$domainDir, $file]);
if (is_file($domainFile)) {
$params['webDomain'] = $domain;
} elseif (!is_file($webFile)) {
return NULL;
}
return $params;
}, Nette\Application\Routers\Route::FILTER_OUT => function (array $params) use($web) {
if (!isset($params['file']) || !($file = $params['file'])) {
return NULL;
}
$webDir = implode(DIRECTORY_SEPARATOR, [$this->wwwDir, 'web', $params['web'] = $web]);
$webFile = implode(DIRECTORY_SEPARATOR, [$webDir, $file]);
$domainDir = implode(DIRECTORY_SEPARATOR, [$webDir, 'domain', $domain = $params['domain']]);
$domainFile = implode(DIRECTORY_SEPARATOR, [$domainDir, $file]);
$directory = NULL;
if (is_file($domainFile)) {
$params['webDomain'] = $domain;
$directory = $domainDir;
} elseif (is_file($webFile)) {
$directory = $webDir;
} else {
unset($params['web']);
$directory = $this->wwwDir;
}
if ((!isset($params['version']) || $params['version']) && $directory) {
$url = new Nette\Http\Url(call_user_func($this->versionFilter, $file, $directory, $parameter = is_string($params['version'] ?? NULL) ? $params['version'] : 'version'));
$params['version'] = $url->getQueryParameter($parameter);
} else {
unset($params['version']);
}
return array_intersect_key($params, array_flip(['domain', 'web', 'webDomain', 'file', 'version']));
}]]])));
}