-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
210 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/bundle/Resources/views/themes/admin/content/tab/authors.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{% trans_default_domain 'ibexa_locationview' %} | ||
|
||
{% set creator_name %} | ||
{% if creator is not empty %} | ||
{% include '@ibexadesign/ui/component/user/user.html.twig' with { user: creator } only %} | ||
{% else %} | ||
{{ 'tab.details.creator.not_found'|trans|desc('Can\'t fetch creator') }} | ||
{% endif %} | ||
{% endset %} | ||
|
||
{% set last_contributor_name %} | ||
{% if last_contributor is not empty %} | ||
{% include '@ibexadesign/ui/component/user/user.html.twig' with { user: last_contributor } only %} | ||
{% else %} | ||
{{ 'tab.details.last_contributor.not_found'|trans|desc('Can\'t fetch last contributor') }} | ||
{% endif %} | ||
{% endset %} | ||
|
||
{% set content_details_items = [ | ||
{ | ||
label: 'tab.details.creator'|trans()|desc('Creator'), | ||
content: creator_name, | ||
}, | ||
{ | ||
label: 'tab.details.last_contributor'|trans()|desc('Last contributor'), | ||
content: last_contributor_name, | ||
} | ||
] %} | ||
|
||
{% include '@ibexadesign/ui/component/details/details.html.twig' with { | ||
headline: 'tab.details.content_details'|trans()|desc('Content details'), | ||
items: content_details_items, | ||
} only %} | ||
|
||
{% set technical_details_items = [ | ||
{ | ||
label: 'tab.details.content_id'|trans()|desc('Content ID'), | ||
content: content_info.id, | ||
}, | ||
{ | ||
label: 'tab.details.location_id'|trans()|desc('Location ID'), | ||
content: location.id, | ||
} | ||
] %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\AdminUi\Tab\LocationView; | ||
|
||
use ArrayObject; | ||
use Ibexa\AdminUi\Specification\UserExists; | ||
use Ibexa\AdminUi\UI\Dataset\DatasetFactory; | ||
use Ibexa\Contracts\AdminUi\Tab\AbstractEventDispatchingTab; | ||
use Ibexa\Contracts\AdminUi\Tab\OrderedTabInterface; | ||
use Ibexa\Contracts\Core\Repository\SectionService; | ||
use Ibexa\Contracts\Core\Repository\UserService; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; | ||
use JMS\TranslationBundle\Annotation\Desc; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
use Twig\Environment; | ||
|
||
class AuthorsTab extends AbstractEventDispatchingTab implements OrderedTabInterface | ||
{ | ||
public const URI_FRAGMENT = 'ibexa-tab-location-view-authors'; | ||
|
||
protected UserService $userService; | ||
|
||
protected SectionService $sectionService; | ||
|
||
protected DatasetFactory $datasetFactory; | ||
|
||
/** | ||
* @param \Twig\Environment $twig | ||
* @param \Symfony\Contracts\Translation\TranslatorInterface $translator | ||
* @param \Ibexa\Contracts\Core\Repository\SectionService $sectionService | ||
* @param \Ibexa\Contracts\Core\Repository\UserService $userService | ||
* @param \Ibexa\AdminUi\UI\Dataset\DatasetFactory $datasetFactory | ||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher | ||
*/ | ||
public function __construct( | ||
Environment $twig, | ||
TranslatorInterface $translator, | ||
SectionService $sectionService, | ||
UserService $userService, | ||
DatasetFactory $datasetFactory, | ||
EventDispatcherInterface $eventDispatcher | ||
) { | ||
parent::__construct($twig, $translator, $eventDispatcher); | ||
|
||
$this->sectionService = $sectionService; | ||
$this->userService = $userService; | ||
$this->datasetFactory = $datasetFactory; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getIdentifier(): string | ||
{ | ||
return 'authors'; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
/** @Desc("authors") */ | ||
return $this->translator->trans('tab.name.authors', [], 'ibexa_locationview'); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getOrder(): int | ||
{ | ||
return 200; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getTemplate(): string | ||
{ | ||
return '@ibexadesign/content/tab/authors.html.twig'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getTemplateParameters(array $contextParameters = []): array | ||
{ | ||
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */ | ||
$content = $contextParameters['content']; | ||
|
||
$versionInfo = $content->getVersionInfo(); | ||
$contentInfo = $versionInfo->getContentInfo(); | ||
|
||
$viewParameters = new ArrayObject([ | ||
'content_info' => $contentInfo, | ||
'version_info' => $versionInfo, | ||
]); | ||
|
||
$this->supplyCreator($viewParameters, $contentInfo); | ||
$this->supplyLastContributor($viewParameters, $versionInfo); | ||
|
||
return array_replace($contextParameters, $viewParameters->getArrayCopy()); | ||
} | ||
|
||
/** | ||
* @param \ArrayObject $parameters | ||
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo | ||
*/ | ||
private function supplyLastContributor(ArrayObject $parameters, VersionInfo $versionInfo): void | ||
{ | ||
$parameters['last_contributor'] = null; | ||
if ((new UserExists($this->userService))->isSatisfiedBy($versionInfo->creatorId)) { | ||
$parameters['last_contributor'] = $this->userService->loadUser($versionInfo->creatorId); | ||
} | ||
} | ||
|
||
/** | ||
* @param \ArrayObject $parameters | ||
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo | ||
*/ | ||
private function supplyCreator(ArrayObject $parameters, ContentInfo $contentInfo): void | ||
{ | ||
$parameters['creator'] = null; | ||
if ((new UserExists($this->userService))->isSatisfiedBy($contentInfo->ownerId)) { | ||
$parameters['creator'] = $this->userService->loadUser($contentInfo->ownerId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters