public function withBrand($brand, $link = null) { if (!isset($link)) { $link = $this->url->to('/'); } $this->brand = compact('brand', 'link'); return $this; }
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; }
/** * Bootstrap any application services. * * @return void */ public function boot(UrlGenerator $url) { // if (env('APP_ENV') !== 'local') { $url->forceSchema('https'); } }
public function __construct(UrlGenerator $url) { $this->middleware('auth'); $this->middleware('permission:dashboard')->only('getIndex'); $this->prev = $url->previous(); $this->module = 'admin'; }
/** * 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); }
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'); }
/** * 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); }
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); }
/** * @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; }
/** @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); }
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); } }
/** * 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); }
/** * 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); }
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(); }
/** * {@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); }
/** * @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); }
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); } }
public function url($path = null, $parameters = [], $secure = null) { if (!$path) { return $this->url; } return $this->url->to($path, $parameters, $secure); }
/** * Return true if current page is $page. */ public function isPage(string $page, array $parameters = []) : bool { // Check if $page is a route name if ($this->route->has($page)) { if ($parameters) { return $this->url->current() == $this->url->route($page, $parameters); } return $this->route->currentRouteName() == $page; } return str_replace($this->request->root() . '/', '', $this->url->full()) == $page; }
/** * {@inheritdoc} */ public function renderHead() { if (!$this->url) { return parent::renderHead(); } $jsModified = $this->getModifiedTime('js'); $cssModified = $this->getModifiedTime('css'); $html = ''; $html .= sprintf('<link rel="stylesheet" type="text/css" href="%s?%s">' . "\n", $this->url->route('debugbar.assets.css'), $cssModified); $html .= sprintf('<script type="text/javascript" src="%s?%s"></script>' . "\n", $this->url->route('debugbar.assets.js'), $jsModified); if ($this->isJqueryNoConflictEnabled()) { $html .= '<script type="text/javascript">jQuery.noConflict(true);</script>' . "\n"; } return $html; }
/** * {@inheritdoc} */ public function renderHead() { if (!$this->url) { return parent::renderHead(); } $cssRoute = $this->url->route('debugbar.assets.css', ['v' => $this->getModifiedTime('css')]); $jsRoute = $this->url->route('debugbar.assets.js', ['v' => $this->getModifiedTime('js')]); $html = ''; $html .= "<link rel='stylesheet' type='text/css' href='{$cssRoute}'>"; $html .= "<script type='text/javascript' src='{$jsRoute}'></script>"; if ($this->isJqueryNoConflictEnabled()) { $html .= '<script type="text/javascript">jQuery.noConflict(true);</script>' . "\n"; } return $html; }
protected function newGetRootUrl($scheme, $root = null) { if ($root == null) { $root = parent::getRootUrl($scheme) . (defined('LARAVEL_SHARED') ? '/public' : ''); } return parent::getRootUrl($scheme, $root); }
/** * @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); }
/** * Perform an API request to a controller action. * * @param string $action * @param string|array $actionParameters * @param string|array $parameters * @return mixed */ public function action($action, $actionParameters = [], $parameters = []) { $version = $this->version ?: $this->router->getDefaultVersion(); $route = $this->router->getApiRouteCollection($version)->getByAction($action); $uri = ltrim($this->url->route($action, $actionParameters, false, $route), '/'); return $this->queueRequest($route->methods()[0], $uri, $parameters); }
/** * Get a URL for a given page number. * * @param integer $page * @return string */ public function url($page) { if (null === $this->routeConfig) { //return parent::url($page); if ($page <= 0) { $page = 1; } // If we have any extra query string key / value pairs that need to be added // onto the URL, we will put them in query string form and then attach it // to the URL. This allows for extra information like sortings storage. $parameters = [$this->pageName => $page]; if (count($this->query) > 0) { $parameters = array_merge($this->query, $parameters); } return $this->getCurrentUrl() . '?' . http_build_query($parameters, null, '&') . $this->buildFragment(); } $parameters = $this->routeConfig['parameters']; //$parameters = [$this->pageName => $page]; //$this->getRequest()->query() if (true === $this->withQuery) { $parameters = array_merge($parameters, $this->query); } $parameters[$this->getPageName()] = $page; $absolute = null === $this->routeConfig['absolute'] ? true : $this->routeConfig['absolute']; // allow adding hash fragments to url $fragment = $this->buildFragment(); $generated_route = $this->urlGenerator->route($this->routeConfig['name'], $parameters, $absolute, $this->routeConfig['instance']); return $generated_route . $fragment; }
/** * Get the action for an "action" option. * * @param array|string $options * @return string */ protected function getControllerAction($options) { if (is_array($options)) { return $this->url->action($options[0], array_slice($options, 1)); } return $this->url->action($options); }
/** * Get the controller action for a "action" option. * * @param array|string $action * @return string */ protected function getAction($action) { if (is_array($action)) { return $this->url->action($action[0], array_slice($action, 1)); } return $this->url->action($action); }
/** * 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); } }
/** * Generate an HTML image element. * * @param string $url * @param string $alt * @param array $attributes * @return string */ public function image($url, $alt = null, $attributes = array()) { if (is_null($alt)) { $alt = $url; } $attributes['alt'] = $alt; return '<img src="' . $this->url->to($url) . '"' . $this->attributes($attributes) . '>'; }
/** * Guess the sections HREF attribute. * * @param ControlPanelBuilder $builder */ public function guess(ControlPanelBuilder $builder) { $sections = $builder->getSections(); foreach ($sections as $index => &$section) { // If HREF is set then skip it. if (isset($section['attributes']['href'])) { continue; } $module = $this->modules->active(); $href = $this->url->to('admin/' . $module->getSlug()); if ($index !== 0 && $module->getSlug() !== $section['slug']) { $href .= '/' . $section['slug']; } $section['attributes']['href'] = $href; } $builder->setSections($sections); }