Ejemplo n.º 1
0
 /**
  * Resolve url's from any type of input.
  *
  * This method MUST either return a `\League\URL\URL` when a url is resolved
  * or null when a url cannot be resolved.
  *
  * @param array $arguments A list of the arguments
  * @param \League\URL\URLInterface $resolved
  *
  * @return \League\URL\URLInterface
  */
 public function resolve(array $arguments, $resolved = null)
 {
     if ($this->cached) {
         return $this->cached;
     }
     $url = Url::createFromUrl('');
     $url->setHost(null);
     $url->setScheme(null);
     if (\Config::get('concrete.seo.canonical_url')) {
         $canonical = UrlImmutable::createFromUrl(Config::get('concrete.seo.canonical_url'));
         // If the request is over https and the canonical url is http, lets just say https for the canonical url.
         if (strtolower($canonical->getScheme()) == 'http' && strtolower($this->request->getScheme()) == 'https') {
             $url->setScheme('https');
         } else {
             $url->setScheme($canonical->getScheme());
         }
         $url->setHost($canonical->getHost());
         if (intval($canonical->getPort()->get()) > 0) {
             $url->setPort($canonical->getPort());
         }
     } else {
         $host = $this->request->getHost();
         $scheme = $this->request->getScheme();
         if ($scheme && $host) {
             $url->setScheme($scheme)->setHost($host)->setPortIfNecessary(Request::getInstance()->getPort());
         }
     }
     if ($relative_path = \Core::getApplicationRelativePath()) {
         $url = $url->setPath($relative_path);
     }
     $this->cached = UrlImmutable::createFromUrl($url);
     return $this->cached;
 }
Ejemplo n.º 2
0
 /**
  * Get a database connection instance.
  *
  * @param  string $name
  * @return \Concrete\Core\Database\Connection\Connection
  */
 public function connection($name = null)
 {
     $name = $name ?: $this->getDefaultConnection();
     // If we haven't created this connection, we'll create it based on the config
     // provided in the application. Once we've created the connections we will
     // set the "fetch mode" for PDO which determines the query return types.
     if (!isset($this->connections[$name])) {
         $connection = $this->makeConnection($name);
         if (Config::get('concrete.log.queries.log')) {
             $connection->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack());
         }
         $this->connections[$name] = $this->prepare($connection);
     }
     return $this->connections[$name];
 }