-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from City-of-Helsinki/UHF-7126
UHF-7126: Allow non-html values to be processed, UHF-7193: fixed radioactivity
- Loading branch information
Showing
14 changed files
with
264 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\helfi_proxy; | ||
|
||
use Drupal\Core\Cache\RefinableCacheableDependencyInterface; | ||
use Drupal\Core\Cache\RefinableCacheableDependencyTrait; | ||
use Drupal\Core\Config\ConfigFactoryInterface; | ||
use Drupal\Core\Config\ImmutableConfig; | ||
use Drupal\Core\Language\LanguageInterface; | ||
use Drupal\Core\Language\LanguageManagerInterface; | ||
|
||
/** | ||
* A service to figure out currently active site prefix. | ||
*/ | ||
final class ActiveSitePrefix implements RefinableCacheableDependencyInterface { | ||
|
||
use RefinableCacheableDependencyTrait; | ||
|
||
/** | ||
* The configuration. | ||
* | ||
* @var \Drupal\Core\Config\ImmutableConfig | ||
*/ | ||
private ImmutableConfig $config; | ||
|
||
/** | ||
* Constructs a new instance. | ||
* | ||
* @param \Drupal\Core\Language\LanguageManagerInterface $languageManager | ||
* The language manager service. | ||
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory | ||
* The config factory. | ||
*/ | ||
public function __construct( | ||
private LanguageManagerInterface $languageManager, | ||
ConfigFactoryInterface $configFactory | ||
) { | ||
$this->config = $configFactory->get('helfi_proxy.settings'); | ||
$this->addCacheableDependency($this->config); | ||
} | ||
|
||
/** | ||
* Gets the site prefixes. | ||
* | ||
* @return array | ||
* The prefixes. | ||
*/ | ||
public function getPrefixes() : array { | ||
if (!$prefixes = $this->config->get(ProxyManagerInterface::PREFIXES)) { | ||
return []; | ||
} | ||
return $prefixes; | ||
} | ||
|
||
/** | ||
* Gets the currently active site prefix. | ||
* | ||
* @return string|null | ||
* The active prefix. | ||
*/ | ||
public function getPrefix(string $langcode = NULL) : ? string { | ||
$prefixes = $this->getPrefixes(); | ||
|
||
if (!$langcode) { | ||
$langcode = $this->languageManager | ||
->getCurrentLanguage(LanguageInterface::TYPE_URL) | ||
->getId(); | ||
} | ||
return $prefixes[$langcode] ?? NULL; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.