From 90272d7ff875ae08a8e09a80fdfb318cc0b63642 Mon Sep 17 00:00:00 2001 From: Fabian Helfer Date: Wed, 19 Apr 2023 11:18:21 +0200 Subject: [PATCH] review dashboard #4 blockdto --- ...lBlockDataDTO.php => class.ilBlockDTO.php} | 2 +- .../classes/class.ilDashboardBlockGUI.php | 32 +++++++++---------- .../class.ilLearningSequenceBlockGUI.php | 2 +- .../classes/class.ilMembershipBlockGUI.php | 2 +- .../class.ilRecommendedContentBlockGUI.php | 2 +- .../classes/class.ilSelectedItemsBlockGUI.php | 2 +- .../class.ilStudyProgrammeBlockGUI.php | 4 +-- 7 files changed, 23 insertions(+), 23 deletions(-) rename Services/Dashboard/Block/classes/{class.ilBlockDataDTO.php => class.ilBlockDTO.php} (99%) diff --git a/Services/Dashboard/Block/classes/class.ilBlockDataDTO.php b/Services/Dashboard/Block/classes/class.ilBlockDTO.php similarity index 99% rename from Services/Dashboard/Block/classes/class.ilBlockDataDTO.php rename to Services/Dashboard/Block/classes/class.ilBlockDTO.php index cc716ab64620..97a17b802e40 100644 --- a/Services/Dashboard/Block/classes/class.ilBlockDataDTO.php +++ b/Services/Dashboard/Block/classes/class.ilBlockDTO.php @@ -17,7 +17,7 @@ *********************************************************************/ declare(strict_types=1); -class ilBlockDataDTO +class ilBlockDTO { private string $type; private int $ref_id; diff --git a/Services/Dashboard/Block/classes/class.ilDashboardBlockGUI.php b/Services/Dashboard/Block/classes/class.ilDashboardBlockGUI.php index 0bcec19a2cc5..79847d1e7cfe 100644 --- a/Services/Dashboard/Block/classes/class.ilDashboardBlockGUI.php +++ b/Services/Dashboard/Block/classes/class.ilDashboardBlockGUI.php @@ -74,7 +74,7 @@ abstract public function addCustomCommandsToActionMenu(ilObjectListGUI $itemList abstract public function emptyHandling(): string; - protected function getCardForData(ilBlockDataDTO $data): ?RepositoryObject + protected function getCardForData(ilBlockDTO $data): ?RepositoryObject { $itemListGui = $this->byType($data->getType()); $card = $itemListGui->getAsCard( @@ -107,7 +107,7 @@ protected function getListItemGroups(): array return $groupedCards; } - protected function getListItemForDataDTO(ilBlockDataDTO $data): ?Item + protected function getListItemForDataDTO(ilBlockDTO $data): ?Item { $itemListGui = $this->byType($data->getType()); $this->addCustomCommandsToActionMenu($itemListGui, $data->getRefId()); @@ -200,18 +200,18 @@ public function getHTML(): string } /** - * @param array $a_data + * @param array $a_data */ public function setData(array $a_data): void { $this->data = array_filter(array_map( - static fn ($group) => array_filter($group, fn ($item) => $item instanceof ilBlockDataDTO), + static fn ($group) => array_filter($group, fn ($item) => $item instanceof ilBlockDTO), $a_data )); } /** - * @return array + * @return array */ public function getData(): array { @@ -219,12 +219,12 @@ public function getData(): array } /** - * @return array + * @return array */ public function groupItemsByStartDate(): array { $data = $this->getData(); - /** @var ilBlockDataDTO[] $items */ + /** @var ilBlockDTO[] $items */ $items = array_merge(...array_values($data)); $groups = [ @@ -247,7 +247,7 @@ public function groupItemsByStartDate(): array } } - $orderByDate = static function (ilBlockDataDTO $left, ilBlockDataDTO $right, bool $asc = true) { + $orderByDate = static function (ilBlockDTO $left, ilBlockDTO $right, bool $asc = true) { if ($left->getStartDate() && $right->getStartDate() && $left->getStartDate()->get( IL_CAL_UNIX ) < $right->getStartDate()->get(IL_CAL_UNIX)) { @@ -277,7 +277,7 @@ public function groupItemsByStartDate(): array } /** - * @return array + * @return array */ protected function groupItemsByType(): array { @@ -286,7 +286,7 @@ protected function groupItemsByType(): array ); $grouped_items = []; $data = $this->getData(); - /** @var ilBlockDataDTO[] $data */ + /** @var ilBlockDTO[] $data */ $data = array_merge(...array_values($data)); $provider = new ilPDSelectedItemsBlockMembershipsProvider($this->viewSettings->getActor()); @@ -317,17 +317,17 @@ protected function groupItemsByType(): array } /** - * @return array + * @return array */ protected function groupItemsByLocation(): array { $grouped_items = []; $data = $this->getData(); - /** @var ilBlockDataDTO[] $data */ + /** @var ilBlockDTO[] $data */ $data = array_merge(...array_values($data)); $parent_ref_ids = array_values(array_unique( - array_map(fn (ilBlockDataDTO $item): ?int => $this->tree->getParentId($item->getRefId()), $data) + array_map(fn (ilBlockDTO $item): ?int => $this->tree->getParentId($item->getRefId()), $data) )); $this->object_cache->preloadReferenceCache($parent_ref_ids); @@ -464,7 +464,7 @@ protected function returnToContext(): void } /** - * @return array + * @return array */ public function getItemGroups(): array { @@ -741,13 +741,13 @@ public function byType(string $a_type): ilObjectListGUI } /** - * @param ilBlockDataDTO[] $data + * @param ilBlockDTO[] $data */ private function sortByTitle(array $data, bool $asc = true): array { uasort( $data, - static fn (ilBlockDataDTO $left, ilBlockDataDTO $right) => $asc ? + static fn (ilBlockDTO $left, ilBlockDTO $right) => $asc ? strcmp($left->getTitle(), $right->getTitle()) : strcmp($right->getTitle(), $left->getTitle()) ); diff --git a/Services/Dashboard/Block/classes/class.ilLearningSequenceBlockGUI.php b/Services/Dashboard/Block/classes/class.ilLearningSequenceBlockGUI.php index dd4f3a9e4319..4c471fea8978 100644 --- a/Services/Dashboard/Block/classes/class.ilLearningSequenceBlockGUI.php +++ b/Services/Dashboard/Block/classes/class.ilLearningSequenceBlockGUI.php @@ -76,7 +76,7 @@ public function initData(): void continue; } - $data[] = new ilBlockDataDTO( + $data[] = new ilBlockDTO( 'lso', $lso_ref_id, $lso_obj->getId(), diff --git a/Services/Dashboard/Block/classes/class.ilMembershipBlockGUI.php b/Services/Dashboard/Block/classes/class.ilMembershipBlockGUI.php index 2dbd10f94df0..6a35c62ed826 100644 --- a/Services/Dashboard/Block/classes/class.ilMembershipBlockGUI.php +++ b/Services/Dashboard/Block/classes/class.ilMembershipBlockGUI.php @@ -47,7 +47,7 @@ public function initData(): void $data = array_map(static function (array $item) { $start = isset($item['start']) && $item['start'] instanceof ilDateTime ? $item['start'] : null; $end = isset($item['end']) && $item['end'] instanceof ilDateTime ? $item['end'] : null; - return new ilBlockDataDTO( + return new ilBlockDTO( $item['type'], (int) $item['ref_id'], (int) $item['obj_id'], diff --git a/Services/Dashboard/Block/classes/class.ilRecommendedContentBlockGUI.php b/Services/Dashboard/Block/classes/class.ilRecommendedContentBlockGUI.php index fedf9c72eb34..f3d6e2dc05e7 100644 --- a/Services/Dashboard/Block/classes/class.ilRecommendedContentBlockGUI.php +++ b/Services/Dashboard/Block/classes/class.ilRecommendedContentBlockGUI.php @@ -84,7 +84,7 @@ public function initData(): void break; } } - return new ilBlockDataDTO( + return new ilBlockDTO( ilObject::_lookupType($obj_id), $ref_id, $obj_id, diff --git a/Services/Dashboard/Block/classes/class.ilSelectedItemsBlockGUI.php b/Services/Dashboard/Block/classes/class.ilSelectedItemsBlockGUI.php index d12b78afbe26..9a0e89666b14 100644 --- a/Services/Dashboard/Block/classes/class.ilSelectedItemsBlockGUI.php +++ b/Services/Dashboard/Block/classes/class.ilSelectedItemsBlockGUI.php @@ -74,7 +74,7 @@ public function initData(): void $data = array_map(static function (array $item) { $start = isset($item['start']) && $item['start'] instanceof ilDateTime ? $item['start'] : null; $end = isset($item['end']) && $item['end'] instanceof ilDateTime ? $item['end'] : null; - return new ilBlockDataDTO( + return new ilBlockDTO( $item['type'], (int) $item['ref_id'], (int) $item['obj_id'], diff --git a/Services/Dashboard/Block/classes/class.ilStudyProgrammeBlockGUI.php b/Services/Dashboard/Block/classes/class.ilStudyProgrammeBlockGUI.php index 0f4e3e1b1a3d..a43bf74a6a12 100644 --- a/Services/Dashboard/Block/classes/class.ilStudyProgrammeBlockGUI.php +++ b/Services/Dashboard/Block/classes/class.ilStudyProgrammeBlockGUI.php @@ -24,7 +24,7 @@ class ilStudyProgrammeBlockGUI extends ilDashboardBlockGUI { protected ?string $visible_on_pd_mode = null; - protected function getListItemForDataDTO(ilBlockDataDTO $data): ?Item + protected function getListItemForDataDTO(ilBlockDTO $data): ?Item { $item_gui = $this->byType($data->getType()); $item_gui->initItem( @@ -158,7 +158,7 @@ public function initData(): void $properties[] = [$this->lng->txt('certificate') => $this->renderer->render($cert_link)]; } - $items[] = new ilBlockDataDTO( + $items[] = new ilBlockDTO( $prg->getType(), $prg->getRefId(), $prg->getId(),