Skip to content

Commit

Permalink
Grouped templates by class so push or unshift templates based on class
Browse files Browse the repository at this point in the history
  • Loading branch information
gorriecoe committed Mar 2, 2018
1 parent d9540af commit 170a270
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/Models/BaseElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,27 +450,33 @@ public function getRenderTemplates($suffix = '')
$classes = ClassInfo::ancestry($this->ClassName);
$classes[static::class] = static::class;
$classes = array_reverse($classes);
$templates = array();
$templates = [];

foreach ($classes as $key => $value) {
if ($value == BaseElement::class) {
foreach ($classes as $key => $class) {
if ($class == BaseElement::class) {
continue;
}

if ($value == DataObject::class) {
if ($class == DataObject::class) {
break;
}

$this->extend('updateRenderTemplates', $templates, $value, $suffix);
if ($style = $this->Style) {
$templates[] = $value . $suffix . '_'. $this->getAreaRelationName() . '_' . $style;
$templates[] = $value . $suffix . '_' . $style;
$templates[$class][] = $class . $suffix . '_'. $this->getAreaRelationName() . '_' . $style;
$templates[$class][] = $class . $suffix . '_' . $style;
}
$templates[] = $value . $suffix . '_'. $this->getAreaRelationName();
$templates[] = $value . $suffix;
$templates[$class][] = $class . $suffix . '_'. $this->getAreaRelationName();
$templates[$class][] = $class . $suffix;
}

return $templates;
$this->extend('updateRenderTemplates', $templates, $suffix);

$templateFlat = [];
foreach ($templates as $class => $variations) {
$templateFlat = array_merge($templateFlat, $variations);
}

return $templateFlat;
}

/**
Expand Down

0 comments on commit 170a270

Please sign in to comment.