class TestLanguageNegotiator in Language Selection Page 8.2
Test language negotiator.
Plugin annotation
@LanguageNegotiation(
id=\Drupal\language_selection_page_test\Plugin\LanguageNegotiation\TestLanguageNegotiator::METHOD_ID,
types={
\Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE,
\Drupal\Core\Language\LanguageInterface::TYPE_CONTENT,
\Drupal\Core\Language\LanguageInterface::TYPE_URL
},
weight=-20,
name=@Translation("Test Language Negotiator"),
description=@Translation("Test Language Negotiator"),
)
Hierarchy
- class \Drupal\language\LanguageNegotiationMethodBase implements LanguageNegotiationMethodInterface
- class \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl implements InboundPathProcessorInterface, OutboundPathProcessorInterface, LanguageSwitcherInterface
- class \Drupal\language_selection_page_test\Plugin\LanguageNegotiation\TestLanguageNegotiator
- class \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl implements InboundPathProcessorInterface, OutboundPathProcessorInterface, LanguageSwitcherInterface
Expanded class hierarchy of TestLanguageNegotiator
File
- tests/
modules/ src/ Plugin/ LanguageNegotiation/ TestLanguageNegotiator.php, line 26
Namespace
Drupal\language_selection_page_test\Plugin\LanguageNegotiationView source
class TestLanguageNegotiator extends LanguageNegotiationUrl {
/**
* The language negotiation method id.
*/
public const METHOD_ID = 'language-selection-page-test-negotiator';
/**
* {@inheritdoc}
*/
public function getLangcode(?Request $request = NULL) {
$request_path = urldecode(trim($request
->getPathInfo(), '/'));
if (strpos($request_path, '-fake') !== FALSE) {
return 'fake';
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function processInbound($path, Request $request) {
return str_replace('-fake', '', $path);
}
/**
* {@inheritdoc}
*/
public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) {
return $path . '-fake';
}
}