Created
June 20, 2017 18:57
-
-
Save mikedotexe/c2a5304f47618dbb7dd9c27b8c727457 to your computer and use it in GitHub Desktop.
Get homepage path of Drupal 8 site from configuration
This file contains hidden or 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
<?php | |
use Drupal\Core\Config\Config; | |
// ... | |
$config = \Drupal::config('system.site'); | |
$front_uri = $config->get('page.front'); | |
$alias = \Drupal::service('path.alias_manager')->getAliasByPath($front_uri); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're doing this in anything but a procedural function, you should make sure to use dependency injection as using the
Drupal
global static object is meant only for legacy code and is considered bad practice elsewhere.