From 19a9c36b8bba489f1c9d0cd2a6c372d43fc2318e Mon Sep 17 00:00:00 2001 From: Gab Date: Thu, 5 Sep 2019 13:43:05 +0100 Subject: [PATCH] Sanitise '-' when using pattern id as theme hook --- src/Definition/PatternDefinition.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Definition/PatternDefinition.php b/src/Definition/PatternDefinition.php index 07bf07c2..6d3a61a1 100644 --- a/src/Definition/PatternDefinition.php +++ b/src/Definition/PatternDefinition.php @@ -65,7 +65,10 @@ public function __construct(array $definition = []) { $this->id = $this->definition['id']; $this->setFields($this->definition['fields']); $this->setVariants($this->definition['variants']); - $this->setThemeHook(self::PATTERN_PREFIX . $this->id()); + // As we know allow hyphens the pattern ID, we need to sanitise it when + // setting pattern theme hook. + $hookFriendlyId = str_replace('-', '_', $this->id()); + $this->setThemeHook(self::PATTERN_PREFIX . $hookFriendlyId); if (!empty($definition['theme hook'])) { $this->setThemeHook($definition['theme hook']);