當前位置: 首頁>>代碼示例>>PHP>>正文


PHP IURLGenerator::linkToRoute方法代碼示例

本文整理匯總了PHP中OCP\IURLGenerator::linkToRoute方法的典型用法代碼示例。如果您正苦於以下問題:PHP IURLGenerator::linkToRoute方法的具體用法?PHP IURLGenerator::linkToRoute怎麽用?PHP IURLGenerator::linkToRoute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OCP\IURLGenerator的用法示例。


在下文中一共展示了IURLGenerator::linkToRoute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: show

 /**
  * Get the template for a specific activity-event in the activities
  *
  * @param array $activity An array with all the activity data in it
  * @return string
  */
 public function show($activity)
 {
     $tmpl = new Template('activity', 'stream.item');
     $tmpl->assign('formattedDate', $this->dateTimeFormatter->formatDateTime($activity['timestamp']));
     $tmpl->assign('formattedTimestamp', Template::relative_modified_date($activity['timestamp']));
     if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) {
         // We do not link the subject as we create links for the parameters instead
         $activity['link'] = '';
     }
     $tmpl->assign('event', $activity);
     if ($activity['file']) {
         $this->view->chroot('/' . $activity['affecteduser'] . '/files');
         $exist = $this->view->file_exists($activity['file']);
         $is_dir = $this->view->is_dir($activity['file']);
         $tmpl->assign('previewLink', $this->getPreviewLink($activity['file'], $is_dir));
         // show a preview image if the file still exists
         $mimeType = Files::getMimeType($activity['file']);
         if ($mimeType && !$is_dir && $this->preview->isMimeSupported($mimeType) && $exist) {
             $tmpl->assign('previewImageLink', $this->urlGenerator->linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
         } else {
             $mimeTypeIcon = Template::mimetype_icon($is_dir ? 'dir' : $mimeType);
             $mimeTypeIcon = substr($mimeTypeIcon, -4) === '.png' ? substr($mimeTypeIcon, 0, -4) . '.svg' : $mimeTypeIcon;
             $tmpl->assign('previewImageLink', $mimeTypeIcon);
             $tmpl->assign('previewLinkIsDir', true);
         }
     }
     return $tmpl->fetchPage();
 }
開發者ID:AARNet,項目名稱:activity,代碼行數:34,代碼來源:display.php

示例2: setRSSToken

 public function setRSSToken($rssToken)
 {
     if ($rssToken) {
         $this->rssLink = $this->URLGenerator->getAbsoluteURL($this->URLGenerator->linkToRoute('activity.rss', array('token' => $rssToken)));
     } else {
         $this->rssLink = '';
     }
 }
開發者ID:WYSAC,項目名稱:oregon-owncloud,代碼行數:8,代碼來源:navigation.php

