Skip to content

Commit

Permalink
Merge branch '2.3' of ezsystems/ezplatform-admin-ui into 4.5 (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou authored Jan 25, 2024
2 parents 93e5af0 + 34e990a commit 14b3f8b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
20 changes: 0 additions & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8975,26 +8975,6 @@ parameters:
count: 1
path: src/lib/Tab/Dashboard/PagerContentToDataMapper.php

-
message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\Dashboard\\\\PagerLocationToDataMapper\\:\\:getAvailableTranslations\\(\\) has invalid return type eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\Content\\\\Language\\.$#"
count: 1
path: src/lib/Tab/Dashboard/PagerLocationToDataMapper.php

-
message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\Dashboard\\\\PagerLocationToDataMapper\\:\\:getAvailableTranslations\\(\\) should return array\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\Content\\\\Language\\> but returns array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Language\\>\\.$#"
count: 1
path: src/lib/Tab/Dashboard/PagerLocationToDataMapper.php

-
message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\Dashboard\\\\PagerLocationToDataMapper\\:\\:map\\(\\) has parameter \\$pager with generic class Pagerfanta\\\\Pagerfanta but does not specify its types\\: T$#"
count: 1
path: src/lib/Tab/Dashboard/PagerLocationToDataMapper.php

-
message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\Dashboard\\\\PagerLocationToDataMapper\\:\\:map\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Tab/Dashboard/PagerLocationToDataMapper.php

-
message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\Event\\\\Subscriber\\\\ConditionalTabSubscriber\\:\\:getSubscribedEvents\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
8 changes: 7 additions & 1 deletion src/lib/Tab/Dashboard/MyContentTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public function getOrder(): int
return 200;
}

/**
* @throws \Twig\Error\Error
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ForbiddenException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
*/
public function renderView(array $parameters): string
{
/** @todo Handle pagination */
Expand All @@ -46,7 +52,7 @@ public function renderView(array $parameters): string
$pager->setCurrentPage($page);

return $this->twig->render('@ibexadesign/ui/dashboard/tab/my_content.html.twig', [
'data' => $this->pagerLocationToDataMapper->map($pager),
'data' => $this->pagerLocationToDataMapper->map($pager, true),
]);
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/lib/Tab/Dashboard/MyMediaTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public function getOrder(): int
return 300;
}

/**
* @throws \Twig\Error\Error
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ForbiddenException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
*/
public function renderView(array $parameters): string
{
/** @todo Handle pagination */
Expand All @@ -46,7 +52,7 @@ public function renderView(array $parameters): string
$pager->setCurrentPage($page);

return $this->twig->render('@ibexadesign/ui/dashboard/tab/my_media.html.twig', [
'data' => $this->pagerLocationToDataMapper->map($pager),
'data' => $this->pagerLocationToDataMapper->map($pager, true),
]);
}
}
Expand Down
32 changes: 21 additions & 11 deletions src/lib/Tab/Dashboard/PagerLocationToDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Ibexa\AdminUi\Tab\Dashboard;

use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;
use Ibexa\Contracts\Core\Repository\LanguageService;
use Ibexa\Contracts\Core\Repository\UserService;
Expand All @@ -20,9 +19,6 @@

final class PagerLocationToDataMapper
{
/** @var \Ibexa\Contracts\Core\Repository\ContentService */
private $contentService;

/** @var \Ibexa\Contracts\Core\Repository\UserService */
private $userService;

Expand All @@ -32,31 +28,45 @@ final class PagerLocationToDataMapper
private LanguageService $languageService;

public function __construct(
ContentService $contentService,
UserService $userService,
LocationResolver $locationResolver,
LanguageService $languageService
) {
$this->contentService = $contentService;
$this->userService = $userService;
$this->locationResolver = $locationResolver;
$this->languageService = $languageService;
}

/**
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
* @param \Pagerfanta\Pagerfanta<\Ibexa\Contracts\Core\Repository\Values\Content\Location> $pager
*
* @return array<
* array{
* 'contentTypeId': int,
* 'contentId': int,
* 'name': string,
* 'type': ?string,
* 'language': string,
* 'available_enabled_translations': \Ibexa\Contracts\Core\Repository\Values\Content\Language[],
* 'contributor': ?\Ibexa\Contracts\Core\Repository\Values\User\User,
* 'content_type': \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType,
* 'modified': \DateTime,
* 'resolvedLocation': \Ibexa\Contracts\Core\Repository\Values\Content\Location
* }
* >
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ForbiddenException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
*/
public function map(Pagerfanta $pager, bool $doMapVersionInfoData = false): array
{
$data = [];

/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */
foreach ($pager as $location) {
$contentInfo = $location->contentInfo;
$versionInfo = $doMapVersionInfoData ? $this->contentService->loadVersionInfo($contentInfo) : null;
$contentInfo = $location->getContentInfo();
$versionInfo = $doMapVersionInfoData ? $location->getContent()->getVersionInfo() : null;
$contentType = $location->getContentInfo()->getContentType();

$data[] = [
Expand Down Expand Up @@ -86,7 +96,7 @@ private function getVersionContributor(VersionInfo $versionInfo): ?User
}

/**
* @return \eZ\Publish\API\Repository\Values\Content\Language[]
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Language[]
*/
private function getAvailableTranslations(
VersionInfo $versionInfo
Expand Down

0 comments on commit 14b3f8b

Please sign in to comment.