Browse Source

Add method to reset View::$hadRendered flag.

ADmad 7 years ago
parent
commit
4468de90d9
2 changed files with 15 additions and 1 deletions
  1. 1 1
      src/Mailer/Email.php
  2. 14 0
      src/View/View.php

+ 1 - 1
src/Mailer/Email.php

@@ -2749,7 +2749,7 @@ class Email implements JsonSerializable, Serializable
         }
 
         foreach ($types as $type) {
-            $View->hasRendered = false;
+            $View->resetHasRendered();
             $View->setTemplatePath('Email' . DIRECTORY_SEPARATOR . $type);
             $View->setLayoutPath('Email' . DIRECTORY_SEPARATOR . $type);
 

+ 14 - 0
src/View/View.php

@@ -1292,6 +1292,7 @@ class View implements EventDispatcherInterface
             'plugin' => 'setPlugin',
             'name' => 'setName',
             'elementCache' => 'setElementCache',
+            'hasRendered' => 'resetHasRendered',
         ];
         if (isset($protected[$name])) {
             $method = $protected[$name];
@@ -1442,6 +1443,19 @@ class View implements EventDispatcherInterface
     }
 
     /**
+     * Reset $hadRendered property to false to allow running render() again.
+     *
+     * @return $this
+     * @since 3.7.0
+     */
+    public function resetHasRendered()
+    {
+        $this->hasRendered = false;
+
+        return $this;
+    }
+
+    /**
      * Set sub-directory for this template files.
      *
      * @param string $subDir Sub-directory name.