Skip to content

Commit

Permalink
PHP-CS-Fixer again
Browse files Browse the repository at this point in the history
  • Loading branch information
gvollbach committed Oct 25, 2024
1 parent f8f2b9e commit 993cdd3
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct()
global $DIC;
$this->default_owner = $DIC->isDependencyAvailable('user') ? $DIC->user()->getId() : 6;
}

public function getId(): string
{
return 'badge';
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/Badge/classes/class.ilBadgeImageTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ public function getImageFromResourceId(?string $image_rid, int $badge_id = null,
}
}
} elseif ($badge_id !== null) {
$badge = new ilBadge($badge_id);
$image_src = $badge->getImage();
$badge = new ilBadge($badge_id);
$image_src = $badge->getImage();
}

return $image_src;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct(
/**
* @return array<string,string>
*/
protected function getBadgeImageTemplates(Container $DIC) : array
protected function getBadgeImageTemplates(Container $DIC): array
{
$modal_container = new ModalBuilder();
$data = [];
Expand All @@ -76,8 +76,11 @@ protected function getBadgeImageTemplates(Container $DIC) : array
$image_html = '';
if ($template->getId() !== null) {
$badge_template_image = $template->getImageFromResourceId($template->getImageRid());
$badge_template_image_large = $template->getImageFromResourceId($template->getImageRid(),
null, 0);
$badge_template_image_large = $template->getImageFromResourceId(
$template->getImageRid(),
null,
0
);
if ($badge_template_image !== '') {
$badge_img = $DIC->ui()->factory()->image()->responsive(
$badge_template_image,
Expand Down Expand Up @@ -113,7 +116,7 @@ public function getRows(
Order $order,
?array $filter_data,
?array $additional_parameters
) : Generator {
): Generator {
$records = $this->getRecords($range, $order);
foreach ($records as $idx => $record) {
$row_id = (string) $record['id'];
Expand All @@ -124,11 +127,11 @@ public function getRows(
public function getTotalRowCount(
?array $filter_data,
?array $additional_parameters
) : ?int {
): ?int {
return count($this->getRecords());
}

protected function getRecords(Range $range = null, Order $order = null) : array
protected function getRecords(Range $range = null, Order $order = null): array
{
global $DIC;

Expand Down Expand Up @@ -160,7 +163,7 @@ protected function getActions(
URLBuilder $url_builder,
URLBuilderToken $action_parameter_token,
URLBuilderToken $row_id_token
) : array {
): array {
$f = $this->factory;
return [
'badge_image_template_edit' => $f->table()->action()->single(
Expand All @@ -177,7 +180,7 @@ protected function getActions(
];
}

public function renderTable() : void
public function renderTable(): void
{
$f = $this->factory;
$r = $this->renderer;
Expand Down Expand Up @@ -212,8 +215,10 @@ public function renderTable() : void
$out = [$table];
$query = $this->http->wrapper()->query();
if ($query->has('tid_id')) {
$query_values = $query->retrieve('tid_id',
$this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()));
$query_values = $query->retrieve(
'tid_id',
$this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
);

$items = [];
if ($query_values === ['ALL_OBJECTS']) {
Expand All @@ -233,7 +238,8 @@ public function renderTable() : void
$items[] = $f->modal()->interruptiveItem()->keyValue(
$id,
(string) $badge->getId(),
$badge->getTitle());
$badge->getTitle()
);
}
} else {
$badge = new ilBadgeImageTemplate($query_values);
Expand All @@ -253,7 +259,7 @@ public function renderTable() : void
$this->lng->txt('badge_deletion_confirmation'),
'#'
)->withAffectedItems($items)
->withAdditionalOnLoadCode(static fn($id) : string => "console.log('ASYNC JS');")
->withAdditionalOnLoadCode(static fn($id): string => "console.log('ASYNC JS');")
]));
exit();
}
Expand Down
49 changes: 31 additions & 18 deletions components/ILIAS/Badge/classes/class.ilBadgePersonalTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct()
$this->request = $DIC->http()->request();
}

protected function buildDataRetrievalObject(Factory $f, Renderer $r) : DataRetrieval
protected function buildDataRetrievalObject(Factory $f, Renderer $r): DataRetrieval
{
return new class ($f, $r) implements DataRetrieval {
private readonly ilBadgeImage $badge_image_service;
Expand All @@ -76,9 +76,11 @@ public function __construct(
$this->renderer = $this->ui_renderer;
$this->user = $DIC->user();
$this->access = $DIC->access();
$this->badge_image_service = new ilBadgeImage($DIC->resourceStorage(),
$this->badge_image_service = new ilBadgeImage(
$DIC->resourceStorage(),
$DIC->upload(),
$DIC->ui()->mainTemplate());
$DIC->ui()->mainTemplate()
);
}

public function getRows(
Expand All @@ -88,7 +90,7 @@ public function getRows(
Order $order,
?array $filter_data,
?array $additional_parameters
) : Generator {
): Generator {
$records = $this->getRecords($range, $order);
foreach ($records as $idx => $record) {
$row_id = (string) $record['id'];
Expand All @@ -99,11 +101,11 @@ public function getRows(
public function getTotalRowCount(
?array $filter_data,
?array $additional_parameters
) : ?int {
): ?int {
return count($this->getRecords());
}

protected function getRecords(Range $range = null, Order $order = null) : array
protected function getRecords(Range $range = null, Order $order = null): array
{
$data = [];
$a_user_id = $this->user->getId();
Expand All @@ -118,8 +120,11 @@ protected function getRecords(Range $range = null, Order $order = null) : array
$badge_img = $this->factory->image()->responsive($image_rid, $badge->getTitle());
$image_html = $this->renderer->render($badge_img);

$image_html_large = $this->badge_image_service->getImageFromResourceId($badge,
$badge->getImageRid(), ilBadgeImage::IMAGE_SIZE_XL);
$image_html_large = $this->badge_image_service->getImageFromResourceId(
$badge,
$badge->getImageRid(),
ilBadgeImage::IMAGE_SIZE_XL
);
if ($image_html_large !== '') {
$badge_img_large = $this->ui_factory->image()->responsive(
$image_html_large,
Expand All @@ -142,8 +147,10 @@ protected function getRecords(Range $range = null, Order $order = null) : array

if ($this->access->checkAccess('read', '', $ref_id)) {
$container_url = ilLink::_getLink($ref_id);
$awarded_by = $this->renderer->render(new Standard($parent['title'],
(string) new URI($container_url)));
$awarded_by = $this->renderer->render(new Standard(
$parent['title'],
(string) new URI($container_url)
));
}
}

Expand All @@ -155,10 +162,14 @@ protected function getRecords(Range $range = null, Order $order = null) : array

$data[] = [
'id' => $badge->getId(),
'image' => $this->ui_renderer->render($this->ui_factory->button()->shy($image_html,
$modal->getShowSignal())) . ' ' . $this->ui_renderer->render($modal),
'title' => $this->ui_renderer->render($this->ui_factory->button()->shy($badge->getTitle(),
$modal->getShowSignal())),
'image' => $this->ui_renderer->render($this->ui_factory->button()->shy(
$image_html,
$modal->getShowSignal()
)) . ' ' . $this->ui_renderer->render($modal),
'title' => $this->ui_renderer->render($this->ui_factory->button()->shy(
$badge->getTitle(),
$modal->getShowSignal()
)),
'user' => '',
'badge_in_profile' => '',
'badge_issued_on' => (new \DateTimeImmutable())->setTimestamp($ass->getTimestamp()),
Expand All @@ -179,7 +190,7 @@ protected function getActions(
URLBuilder $url_builder,
URLBuilderToken $action_parameter_token,
URLBuilderToken $row_id_token
) : array {
): array {
$f = $this->factory;

return [
Expand All @@ -197,7 +208,7 @@ protected function getActions(
];
}

public function renderTable() : void
public function renderTable(): void
{
$f = $this->factory;
$r = $this->renderer;
Expand All @@ -211,9 +222,11 @@ public function renderTable() : void
'title' => $f->table()->column()->text($this->lng->txt('title')),
'awarded_by' => $f->table()->column()->text($this->lng->txt('awarded_by')),
'badge_issued_on' => $f->table()->column()->date($this->lng->txt('badge_issued_on'), $date_format),
'active' => $f->table()->column()->boolean($this->lng->txt('badge_in_profile'),
'active' => $f->table()->column()->boolean(
$this->lng->txt('badge_in_profile'),
$this->lng->txt('yes'),
$this->lng->txt('no')),
$this->lng->txt('no')
),
];

$table_uri = $df->uri($request->getUri()->__toString());
Expand Down
12 changes: 6 additions & 6 deletions components/ILIAS/Badge/classes/class.ilBadgeTypesTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(
/**
* @return array<string, string>
*/
protected function getBadgeImageTemplates() : array
protected function getBadgeImageTemplates(): array
{
$data = [];
$handler = ilBadgeHandler::getInstance();
Expand Down Expand Up @@ -102,7 +102,7 @@ public function getRows(
Order $order,
?array $filter_data,
?array $additional_parameters
) : Generator {
): Generator {
$records = $this->getRecords($range, $order);
foreach ($records as $idx => $record) {
$row_id = (string) $record['id'];
Expand All @@ -113,11 +113,11 @@ public function getRows(
public function getTotalRowCount(
?array $filter_data,
?array $additional_parameters
) : ?int {
): ?int {
return count($this->getRecords());
}

protected function getRecords(Range $range = null, Order $order = null) : array
protected function getRecords(Range $range = null, Order $order = null): array
{
$data = $this->getBadgeImageTemplates();

Expand Down Expand Up @@ -147,7 +147,7 @@ protected function getActions(
URLBuilder $url_builder,
URLBuilderToken $action_parameter_token,
URLBuilderToken $row_id_token
) : array {
): array {
$f = $this->factory;
return [
'badge_type_activate' => $f->table()->action()->multi(
Expand All @@ -164,7 +164,7 @@ protected function getActions(
];
}

public function renderTable() : void
public function renderTable(): void
{
$f = $this->factory;
$r = $this->renderer;
Expand Down
8 changes: 5 additions & 3 deletions components/ILIAS/Badge/classes/class.ilBadgeUserTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(int $parent_ref_id, ?ilBadge $award_badge = null)
$this->award_badge = $award_badge;
}

protected function buildDataRetrievalObject(Factory $f, Renderer $r, int $parent_ref_id, ?ilBadge $award_badge = null) : DataRetrieval
protected function buildDataRetrievalObject(Factory $f, Renderer $r, int $parent_ref_id, ?ilBadge $award_badge = null): DataRetrieval
{
return new class ($f, $r, $parent_ref_id, $award_badge) implements DataRetrieval {
public function __construct(
Expand Down Expand Up @@ -234,8 +234,10 @@ public function renderTable(): void
'login' => $f->table()->column()->text($this->lng->txt("login")),
'type' => $f->table()->column()->text($this->lng->txt("type")),
'title' => $f->table()->column()->text($this->lng->txt("title")),
'issued' => $f->table()->column()->date($this->lng->txt("badge_issued_on"),
$df->dateFormat()->germanShort())
'issued' => $f->table()->column()->date(
$this->lng->txt("badge_issued_on"),
$df->dateFormat()->germanShort()
)
];

$table_uri = $df->uri($request->getUri()->__toString());
Expand Down

0 comments on commit 993cdd3

Please sign in to comment.