diff --git a/core/lib/Drupal/Core/Path/PathMatcher.php b/core/lib/Drupal/Core/Path/PathMatcher.php index fada60a..9a8a7bf 100644 --- a/core/lib/Drupal/Core/Path/PathMatcher.php +++ b/core/lib/Drupal/Core/Path/PathMatcher.php @@ -29,13 +29,20 @@ class PathMatcher implements PathMatcherInterface { protected $regexes; /** + * The config factory service. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + + /** * Creates a new PathMatcher. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. */ public function __construct(ConfigFactoryInterface $config_factory) { - $this->frontPage = $config_factory->get('system.site')->get('page.front'); + $this->configFactory = $config_factory; } /** @@ -44,7 +51,12 @@ public function __construct(ConfigFactoryInterface $config_factory) { public function matchPath($path, array $patterns) { // Convert array to a string for easier find and replace. $pattern_string = implode("\n", $patterns); + if (!isset($this->regexes[$pattern_string])) { + // Lazy-load front page config. + if (!isset($this->frontPage)) { + $this->frontPage = $this->configFactory->get('system.site')->get('page.front'); + } // Convert path settings to a regular expression. $to_replace = array( // Replace newlines with a logical 'or'.