Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed relative template path assumption #1513

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Propel/Generator/Builder/Om/AbstractOMBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the style used in https://github.com/propelorm/Propel2/pull/1491/files where the code uses realpath which would be less error-prone. Can we do something like that in this method?

}

if (!file_exists($filePath)) {
// try with '.php' at the end
$filePath = $filePath . '.php';
Expand Down