maj ninegate
Cadoles/nineskeletor/pipeline/head There was a failure building this commit Details

This commit is contained in:
afornerot 2023-01-10 11:47:07 +01:00
parent 88cfeae266
commit 09bd5e9e65
3 changed files with 26 additions and 16 deletions

View File

@ -16,6 +16,8 @@ class HomeController extends AbstractController
}
$em->getRepository("App\Entity\Item")->getUserItems($this->getUser(),$bookmarks,$items,$itemscategorys);
dump($items);
dump($itemscategorys);
return $this->render('Home/page.html.twig', [
'useheader' => true,
'usemenu' => false,

View File

@ -68,7 +68,6 @@ class ItemRepository extends ServiceEntityRepository
// Récupération des items par rôles
$itemsroles=[];
foreach($roles as $role) {
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('item')
@ -145,19 +144,6 @@ class ItemRepository extends ServiceEntityRepository
$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) {
// items uniquement
case 1: $bookmarks=null; break;
@ -165,5 +151,28 @@ class ItemRepository extends ServiceEntityRepository
// bookmarks uniquement
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);
}
}

View File

@ -12,7 +12,7 @@
{% endfor %}
{% 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">
{% for item in items %}
@ -47,5 +47,4 @@
{% endfor %}
</div>
{% endfor %}
{% endblock %}