Skip to content

Commit f69982b

Browse files
committed
Merge pull request #256 from paulandrieux/bugfix/template-list
add a method to get Template inheritors
2 parents fa9a0fa + 3e141de commit f69982b

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

Bundle/BusinessPageBundle/Entity/BusinessTemplate.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,21 @@ public function setAuthorRestricted($authorRestricted)
110110
{
111111
$this->authorRestricted = $authorRestricted;
112112
}
113+
114+
/**
115+
* Get inheritors (all Templates having this object as Template).
116+
*
117+
* @return [Template]
118+
*/
119+
public function getTemplateInheritors()
120+
{
121+
$templateInheritors = [];
122+
foreach ($this->inheritors as $inheritor) {
123+
if ($inheritor instanceof self) {
124+
$templateInheritors[] = $inheritor;
125+
}
126+
}
127+
128+
return $templateInheritors;
129+
}
113130
}

Bundle/TemplateBundle/Entity/Template.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function setInheritors($inheritors)
147147
}
148148

149149
/**
150-
* Get inheritors (all Templates having this object as Template).
150+
* Get inheritors (all Views having this object as Template).
151151
*
152152
* @return [Template]
153153
*/
@@ -156,6 +156,23 @@ public function getInheritors()
156156
return $this->inheritors;
157157
}
158158

159+
/**
160+
* Get inheritors (all Templates having this object as Template).
161+
*
162+
* @return [Template]
163+
*/
164+
public function getTemplateInheritors()
165+
{
166+
$templateInheritors = [];
167+
foreach ($this->inheritors as $inheritor) {
168+
if ($inheritor instanceof self) {
169+
$templateInheritors[] = $inheritor;
170+
}
171+
}
172+
173+
return $templateInheritors;
174+
}
175+
159176
/**
160177
* @Assert\Callback(groups={"victoire"})
161178
*/

Bundle/TemplateBundle/Resources/views/Template/index.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
{% macro templatesHierarchy(templates) %}
1414
{% for template in templates %}
1515
<li id="list_{{template.id}}"><a href="{{path('victoire_template_show', {'slug' : template.slug })}}">{{ template.name }}</a>
16-
{% if template.inheritors %}
16+
{% if template.templateInheritors %}
1717
<ol>
18-
{{ _self.templatesHierarchy(template.inheritors) }}
18+
{{ _self.templatesHierarchy(template.templateInheritors) }}
1919
</ol>
2020
{% endif %}
2121
</li>

0 commit comments

Comments
 (0)