From 964dc07c07b115a9b49d6c50800e60521172f48f Mon Sep 17 00:00:00 2001 From: Jacob Thomason <jacob@thomason.xxx> Date: Thu, 16 May 2019 13:39:56 +0800 Subject: [PATCH] Fixed relative template path assumption As this is currently written, it's difficult to write behaviors and specify a template dir since it's using the __DIR__ constant, effectively making it relative. The change keeps the same defaults, but expects a full absolute path, as it should be. --- src/Propel/Generator/Builder/Om/AbstractOMBuilder.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php index 1441c3e6cf..50279192bc 100644 --- a/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php +++ b/src/Propel/Generator/Builder/Om/AbstractOMBuilder.php @@ -992,12 +992,17 @@ public function getBehaviorContentBase($contentName, $modifier) * * @param string $filename * @param array $vars - * @param string $templateDir + * @param string|null $templateDir * @return string */ - public function renderTemplate($filename, $vars = [], $templateDir = '/templates/') + public function renderTemplate($filename, $vars = [], $templateDir = null) { - $filePath = __DIR__ . $templateDir . $filename; + if (!$templateDir) { + $filePath = __DIR__ . '/templates/' . $filename; + } else { + $filePath = $templateDir . $filename; + } + if (!file_exists($filePath)) { // try with '.php' at the end $filePath = $filePath . '.php';