Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for session lookup for active site #102

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ before_script:
- phpenv rehash
- phpenv config-rm xdebug.ini
- composer validate
- composer require --dev --no-update silverstripe/recipe-cms:1.0.x-dev
- composer require --dev --no-update silverstripe/recipe-cms:1.0.0
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile

script:
Expand Down
13 changes: 13 additions & 0 deletions src/Multisites.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class Multisites
* @var Array - A list of features to be used on a given Site, identified by developer_identifiers
*/
private static $site_features;

/**
*
* @var boolean
*/
private static $allow_site_session_fallback = true;

/**
*
Expand Down Expand Up @@ -183,6 +189,13 @@ public function getDefaultSite()
*/
public function getCurrentSiteId()
{
if (self::$allow_site_session_fallback) {
$controller = Controller::has_curr() ? Controller::curr() : null;
$req = $controller ? $controller->getRequest() : null;
if ($id = $req->getSession()->get('Multisites_ActiveSite')) {
return $id;
}
}

// Re-parse the protocol and host to ensure it's in a consistent
// format.
Expand Down