本文整理匯總了PHP中Zend\Uri\Http::getQueryAsArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Http::getQueryAsArray方法的具體用法?PHP Http::getQueryAsArray怎麽用?PHP Http::getQueryAsArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Uri\Http
的用法示例。
在下文中一共展示了Http::getQueryAsArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ingest
public function ingest(Media $media, Request $request, ErrorStore $errorStore)
{
$data = $request->getContent();
if (!isset($data['o:source'])) {
$errorStore->addError('o:source', 'No YouTube URL specified');
return;
}
$uri = new HttpUri($data['o:source']);
if (!($uri->isValid() && $uri->isAbsolute())) {
$errorStore->addError('o:source', 'Invalid YouTube URL specified');
return;
}
switch ($uri->getHost()) {
case 'www.youtube.com':
if ('/watch' !== $uri->getPath()) {
$errorStore->addError('o:source', 'Invalid YouTube URL specified, missing "/watch" path');
return;
}
$query = $uri->getQueryAsArray();
if (!isset($query['v'])) {
$errorStore->addError('o:source', 'Invalid YouTube URL specified, missing "v" parameter');
return;
}
$youtubeId = $query['v'];
break;
case 'youtu.be':
$youtubeId = substr($uri->getPath(), 1);
break;
default:
$errorStore->addError('o:source', 'Invalid YouTube URL specified, not a YouTube URL');
return;
}
$fileManager = $this->getServiceLocator()->get('Omeka\\File\\Manager');
$file = $this->getServiceLocator()->get('Omeka\\File');
$url = sprintf('http://img.youtube.com/vi/%s/0.jpg', $youtubeId);
$this->downloadFile($url, $file->getTempPath());
$hasThumbnails = $fileManager->storeThumbnails($file);
$media->setData(['id' => $youtubeId, 'start' => $request->getValue('start'), 'end' => $request->getValue('end')]);
if ($hasThumbnails) {
$media->setFilename($file->getStorageName());
$media->setHasThumbnails(true);
}
}
示例2: partiallyRequest
/**
* @param Http $httpUri
* @param int $offset
* @param int $limit
* @return array
*/
protected function partiallyRequest(Http $httpUri, $offset, $limit)
{
$query = $httpUri->getQueryAsArray();
$query['start'] = $offset;
$query['count'] = $limit;
$httpUri->setQuery($query);
$elements = $this->mapper->fetchAll($httpUri->toString());
$entityName = $this->classMetadata->getName();
$entities = array();
foreach ($elements as $element) {
$hydrator = new EntityHydrator($this->classMetadata);
$entities[] = $hydrator->hydrate($element, new $entityName());
}
return $entities;
}