Skip to content

Commit

Permalink
AD-231 Configure example instance to get a valid domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Dani Esteban committed May 9, 2022
1 parent 44dd590 commit 4864052
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions instances/example/config/configuration_files.config.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php
include ROOT_PATH . '/vendor/sifophp/sifo-common-instance/config/configuration_files.config.php';
$config['locale'] = 'instances/example/config/locale.config.php';
$config['domains'] = 'instances/example/config/domains.config.php';
34 changes: 34 additions & 0 deletions instances/example/config/domains.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

$config['core_inheritance'] = array( 'Sifo' );

$config['redirections'] = array(
array( 'from' => 'www.sifo.local', 'to' => 'http://sifo.local' ),
array( 'from' => 'www2.sifo.local', 'to' => 'http://sifo.local' ),
);

$config['instance_type'] = 'instantiable';

$config['sifo.local'] = array(
'devel' => true, // Domain is marked as development
'has_debug' => true, // Domain shows the floating debug box.
'instance' => 'example',
'language' => 'en_US',
'language_domain' =>'messages',
'lang_in_subdomain' => array( 'es' => 'es_ES', 'en' => 'en_US' ),
'www_as_subdomain' => false,
'static_host' => 'http://static.sifo.local',
'media_host' => 'http://static.sifo.local', // Alternative static content (media). Comment to disable.
'database' => array(
'db_driver' => 'mysql', // To use transactions you must use mysqli driver.
'db_host' => '127.0.0.1',
'db_user' => 'root',
'db_password' => 'root',
'db_name' => 'yourdatabase',
'db_init_commands' => array( 'SET NAMES utf8' ) // Commands launched before the queries.
),
'php_ini_sets' => array( // Empty array if you don't want any php.ini overriden.
'log_errors' => 'On',
'error_log' => ROOT_PATH . '/logs/errors_' . date( 'Y-m' ) . '.log', // Store a different error file per month. For the lazy rotator :)
),
);
7 changes: 1 addition & 6 deletions src/Sifo/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static private function _initDomain()
{
self::$cookies = array( );
// Take domain from configuration to allow multiple subdomain compatibility with cookies.
self::$domain = static::domain();
self::$domain = Domains::getInstance()->getDomain();
self::$path = '/';
}

Expand Down Expand Up @@ -152,9 +152,4 @@ static protected function setCookie(string $name, $value = "", $expires = 0, $pa

return setcookie( $name, $value, $options );
}

static protected function domain()
{
return Domains::getInstance()->getDomain();
}
}
4 changes: 2 additions & 2 deletions test/Sifo/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testCookieIsSetWithExpectedDefaults(): void
"Expires doesn't match with expected."
);
$this->assertSame(
'example',
'sifo.local',
TestCookie::getDomain($cookieName),
"Domain doesn't match with expected."
);
Expand Down Expand Up @@ -62,7 +62,7 @@ public function testCookieIsSetWithCustomParameters(): void
"Expires doesn't match with expected."
);
$this->assertSame(
'example',
'sifo.local',
TestCookie::getDomain($cookieName),
"Domain doesn't match with expected."
);
Expand Down
5 changes: 0 additions & 5 deletions test/Sifo/TestCookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,4 @@ public static function clearCookies(): void
{
self::$cookies = [];
}

protected static function domain()
{
return 'example';
}
}
3 changes: 3 additions & 0 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
if (false === defined('ROOT_PATH')) {
define('ROOT_PATH', $rootDir);
}

$_SERVER['HTTP_HOST'] = 'sifo.local';

Bootstrap::$instance = 'example';

0 comments on commit 4864052

Please sign in to comment.