Merge pull request #6786 from mikenz/patch-10

Support booleans in SilverStripe\View\Parsers\Diff::getHTMLChunks
This commit is contained in:
Daniel Hensby 2017-05-11 11:58:31 +01:00 committed by GitHub
commit dcf23ac0e0
1 changed files with 7 additions and 2 deletions

View File

@ -161,15 +161,20 @@ class Diff extends \Diff
}
/**
* @param string|array $content If passed as an array, values will be concatenated with a comma.
* @param string|bool|array $content If passed as an array, values will be concatenated with a comma.
* @return array
*/
public static function getHTMLChunks($content)
{
if ($content && !is_string($content) && !is_array($content) && !is_numeric($content)) {
if ($content && !is_string($content) && !is_array($content) && !is_numeric($content) && !is_bool($content)) {
throw new InvalidArgumentException('$content parameter needs to be a string or array');
}
if (is_bool($content)) {
// Convert boolean to strings
$content = $content ? "true" : "false";
}
if (is_array($content)) {
// Convert array to CSV
$content = implode(',', $content);
}