TestLanguageNegotiator.php in Language Selection Page 8.2
File
tests/modules/src/Plugin/LanguageNegotiation/TestLanguageNegotiator.php
View source
<?php
declare (strict_types=1);
namespace Drupal\language_selection_page_test\Plugin\LanguageNegotiation;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
use Symfony\Component\HttpFoundation\Request;
class TestLanguageNegotiator extends LanguageNegotiationUrl {
public const METHOD_ID = 'language-selection-page-test-negotiator';
public function getLangcode(?Request $request = NULL) {
$request_path = urldecode(trim($request
->getPathInfo(), '/'));
if (strpos($request_path, '-fake') !== FALSE) {
return 'fake';
}
return NULL;
}
public function processInbound($path, Request $request) {
return str_replace('-fake', '', $path);
}
public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) {
return $path . '-fake';
}
}