예제 #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;
 }
예제 #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];
 }
예제 #3
0
 */
$cms = (require $DIR_BASE_CORE . '/bootstrap/start.php');
/**
 * Test more strictly than core settings
 */
error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
class TestConfigRepository extends Repository
{
    public function save($key, $value)
    {
        return true;
    }
}
$old_config = $cms->make('config');
$cms->instance('config', new TestConfigRepository($old_config->getLoader(), $old_config->getSaver(), 'travis'));
\Concrete\Core\Support\Facade\Config::clearResolvedInstance('config');
\Config::set('concrete.seo.canonical_url', null);
/** @var Repository $config */
$config = $cms->make('config');
$config->set('database.default-connection', 'travis');
$config->set('database.connections.travis', array('driver' => 'c5_pdo_mysql', 'server' => 'localhost', 'database' => 'concrete5_tests', 'username' => 'travis', 'password' => '', 'charset' => 'utf8'));
$config->set('database.connections.travisWithoutDB', array('driver' => 'c5_pdo_mysql', 'server' => 'localhost', 'username' => 'travis', 'password' => '', 'charset' => 'utf8'));
$config->get('concrete');
$config->set('concrete.cache.blocks', false);
$config->set('concrete.cache.pages', false);
$config->set('concrete.cache.enabled', false);
$cn = $cms->make('database')->connection('travisWithoutDB');
$cn->query('DROP DATABASE IF EXISTS concrete5_tests');
$cn->query('CREATE DATABASE concrete5_tests');
$cn->close();
/**