DomainConfigUIManager.php in Domain Access 8
File
domain_config_ui/src/DomainConfigUIManager.php
View source
<?php
namespace Drupal\domain_config_ui;
use Symfony\Component\HttpFoundation\RequestStack;
class DomainConfigUIManager implements DomainConfigUIManagerInterface {
protected $requestStack;
protected $currentRequest;
public function __construct(RequestStack $request_stack) {
$this->requestStack = $request_stack;
}
public function getSelectedConfigName($name, $omit_language = FALSE) {
if ($domain_id = $this
->getSelectedDomainId()) {
$prefix = "domain.config.{$domain_id}.";
if (!$omit_language && ($langcode = $this
->getSelectedLanguageId())) {
$prefix .= "{$langcode}.";
}
return $prefix . $name;
}
return $name;
}
public function getSelectedDomainId() {
if (!empty($this
->getRequest()) && ($domain = $this->currentRequest
->get('domain_config_ui_domain'))) {
return $domain;
}
elseif (isset($_SESSION['domain_config_ui_domain'])) {
return $_SESSION['domain_config_ui_domain'];
}
}
public function getSelectedLanguageId() {
if (!empty($this
->getRequest()) && ($language = $this->currentRequest
->get('domain_config_ui_language'))) {
return $language;
}
elseif (isset($_SESSION['domain_config_ui_language'])) {
return $_SESSION['domain_config_ui_language'];
}
}
private function getRequest() {
if (!isset($this->currentRequest)) {
$this->currentRequest = $this->requestStack
->getCurrentRequest();
}
return $this->currentRequest;
}
}