• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Routing\UrlGenerator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Illuminate\Routing\UrlGenerator的典型用法代码示例。如果您正苦于以下问题:PHP UrlGenerator类的具体用法?PHP UrlGenerator怎么用?PHP UrlGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UrlGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot(UrlGenerator $url)
 {
     //
     if (env('APP_ENV') !== 'local') {
         $url->forceSchema('https');
     }
 }
开发者ID:danielsamfdo,项目名称:applara,代码行数:12,代码来源:AppServiceProvider.php


示例2: __construct

 public function __construct(UrlGenerator $url)
 {
     $this->middleware('auth');
     $this->middleware('permission:dashboard')->only('getIndex');
     $this->prev = $url->previous();
     $this->module = 'admin';
 }
开发者ID:solunes,项目名称:master,代码行数:7,代码来源:AdminController.php


示例3:

 function it_creates_image_links(UrlGenerator $url)
 {
     $url->to('/', null)->shouldBeCalled()->willReturn('localhost');
     $this->beConstructedWith($url);
     $html = '<a href="localhost"><img src="http://placehold.it/100x100.png" /></a>';
     $this->linkImage('/', '<img src="http://placehold.it/100x100.png" />')->shouldReturn($html);
 }
开发者ID:nukacode,项目名称:front-end-materialize,代码行数:7,代码来源:HtmlBuilderSpec.php


示例4: calculateFullPath

 /**
  * @param array        $value
  * @param string       $route
  * @param UrlGenerator $router
  *
  * @return mixed|string
  */
 protected function calculateFullPath(array &$value, $route, UrlGenerator $router)
 {
     if (!empty($value['as_id'])) {
         preg_match_all('/{(.*?)}/', $route, $matches);
         $route = str_replace($matches[0], '{' . $value['as_id'] . '}', $route);
     }
     $port = parse_url($router->current(), PHP_URL_PORT);
     $port = null == $port ? '' : ':' . $port;
     $scheme = parse_url($router->current(), PHP_URL_SCHEME);
     $host = parse_url($router->current(), PHP_URL_HOST) . $port;
     return sprintf('%s://%s/%s', $scheme, $host, $route);
 }
开发者ID:nilportugues,项目名称:laravel5-hal-json,代码行数:19,代码来源:Laravel52Provider.php