示例3: getLinkList

 /**
  * Get all items for the users we want to send an email to
  *
  * @return array Notification data (user => array of rows from the table)
  */
 public function getLinkList()
 {
     $topEntries = [['id' => 'all', 'name' => (string) $this->l->t('All Activities'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList')]];
     if ($this->user && $this->userSettings->getUserSetting($this->user, 'setting', 'self')) {
         $topEntries[] = ['id' => 'self', 'name' => (string) $this->l->t('Activities by you'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self'))];
         $topEntries[] = ['id' => 'by', 'name' => (string) $this->l->t('Activities by others'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by'))];
     }
     $additionalEntries = $this->activityManager->getNavigation();
     $topEntries = array_merge($topEntries, $additionalEntries['top']);
     return array('top' => $topEntries, 'apps' => $additionalEntries['apps']);
 }
開發者ID:Kevin-ZK,項目名稱:vaneDisk,代碼行數:16,代碼來源:navigation.php

示例4: redirectToErrorPage

 /**
  * Redirects the client to an error page
  *
  * @param string $message
  * @param int $code
  *
  * @return RedirectResponse
  */
 private function redirectToErrorPage($message, $code)
 {
     $url = $this->urlGenerator->linkToRoute($this->appName . '.page.error_page', ['code' => $code]);
     $response = new RedirectResponse($url);
     $response->addCookie('galleryErrorMessage', $message);
     return $response;
 }
開發者ID:patman15,項目名稱:galleryplus,代碼行數:15,代碼來源:checkmiddleware.php

示例5: createPublicUrl

 private function createPublicUrl($parameter)
 {
     $route = 'myapp.author_api.do_something';
     $parameters = array('id' => $parameter);
     $url = $this->urlGenerator->linkToRoute($route, $parameters);
     return new RedirectResponse($url);
 }
開發者ID:Werdffelynir,項目名稱:owncollab_chart,代碼行數:7,代碼來源:maincontroller.php

示例6: showFile

 /**
  * Redirects to the file list and highlight the given file id
  *
  * @param string $fileId file id to show
  * @return RedirectResponse redirect response or not found response
  * @throws \OCP\Files\NotFoundException
  *
  * @NoCSRFRequired
  * @NoAdminRequired
  */
 public function showFile($fileId)
 {
     $uid = $this->userSession->getUser()->getUID();
     $baseFolder = $this->rootFolder->get($uid . '/files/');
     $files = $baseFolder->getById($fileId);
     $params = [];
     if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
         $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/');
         $files = $baseFolder->getById($fileId);
         $params['view'] = 'trashbin';
     }
     if (!empty($files)) {
         $file = current($files);
         if ($file instanceof Folder) {
             // set the full path to enter the folder
             $params['dir'] = $baseFolder->getRelativePath($file->getPath());
         } else {
             // set parent path as dir
             $params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
             // and scroll to the entry
             $params['scrollto'] = $file->getName();
         }
         return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
     }
     throw new \OCP\Files\NotFoundException();
 }
開發者ID:rchicoli,項目名稱:owncloud-core,代碼行數:36,代碼來源:ViewController.php

示例7: download

 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @CORS
  *
  * Sends the file matching the fileId
  *
  * @param int $fileId the ID of the file we want to download
  * @param string|null $filename
  *
  * @return ImageResponse|RedirectResponse
  */
 public function download($fileId, $filename = null)
 {
     $download = $this->getDownload($fileId, $filename);
     if (!$download) {
         $url = $this->urlGenerator->linkToRoute($this->appName . '.page.error_page', ['message' => 'There was a problem accessing the file', 'code' => Http::STATUS_NOT_FOUND]);
         return new RedirectResponse($url);
     }
     return new ImageResponse($download);
 }
開發者ID:efueger,項目名稱:galleryplus,代碼行數:21,代碼來源:filesapicontroller.php

示例8: filterHttp

 /**
  * @param $uri
  * @param $context
  * @return HTMLPurifier_URI
  */
 private function filterHttp(&$uri, $context)
 {
     $originalURL = urlencode($uri->scheme . '://' . $uri->host . $uri->path);
     if ($uri->query !== null) {
         $originalURL = $originalURL . urlencode('?' . $uri->query);
     }
     // Get the HTML attribute
     $element = $context->get('CurrentAttr');
     // If element is of type "href" it is most likely a link that should get redirected
     // otherwise it's an element that we send through our proxy
     if ($element === 'href') {
         $uri = new \HTMLPurifier_URI(Util::getServerProtocol(), null, Util::getServerHost(), null, $this->urlGenerator->linkToRoute('mail.proxy.redirect'), 'src=' . $originalURL, null);
         return $uri;
     } else {
         $uri = new \HTMLPurifier_URI(Util::getServerProtocol(), null, Util::getServerHost(), null, $this->urlGenerator->linkToRoute('mail.proxy.proxy'), 'src=' . $originalURL . '&requesttoken=' . \OC::$server->getSession()->get('requesttoken'), null);
         return $uri;
     }
 }
開發者ID:matiasdelellis,項目名稱:mail,代碼行數:23,代碼來源:transformurlscheme.php

示例9: htmlError

 /**
  * @param IURLGenerator $urlGenerator
  * @param string $appName
  * @param \Exception $exception
  *
  * @return RedirectResponse
  */
 public function htmlError($urlGenerator, $appName, Exception $exception)
 {
     $message = $exception->getMessage();
     $code = $this->getHttpStatusCode($exception);
     $url = $urlGenerator->linkToRoute($appName . '.page.error_page', ['code' => $code]);
     $response = new RedirectResponse($url);
     $response->addCookie('galleryErrorMessage', $message);
     return $response;
 }
開發者ID:patman15,項目名稱:galleryplus,代碼行數:16,代碼來源:httperror.php

示例10: afterException

 public function afterException($controller, $methodName, Exception $exception)
 {
     if ($exception instanceof TwoFactorAuthRequiredException) {
         return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge', ['redirect_url' => urlencode($this->request->server['REQUEST_URI'])]));
     }
     if ($exception instanceof UserAlreadyLoggedInException) {
         return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index'));
     }
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:9,代碼來源:TwoFactorMiddleware.php

示例11: getLinkList

 /**
  * Get all items for the users we want to send an email to
  *
  * @return array Notification data (user => array of rows from the table)
  */
 public function getLinkList()
 {
     $topEntries = array(array('id' => 'all', 'name' => (string) $this->l->t('All Activities'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList')), array('id' => 'self', 'name' => (string) $this->l->t('Activities by you'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self'))), array('id' => 'by', 'name' => (string) $this->l->t('Activities by others'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by'))), array('id' => 'shares', 'name' => (string) $this->l->t('Shares'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'shares'))));
     $appFilterEntries = array(array('id' => 'files', 'name' => (string) $this->l->t('Files'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'files'))));
     $additionalEntries = $this->activityManager->getNavigation();
     $topEntries = array_merge($topEntries, $additionalEntries['top']);
     $appFilterEntries = array_merge($appFilterEntries, $additionalEntries['apps']);
     return array('top' => $topEntries, 'apps' => $appFilterEntries);
 }
開發者ID:kebenxiaoming,項目名稱:owncloudRedis,代碼行數:14,代碼來源:navigation.php

示例12: testDownloadWithWrongId

 public function testDownloadWithWrongId()
 {
     $fileId = 99999;
     $filename = null;
     $this->mockGetResourceFromId($fileId, false);
     $redirect = new RedirectResponse($this->urlGenerator->linkToRoute($this->appName . '.page.error_page'));
     $response = $this->controller->download($fileId, $filename);
     $this->assertEquals($redirect->getRedirectURL(), $response->getRedirectURL());
 }
開發者ID:efueger,項目名稱:galleryplus,代碼行數:9,代碼來源:FilesControllerTest.php

示例13: publicIndex

 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * Shows the albums and pictures or redirects to the download location the token gives access to
  *
  * @param string $token
  * @param null|string $filename
  *
  * @return TemplateResponse|ImageResponse|RedirectResponse
  */
 public function publicIndex($token, $filename)
 {
     $node = $this->environment->getSharedNode();
     if ($node->getType() === 'dir') {
         return $this->showPublicPage($token);
     } else {
         $url = $this->urlGenerator->linkToRoute($this->appName . '.files_public.download', ['token' => $token, 'fileId' => $node->getId(), 'filename' => $filename]);
         return new RedirectResponse($url);
     }
 }
開發者ID:drognisep,項目名稱:Portfolio-Site,代碼行數:21,代碼來源:pagecontroller.php

示例14: redirect

 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * @throws \Exception If the URL is not valid.
  * @return TemplateResponse
  */
 public function redirect()
 {
     $templateName = 'redirect';
     $route = 'mail.page.index';
     $mailURL = $this->urlGenerator->linkToRoute($route);
     $url = $this->request->getParam('src');
     $authorizedRedirect = false;
     if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
         throw new \Exception('URL is not valid.', 1);
     }
     // If the request has a referrer from this domain redirect the user without interaction
     // this is there to prevent an open redirector.
     // Since we can't prevent the referrer from being added with a HTTP only header we rely on an
     // additional JS file here.
     if (parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) === Util::getServerHostName()) {
         Util::addScript('mail', 'autoredirect');
         $authorizedRedirect = true;
     }
     $params = ['authorizedRedirect' => $authorizedRedirect, 'url' => $url, 'urlHost' => parse_url($url, PHP_URL_HOST), 'mailURL' => $mailURL];
     return new TemplateResponse($this->appName, $templateName, $params, 'guest');
 }
開發者ID:jakobsack,項目名稱:mail,代碼行數:28,代碼來源:proxycontroller.php

示例15: transform

 /**
  * @param array $attr
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return array
  */
 public function transform($attr, $config, $context)
 {
     if ($context->get('CurrentToken')->name !== 'img' || !isset($attr['src'])) {
         return $attr;
     }
     // Block tracking pixels
     if (isset($attr['width']) && isset($attr['height']) && (int) $attr['width'] < 5 && (int) $attr['height'] < 5) {
         // Replace with a transparent png in case it's important for the layout
         $attr['src'] = Util::imagePath('mail', 'blocked-image.png');
         $attr = $this->setDisplayNone($attr);
         return $attr;
     }
     // Do not block images attached to the email
     $url = $this->parser->parse($attr['src']);
     if ($url->host === Util::getServerHostName() && $url->path === $this->urlGenerator->linkToRoute('mail.proxy.proxy')) {
         $attr['data-original-src'] = $attr['src'];
         $attr['src'] = Util::imagePath('mail', 'blocked-image.png');
         $attr = $this->setDisplayNone($attr);
     }
     return $attr;
 }
開發者ID:matiasdelellis,項目名稱:mail,代碼行數:27,代碼來源:transformimagesrc.php


注:本文中的OCP\IURLGenerator::linkToRoute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。