Use:
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Database;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Language\Language;
Language Manager:
$languageManager = \Drupal::service('language_manager');
$language_de = $languageManager->getLanguage('de');
URL / Link as HTML:
$url_string = "my-content-url-123";
$url = Url::fromUri('internal:'.$url_string, ['language' => $language_de] );
$link = Link::fromTextAndUrl($label, $url);
$link = $link->toRenderable();
$link['#attributes'] = ['class' => ['internal']];
$html = \Drupal::service('renderer')->render( $link );
Neuen Kommentar schreiben