示例5: handle

 /**
  * @param $request
  * @param \Closure $next
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         return new RedirectResponse(UrlGenerator::to('admin'));
     }
     return $next($request);
 }
开发者ID:darrengopower,项目名称:framework,代码行数:12,代码来源:RedirectIfAuthenticated.php


示例6: __construct

 /**
  * Create a new UrlGenerator instance.
  *
  * @param RouteCollection $routes
  * @param Request $request
  */
 public function __construct(RouteCollection $routes, Request $request)
 {
     parent::__construct(app('router')->getRoutes(), $request);
     $this->parser = app(Engine::class);
     if (defined('LOCALE')) {
         $this->forceRootUrl($this->getRootUrl($this->getScheme(null)) . '/' . LOCALE);
     }
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:14,代码来源:UrlGenerator.php


示例7: withBrand

 public function withBrand($brand, $link = null)
 {
     if (!isset($link)) {
         $link = $this->url->to('/');
     }
     $this->brand = compact('brand', 'link');
     return $this;
 }
开发者ID:AdrianSkierniewski,项目名称:bootstrapper,代码行数:8,代码来源:Navbar.php


示例8: getHomeUrl

 protected function getHomeUrl()
 {
     // wrap in value() to allow closures
     $enableHomeLink = value($this->config->get('c::enable-home-link', false));
     if ($enableHomeLink) {
         $url = $this->config->get('c::redirect-login', '/');
         return $this->url->to($url);
     }
     return null;
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:10,代码来源:MenuViewCreator.php


示例9: url

 /**
  * Return the URL for the file.
  *
  * @param array $attributes
  * @param null  $secure
  * @return string
  */
 public function url(array $attributes = [], $secure = null)
 {
     if ($secure === null) {
         $secure = $this->request->isSecure();
     }
     return $this->url->to($this->object->publicPath(), $attributes, $secure);
 }
开发者ID:bloveless,项目名称:files-module,代码行数:14,代码来源:FilePresenter.php


示例10: testPutURL

 public function testPutURL()
 {
     $this->sessionStorage->expects($this->exactly(2))->method('put');
     $this->urlGenerator->expects($this->once())->method('current')->will($this->returnValue('http://' . uniqid() . '.com'));
     $this->testInstance->putURL(uniqid());
     $this->testInstance->putURL(uniqid(), 'http://link.com');
 }
开发者ID:laravel-commode,项目名称:navigation-bag,代码行数:7,代码来源:NavigationBagTest.php


示例11: guess

 /**
  * Guess the HREF for a button.
  *
  * @param TableBuilder $builder
  */
 public function guess(TableBuilder $builder)
 {
     $buttons = $builder->getButtons();
     if (!($section = $this->sections->active())) {
         return;
     }
     if (!($module = $this->modules->active())) {
         return;
     }
     $stream = $builder->getTableStream();
     foreach ($buttons as &$button) {
         // If we already have an HREF then skip it.
         if (isset($button['attributes']['href'])) {
             continue;
         }
         switch (array_get($button, 'button')) {
             case 'restore':
                 $button['attributes']['href'] = $this->url->to('entry/handle/restore/' . $module->getNamespace() . '/' . $stream->getNamespace() . '/' . $stream->getSlug() . '/{entry.id}');
                 break;
             default:
                 // Determine the HREF based on the button type.
                 $type = array_get($button, 'segment', array_get($button, 'button'));
                 if ($type && !str_contains($type, '\\') && !class_exists($type)) {
                     $button['attributes']['href'] = $section->getHref($type . '/{entry.id}');
                 }
                 break;
         }
     }
     $builder->setButtons($buttons);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:35,代码来源:HrefGuesser.php


示例12: compose

 /**
  * @param View $view
  */
 public function compose(View $view)
 {
     $view->cruddyData = $this->cruddy->data();
     $view->cruddyData += ['schemaUrl' => $this->url->route('cruddy.schema'), 'thumbUrl' => $this->url->route('cruddy.thumb'), 'baseUrl' => $this->url->route('cruddy.home'), 'root' => $this->request->root(), 'token' => csrf_token()];
     $view->scripts = $this->assets->scripts();
     $view->styles = $this->assets->styles();
     $view->menu = $this->menuBuilder;
 }
开发者ID:guratr,项目名称:cruddy,代码行数:11,代码来源:LayoutComposer.php


示例13: the_default_config_can_be_overwritten_by_passing_arguments_to_get_login_url

 /** @test */
 public function the_default_config_can_be_overwritten_by_passing_arguments_to_get_login_url()
 {
     $this->url_mock->shouldReceive('to')->with('https://poop.fart/callback')->once()->andReturn('https://poop.fart/callback');
     $this->config_mock->shouldReceive('get')->never();
     $login_url = $this->laravel_facebook_sdk->getLoginUrl(['dance', 'totes'], 'https://poop.fart/callback');
     $this->assertContains('redirect_uri=https%3A%2F%2Fpoop.fart%2Fcallback', $login_url);
     $this->assertContains('scope=dance%2Ctotes', $login_url);
 }
开发者ID:abada,项目名称:videoGame,代码行数:9,代码来源:LaravelFacebookSdkTest.php


示例14: filter

 public function filter(Route $route, Request $request)
 {
     if ($this->auth->check()) {
         $config = $this->config->get('c::redirect-login');
         $url = $config ? $this->url->to($config) : '/';
         return $this->redirect->to($url);
     }
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:8,代码来源:GuestFilter.php


示例15: url

 /**
  * Generates a url for Sorter
  *
  * @param string $field
  * @param null|string $path
  * @param boolean $appends
  * */
 public function url($field, $path = null, $appends = true)
 {
     if ($path === null) {
         $path = $this->url->current();
     }
     $queryString = [$this->getFieldIndex() => $field, $this->getDirectionIndex() => $this->getConditionallyDirection($field)];
     $appends && ($queryString += $this->request->query());
     $url = $path . '?' . http_build_query($queryString);
     return $this->url->to($url);
 }
开发者ID:laravellegends,项目名称:sorter,代码行数:17,代码来源:Sorter.php


示例16: guess

 /**
  * Guess the HREF for the views.
  *
  * @param TableBuilder $builder
  */
 public function guess(TableBuilder $builder)
 {
     $views = $builder->getViews();
     foreach ($views as &$view) {
         // Only automate it if not set.
         if (!isset($view['attributes']['href'])) {
             $view['attributes']['href'] = $this->url->to($this->request->path() . '?' . array_get($view, 'prefix') . 'view=' . $view['slug']);
         }
     }
     $builder->setViews($views);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:16,代码来源:HrefGuesser.php


示例17: getIndex

 public function getIndex($status = '')
 {
     $threadCount = $this->request->get('take', $this->threadsPerPage);
     $tags = $this->tags->getAllTagsBySlug($this->request->get('tags'));
     $threads = $this->threads->getByTagsAndStatusPaginated($tags, $status, $threadCount);
     $collection = $threads->getCollection();
     $collection->each(function ($thread) {
         $thread->url = $this->url->action('ForumController@getViewThread', ['slug' => $thread->slug]);
     });
     // We want the newest threads to come out in chronological order
     return $collection->reverse();
 }
开发者ID:sdlyhu,项目名称:laravelio,代码行数:12,代码来源:ForumThreadsController.php


示例18: getUrl

 /**
  * {@inheritdoc}
  * @throws \Plank\Mediable\Exceptions\MediaUrlException If media's disk is not publicly accessible
  */
 public function getUrl()
 {
     $path = $this->getPublicPath();
     $url = $this->getDiskConfig('url');
     if ($url) {
         if ($this->isInWebroot()) {
             $path = $this->media->getDiskPath();
         }
         return rtrim($url, '/') . '/' . trim($path, '/');
     }
     return $this->url->asset($path);
 }
开发者ID:plank,项目名称:laravel-mediable,代码行数:16,代码来源:LocalUrlGenerator.php


示例19: makeResponse

 protected function makeResponse(Request $request)
 {
     $message = $this->translator->get('c::auth.login-required');
     if ($request->ajax() || $request->isJson() || $request->wantsJson()) {
         return Response::json(['error' => $message], 403);
     } else {
         $url = $this->url->action('anlutro\\Core\\Web\\AuthController@login');
         $intended = $request->getMethod() == 'GET' ? $request->fullUrl() : ($request->header('referer') ?: '/');
         $this->session->put('url.intended', $intended);
         return $this->redirect->to($url)->with('error', $message);
     }
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:12,代码来源:AuthFilter.php


示例20: url

 public function url($path = null, $parameters = [], $secure = null)
 {
     if (!$path) {
         return $this->url;
     }
     return $this->url->to($path, $parameters, $secure);
 }
开发者ID:rcrowe,项目名称:twigbridge,代码行数:7,代码来源:Url.php



注:本文中的Illuminate\Routing\UrlGenerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Session\SessionManager类代码示例发布时间:2022-05-23
下一篇:
PHP Routing\Router类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap