Support form builder dependencies with non-Core templates
authorMatthias Schmidt <gravatronics@live.com>
Fri, 7 May 2021 05:49:15 +0000 (07:49 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 7 May 2021 05:49:15 +0000 (07:49 +0200)
wcfsetup/install/files/lib/system/form/builder/field/dependency/AbstractFormFieldDependency.class.php

index 7e4844d168df3ec6e3e77e91f78d1c9300d1a62a..213af182a6deb68833e5a880270c9a0853963faf 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace wcf\system\form\builder\field\dependency;
 
+use wcf\system\application\ApplicationHandler;
 use wcf\system\form\builder\field\IFormField;
 use wcf\system\form\builder\IFormNode;
 use wcf\system\WCF;
@@ -47,6 +48,13 @@ abstract class AbstractFormFieldDependency implements IFormFieldDependency
      */
     protected $templateName;
 
+    /**
+     * abbreviation of the application the template belongs to
+     * @var string
+     * @since   5.4
+     */
+    protected $templateNameApplication = 'wcf';
+
     /**
      * @inheritDoc
      */
@@ -133,8 +141,11 @@ abstract class AbstractFormFieldDependency implements IFormFieldDependency
         if ($this->templateName === null) {
             throw new \LogicException("Template name is not set.");
         }
+        if (ApplicationHandler::getInstance()->getApplication($this->templateNameApplication) === null) {
+            throw new \LogicException("Unknown application with abbreviation '{$this->templateNameApplication}'.");
+        }
 
-        return WCF::getTPL()->fetch($this->templateName, 'wcf', [
+        return WCF::getTPL()->fetch($this->templateName, $this->templateNameApplication, [
             'dependency' => $this,
         ], true);
     }