/** * @param array $queryParams * @param array|object|null $meta * @return Link */ public function current(array $queryParams = [], $meta = null) { $url = $this->generator->current(); if ($queryParams) { $url .= '?' . http_build_query($queryParams); } return new Link($url, $meta, true); }
/** * Build documentation URL. * * @param array $documentation * * @return array */ protected function buildDocumentationUrl(array $documentation) { $current = $this->request->segment(2); foreach ($documentation as $doc) { $code = $doc->getCode(); if ($code !== $current && $this->foundation->is('app::docs*')) { $doc->setURL(strtr($this->urlGenerator->current(), [$current => $code])); } } return $documentation; }
/** * Creates a new menu. * * A menu will be typically created from the Menu generator class through * the Menu facade (Menu::make). * * @param Url $url * @param Theme $theme * @param $items */ public function __construct(URL $url, Theme $theme, $items) { $this->url = $url; $this->theme = $theme; $this->items = $items; $this->activeUrl = $this->url->current(); $this->baseUrl = $this->url->to(''); }
/** * Get the form action from the options. * * @param array $options * * @return string */ protected function getAction(array $options) { // We will also check for a "route" or "action" parameter on the array so that // developers can easily specify a route or controller action when creating // a form providing a convenient interface for creating the form actions. if (isset($options['url'])) { return $this->getUrlAction($options['url']); } if (isset($options['route'])) { return $this->getRouteAction($options['route']); } elseif (isset($options['action'])) { return $this->getControllerAction($options['action']); } return $this->url->current(); }
/** * Get the form action from the options. * * @param array $options * * @return string */ private function getAction(array $options) { // We will also check for a "route" or "action" parameter on the array so that // developers can easily specify a route or controller action when creating // a form providing a convenient interface for creating the form actions. if (isset($options['url'])) { return $this->getUrlAction($options['url']); } elseif (isset($options['route'])) { return $this->getRouteAction($options['route']); } elseif (isset($options['action'])) { // If an action is available, we are attempting to open a form to a controller // action route. So, we will use the URL generator to get the path to these // actions and return them from the method. Otherwise, we'll use current. return $this->getControllerAction($options['action']); } return $this->url->current(); }
/** * Renders the metadata. * * @param array $attributes * * @return string */ public function render(array $attributes = []) { $html = ''; // Add some default options $attributes = array_merge(['card' => 'summary', 'site' => $this->project, 'url' => $this->url->current()], $this->metadata, $attributes); // Format URLs if provided $image = array_get($attributes, 'image'); if (!file_exists($this->publicFolder . $image) || strpos($image, 'placeholder') !== false) { $image = $this->getPlaceholderIllustration(); } $attributes['image'] = $this->url->asset($image); // Get Twitter equivalents $twitterProperties = ['name' => 'title', 'image' => 'image:src']; // Append attributes foreach ($attributes as $name => $value) { $twitter = array_get($twitterProperties, $name, $name); $html .= $this->getWrapper($twitter, $name, $value) . PHP_EOL; } return $html; }
/** * Get the current URL for the request. * * @return string */ public function current() { return $this->url->current(); }