Skip to content

Commit

Permalink
Merge pull request #1437 from ITernovtsiy/contributor-fix
Browse files Browse the repository at this point in the history
EZP-31767: Use version contributor name on dashboard
  • Loading branch information
adamwojs authored Sep 24, 2020
2 parents 2d1377f + 48babe8 commit 523ac22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions src/lib/Pagination/Mapper/AbstractPagerContentToDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
namespace EzSystems\EzPlatformAdminUi\Pagination\Mapper;

use eZ\Publish\API\Repository\ContentTypeService;
use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use eZ\Publish\API\Repository\LanguageService;
use eZ\Publish\API\Repository\UserService;
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use eZ\Publish\API\Repository\Values\Content\Language;
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
use eZ\Publish\API\Repository\Values\User\User;
use eZ\Publish\Core\Helper\TranslationHelper;
use eZ\Publish\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface;
use EzSystems\EzPlatformAdminUi\Specification\ContentIsUser;
use EzSystems\EzPlatformAdminUi\Specification\UserExists;

abstract class AbstractPagerContentToDataMapper
{
Expand Down Expand Up @@ -88,19 +88,17 @@ protected function isContentIsUser(Content $content): bool
}

/**
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
* @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
*
* @return \eZ\Publish\API\Repository\Values\User\User|null
*/
protected function getContributor(ContentInfo $contentInfo): ?User
protected function getVersionContributor(VersionInfo $versionInfo): ?User
{
$userExists = (new UserExists($this->userService))->isSatisfiedBy($contentInfo->ownerId);

if (false === $userExists) {
try {
return $this->userService->loadUser($versionInfo->creatorId);
} catch (NotFoundException $e) {
return null;
}

return $this->userService->loadUser($contentInfo->ownerId);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Tab/Dashboard/PagerContentToDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function map(Pagerfanta $pager): array
'contentId' => $content->id,
'name' => $this->translationHelper->getTranslatedContentName($content),
'language' => $contentInfo->mainLanguageCode,
'contributor' => $this->getContributor($contentInfo),
'contributor' => $this->getVersionContributor($content->versionInfo),
'version' => $content->versionInfo->versionNo,
'content_type' => $content->getContentType(),
'modified' => $content->versionInfo->modificationDate,
Expand Down

0 comments on commit 523ac22

Please # to comment.