Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Only wrap config and DCA files in namespaces blocks (see #8635).
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Mar 20, 2017
1 parent 8e2b5b7 commit 31f43d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions system/modules/core/library/Contao/Automator.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public function generateConfigCache()

if (file_exists(TL_ROOT . '/' . $strFile))
{
$objCacheFile->append(static::readPhpFileWithoutTags($strFile));
$objCacheFile->append(static::readPhpFileWithoutTags($strFile, true));
}
}

Expand All @@ -521,7 +521,7 @@ public function generateConfigCache()

if (file_exists(TL_ROOT . '/' . $strFile))
{
$objCacheFile->append(static::readPhpFileWithoutTags($strFile));
$objCacheFile->append(static::readPhpFileWithoutTags($strFile, true));
}
}

Expand Down Expand Up @@ -599,7 +599,7 @@ public function generateDcaCache()

if (file_exists(TL_ROOT . '/' . $strFile))
{
$objCacheFile->append(static::readPhpFileWithoutTags($strFile));
$objCacheFile->append(static::readPhpFileWithoutTags($strFile, true));
}
}

Expand Down
12 changes: 9 additions & 3 deletions system/modules/core/library/Contao/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,12 @@ public static function anonymizeIp($strIp)
/**
* Read the contents of a PHP file, stripping the opening and closing PHP tags
*
* @param string $strName The name of the PHP file
* @param string $strName The name of the PHP file
* @param boolean $blnAddNamespace Wrap the content into a namespace declaration
*
* @return string The PHP code without the PHP tags
*/
protected static function readPhpFileWithoutTags($strName)
protected static function readPhpFileWithoutTags($strName, $blnAddNamespace=false)
{
$strCode = rtrim(file_get_contents(TL_ROOT . '/' . $strName));

Expand All @@ -671,7 +672,12 @@ protected static function readPhpFileWithoutTags($strName)
$strCode = substr($strCode, 0, -2);
}

return sprintf("\nnamespace {%s\n\n}", rtrim($strCode));
if ($blnAddNamespace)
{
return sprintf("\nnamespace {%s\n\n}", rtrim($strCode));
}

return rtrim($strCode)."\n";
}


Expand Down

0 comments on commit 31f43d9

Please sign in to comment.