コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function to($path, $extra = [], $secure = null)
 {
     $url = $this->url->to($path, $extra, $secure);
     $permission = $this->securityApi->permissions()->getForPath($url);
     $this->checkPermission($permission);
     return $url;
 }
コード例 #2
0
 /**
  * Guess the HREF for a button.
  *
  * @param ControlPanelBuilder $builder
  */
 public function guess(ControlPanelBuilder $builder)
 {
     $buttons = $builder->getButtons();
     $sections = $builder->getControlPanelSections();
     $active = $sections->active();
     $module = $this->modules->active();
     foreach ($buttons as &$button) {
         // If we already have an HREF then skip it.
         if (isset($button['attributes']['href'])) {
             continue;
         }
         // Determine the HREF based on the button type.
         switch (array_get($button, 'button')) {
             case 'add':
             case 'new':
             case 'create':
                 $button['attributes']['href'] = $active->getHref('create');
                 break;
             case 'export':
                 if ($module) {
                     $button['attributes']['href'] = $this->url->to('entry/handle/export/' . $module->getNamespace() . '/' . array_get($button, 'namespace') . '/' . array_get($button, 'stream'));
                 }
                 break;
         }
         $type = array_get($button, 'segment', array_get($button, 'button'));
         if (!isset($button['attributes']['href']) && $type) {
             $button['attributes']['href'] = $active->getHref($type);
         }
     }
     $builder->setButtons($buttons);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function url($path, $absolute = true)
 {
     if ($absolute === false) {
         return $path;
     }
     return $this->urlGenerator->to($path);
 }
コード例 #4
0
 /**
  * Create a new Redirect response.
  *
  * @param RedirectInterface $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function create(RedirectInterface $redirect)
 {
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($this->route->parameterNames())), $this->route->parameters());
     if (!starts_with($url = $redirect->getTo(), ['http://', 'https://', '//'])) {
         $url = $this->url->to($redirect->getTo(), [], $redirect->isSecure());
     }
     return $this->redirector->to(rtrim($this->parser->parse($url, $parameters), '/'), $redirect->getStatus());
 }
コード例 #5
0
 /**
  * Generate a absolute URL to the given path.
  *
  * @param  string  $path
  * @param  mixed  $extra
  * @param  bool  $secure
  * @return string
  */
 public function url($path, $extra = [], $secure = null)
 {
     // Do not modify path if it starts with `http`.
     if (preg_match('/^http/', $path)) {
         return $this->url->to($path, $extra, $secure);
     }
     if ($this->isCurrentLocaleDefault()) {
         return $this->url->to($path, $extra, $secure);
     }
     $path = $this->config->get('app.locale') . '/' . $path;
     return $this->url->to($path, $extra, $secure);
 }
コード例 #6
0
ファイル: Html.php プロジェクト: huglester/streams-platform
 /**
  * Get the action for a "url" option.
  *
  * @param array|string $options
  *
  * @return string
  */
 protected function getUrlAction($options)
 {
     if (is_array($options)) {
         return $this->url->to($options[0], array_slice($options, 1));
     }
     return $this->url->to($options);
 }
コード例 #7
0
 /**
  * Map the redirect routes.
  *
  * @param UrlGenerator                $url
  * @param Router                      $router
  * @param Request                     $request
  * @param RedirectRepositoryInterface $redirects
  * @internal param Filesystem $files
  * @internal param Application $application
  */
 public function map(UrlGenerator $url, Router $router, Request $request, RedirectRepositoryInterface $redirects)
 {
     if ($request->segment(1) == 'admin') {
         return;
     }
     /* @var RedirectInterface $redirect */
     foreach ($redirects->sorted() as $redirect) {
         if (!starts_with($parsed = $redirect->getFrom(), ['http://', 'https://', '//'])) {
             $parsed = $url->to($redirect->getFrom());
         }
         $parsed = parse_url(preg_replace_callback("/\\{[a-z]+\\?\\}/", function ($matches) {
             return str_replace('?', '!', $matches[0]);
         }, $parsed));
         if (isset($parsed['host']) && $parsed['host'] == $request->getHost()) {
             /**
              * Route a domain redirect in a domain group.
              */
             $router->group(['domain' => $parsed['host']], function () use($parsed, $router, $redirect) {
                 $path = ltrim(preg_replace_callback("/\\{[a-z]+\\!\\}/", function ($matches) {
                     return str_replace('!', '?', $matches[0]);
                 }, $parsed['path']), '/');
                 $router->any($path ?: '/', ['uses' => 'Anomaly\\RedirectsModule\\Http\\Controller\\RedirectsController@handle', 'redirect' => $redirect->getId()])->where(['any' => '(.*)', 'path' => '(.*)']);
             });
         } else {
             /**
              * Route a standard redirect.
              */
             $router->any($redirect->getFrom(), ['uses' => 'Anomaly\\RedirectsModule\\Http\\Controller\\RedirectsController@handle', 'redirect' => $redirect->getId()])->where(['any' => '(.*)', 'path' => '(.*)']);
         }
     }
 }
コード例 #8
0
ファイル: HtmlBuilder.php プロジェクト: stevebauman/html
 /**
  * Generate a HTML link.
  *
  * @param  string  $url
  * @param  string  $title
  * @param  array   $attributes
  * @param  bool    $secure
  *
  * @return string
  */
 public function link($url, $title = null, $attributes = [], $secure = null)
 {
     $url = $this->url->to($url, [], $secure);
     if (is_null($title) || $title === false) {
         $title = $url;
     }
     return '<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $this->entities($title) . '</a>';
 }
コード例 #9
0
ファイル: HtmlBuilder.php プロジェクト: ARCANEDEV/LaravelHtml
 /**
  * Generate a HTML link.
  *
  * @param  string  $url
  * @param  string  $title
  * @param  array   $attributes
  * @param  bool    $secure
  * @param  bool    $escaped
  *
  * @return \Illuminate\Support\HtmlString
  */
 public function link($url, $title = null, $attributes = [], $secure = null, $escaped = true)
 {
     $url = $this->url->to($url, [], $secure);
     if (is_null($title) || $title === false) {
         $title = $url;
     }
     return $this->toHtmlString('<a href="' . $url . '"' . $this->attributes($attributes) . '>' . ($escaped ? $this->entities($title) : $title) . '</a>');
 }
コード例 #10
0
 /**
  * Generate a page URL, based on the request's current URL.
  *
  * @param int  $page
  * @param bool $full Return the full version of the URL in for the first page
  *                   Ex. /users/page/1 instead of /users
  *
  * @return string
  */
 public function pageUrl($page, $full = false)
 {
     $currentPageUrl = $this->router->getCurrentRoute()->getUri();
     $url = $this->addPageQuery(str_replace('{pageQuery?}', '', $currentPageUrl), $page, $full);
     foreach ($this->router->getCurrentRoute()->bindParameters(app('request')) as $parameterName => $parameterValue) {
         $url = str_replace(['{' . $parameterName . '}', '{' . $parameterName . '?}'], $parameterValue, $url);
     }
     return $this->urlGenerator->to($url);
 }
コード例 #11
0
ファイル: Navigation.php プロジェクト: ssomenzi/silence
 /**
  * Convert slugs to urls.
  *
  * @param array $nav
  *
  * @return array
  */
 protected function process(array $nav)
 {
     // convert slugs to urls
     foreach ($nav as $key => $value) {
         // if the url is not set
         if (!isset($value['url'])) {
             // set the url based on the slug
             $nav[$key]['url'] = $this->url->to($value['slug']);
         }
         // remove any remaining slugs
         unset($nav[$key]['slug']);
     }
     // spit out the nav bar array at the end
     return $nav;
 }
コード例 #12
0
 /**
  * Get the previous page url
  * 
  * @param  bool $full  Return the full version of the url in for the first page
  *                     Ex. /users/page/1 instead of /users
  * @return string|null
  */
 public function previousPageUrl($full = false)
 {
     $previousPage = $this->previousPage();
     if ($previousPage === null) {
         return null;
     }
     // This should call the current action with a different parameter
     // Afaik there's no cleaner way to do this
     $currentPageUrl = new String($this->router->getCurrentRoute()->getUri());
     if ($previousPage === 1 && !$full) {
         $previousPageUrl = $currentPageUrl->replaceLast($this->pageName . '/{page}', '');
     } else {
         $previousPageUrl = $currentPageUrl->replaceLast('{page}', $previousPage);
     }
     return $this->urlGenerator->to($previousPageUrl);
 }
コード例 #13
0
ファイル: Menu.php プロジェクト: phroggyy/html
 /**
  * Generates the menu item URL, using any of the following options, in order:
  *
  * If you pass a 'full_url' key within the item configuration, in that case
  * it will return it as the URL with no additional action.
  *
  * If you pass a 'url' key then it will call the Url::to method to complete
  * the base URL, you can also specify a 'secure' key to indicate whether
  * this URL should be secure or not. Otherwise the defaultSecure option will
  * be used.
  *
  * If you pass a 'route' key then it will call the getRouteAndParameters to
  * return the route's name and its parameters, then it will call Url::route
  *
  * If you pass an 'action' key it'd be processed in a similar way as the
  * route key, but calling the Url::action method instead.
  *
  * If none of these options are found then this function will simple return
  * a placeholder (#).
  *
  *
  * @param $values
  * @return mixed
  */
 protected function generateUrl($values)
 {
     if (isset($values['full_url'])) {
         return $values['full_url'];
     }
     if (isset($values['url'])) {
         $isSecure = isset($values['secure']) ? $values['secure'] : $this->defaultSecure;
         return $this->url->to($values['url'], $isSecure);
     }
     if (isset($values['route'])) {
         list($route, $params) = $this->getRouteAndParameters($values['route']);
         return $this->url->route($route, $params);
     }
     if (isset($values['action'])) {
         list($route, $params) = $this->getRouteAndParameters($values['action']);
         return $this->url->action($route, $params);
     }
     return '#';
 }
コード例 #14
0
 function it_passes_prefixed_url_to_url_when_locale_is_not_default(Config $config, UrlGenerator $url)
 {
     $config->get('app.locale')->willReturn('en');
     $url->to('en/home', [], null)->shouldBeCalled();
     $this->url('home');
 }
コード例 #15
0
 /**
  * Return a URL.
  *
  * @param null  $path
  * @param array $parameters
  * @param null  $secure
  * @return string
  */
 public function url($path = null, $parameters = [], $secure = null)
 {
     return $this->url->to($path, $parameters, $secure);
 }
コード例 #16
0
 /**
  * Returns the current Url
  *
  **/
 public function currentUrl()
 {
     return $this->urlGenerator->to($this->request->getPathInfo());
 }
コード例 #17
0
ファイル: LaravelFacebookSdk.php プロジェクト: SAEMA/project
 /**
  * Get the fallback callback redirect URL if none provided.
  *
  * @param string $callback_url
  *
  * @return string
  */
 private function getCallbackUrl($callback_url)
 {
     $callback_url = $callback_url ?: $this->config_handler->get('laravel-facebook-sdk.default_redirect_uri');
     return $this->url->to($callback_url);
 }
コード例 #18
0
ファイル: LocaleUrl.php プロジェクト: thinktomorrow/locale
 /**
  * Generate url via illuminate
  *
  * @param $url
  * @param array $extra
  * @param null $secure
  * @return string
  */
 private function resolveUrl($url, $extra = [], $secure = null)
 {
     return $this->generator->to($url, $extra, $secure);
 }
コード例 #19
0
 /**
  * @return string
  */
 public function getBaseUri()
 {
     return $this->urlGenerator->to('/');
 }
コード例 #20
0
ファイル: FormBuilder.php プロジェクト: ARCANEDEV/LaravelHtml
 /**
  * Get the action for a "url" option.
  *
  * @param  array|string  $options
  *
  * @return string
  */
 private function getUrlAction($options)
 {
     return is_array($options) ? $this->url->to($options[0], array_slice($options, 1)) : $this->url->to($options);
 }