maj ninegate
Cadoles/nineskeletor/pipeline/head There was a failure building this commit
Details
Cadoles/nineskeletor/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
88cfeae266
commit
09bd5e9e65
|
@ -16,6 +16,8 @@ class HomeController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->getRepository("App\Entity\Item")->getUserItems($this->getUser(),$bookmarks,$items,$itemscategorys);
|
$em->getRepository("App\Entity\Item")->getUserItems($this->getUser(),$bookmarks,$items,$itemscategorys);
|
||||||
|
dump($items);
|
||||||
|
dump($itemscategorys);
|
||||||
return $this->render('Home/page.html.twig', [
|
return $this->render('Home/page.html.twig', [
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usemenu' => false,
|
'usemenu' => false,
|
||||||
|
|
|
@ -68,7 +68,6 @@ class ItemRepository extends ServiceEntityRepository
|
||||||
|
|
||||||
// Récupération des items par rôles
|
// Récupération des items par rôles
|
||||||
$itemsroles=[];
|
$itemsroles=[];
|
||||||
|
|
||||||
foreach($roles as $role) {
|
foreach($roles as $role) {
|
||||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||||
$qb->select('item')
|
$qb->select('item')
|
||||||
|
@ -145,19 +144,6 @@ class ItemRepository extends ServiceEntityRepository
|
||||||
|
|
||||||
$itemsordered=iterator_to_array($itemsordered);
|
$itemsordered=iterator_to_array($itemsordered);
|
||||||
|
|
||||||
// Catégories affichées
|
|
||||||
$itemcategorys = $this->getEntityManager()->getRepository('App\Entity\Itemcategory')->findBy([], ['rowOrder' => 'asc']);
|
|
||||||
if($iditemcategory && $itemcategoryfilter) $itemcategorys = $itemcategoryfilter;
|
|
||||||
else {
|
|
||||||
// On eleve les category sans item
|
|
||||||
foreach($itemcategorys as $key => $category) {
|
|
||||||
foreach($category->getItems() as $item) {
|
|
||||||
if(!in_array($item,$itemsordered)) {
|
|
||||||
unset($itemcategorys[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch($withbookmark) {
|
switch($withbookmark) {
|
||||||
// items uniquement
|
// items uniquement
|
||||||
case 1: $bookmarks=null; break;
|
case 1: $bookmarks=null; break;
|
||||||
|
@ -165,5 +151,28 @@ class ItemRepository extends ServiceEntityRepository
|
||||||
// bookmarks uniquement
|
// bookmarks uniquement
|
||||||
case 2: $itemsordered=null; break;
|
case 2: $itemsordered=null; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Catégories affichées
|
||||||
|
$itemcategorys=new ArrayCollection();
|
||||||
|
if($iditemcategory && $itemcategoryfilter) $itemcategorys = $itemcategoryfilter;
|
||||||
|
else {
|
||||||
|
foreach($itemsordered as $key => $item) {
|
||||||
|
if(!$itemcategorys->contains($item->getItemcategory()))
|
||||||
|
$itemcategorys->add($item->getItemcategory());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trie des itemcategorys
|
||||||
|
$itemcategorysordered = $itemcategorys->getIterator();
|
||||||
|
$itemcategorysordered->uasort(function ($first, $second) {
|
||||||
|
if((int) $first->getRowOrder() > (int) $second->getRowOrder())
|
||||||
|
$return=1;
|
||||||
|
else
|
||||||
|
$return=-1;
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
});
|
||||||
|
|
||||||
|
$itemcategorys=iterator_to_array($itemcategorysordered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for itemcategory in itemcategorys %}
|
{% for itemcategory in itemcategorys %}
|
||||||
{% if itemcategorys|length > 1 %} <h2>{{itemcategory.label}}</h2> {% endif %}
|
{% if itemcategorys|length > 1 %} <h2 {% if not loop.first %} class="mt-3" {% endif %}>{{itemcategory.label}}</h2> {% endif %}
|
||||||
|
|
||||||
<div class="items-list">
|
<div class="items-list">
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
|
@ -47,5 +47,4 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue