Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

EZP-31767: Use version contributor name on dashboard #1437

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if renaming protected function in abstract class is the safest way to do, it should be internal but maybe someone else have opinion on that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I create a separate getVersionContributor method, and keep getContributor as is? And, mark getContributor with @deprecated?

{
$userExists = (new UserExists($this->userService))->isSatisfiedBy($contentInfo->ownerId);

if (false === $userExists) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you did not reuse Specification just with different ID provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ViniTou This method called for each row, so this will save us a few userService->loadUser() calls, which will make the dashboard page a bit faster.
IMHO, UserExists->isSatisfiedBy is overcomplicating the simple thing, user service is doing this job quite well already. Probably, it is the reason why it's not used commonly through the code.

Let me know if these few extra calls are not a big deal and I'll change it to use UserExists.
Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I didnt notice the last removed call, fine with me then.

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 @@ -78,7 +78,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