-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* IBX-4032: Added limitation to prevent changing content ownership * fix: Add translations * fix: Use constant defined in Core * fix: Move constant to Contract * fix: Code Review * fix: Missing Translation * fix: Code Review * fix: Missing translations
- Loading branch information
1 parent
ff70b9f
commit 2ee5163
Showing
7 changed files
with
169 additions
and
17 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
16 changes: 16 additions & 0 deletions
16
src/bundle/Resources/translations/ibexa_content_forms_policies.en.xliff
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2"> | ||
<file source-language="en" target-language="en" datatype="plaintext" original="not.available"> | ||
<header> | ||
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/> | ||
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note> | ||
</header> | ||
<body> | ||
<trans-unit id="0ba4dd0a3e03edbb23ad81c27bb921449e811cdc" resname="policy.limitation.identifier.changeowner"> | ||
<source>Change Owner</source> | ||
<target state="new">Change Owner</target> | ||
<note>key: policy.limitation.identifier.changeowner</note> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
16 changes: 16 additions & 0 deletions
16
src/bundle/Resources/translations/ibexa_content_forms_role.en.xliff
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2"> | ||
<file source-language="en" target-language="en" datatype="plaintext" original="not.available"> | ||
<header> | ||
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/> | ||
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note> | ||
</header> | ||
<body> | ||
<trans-unit id="57d5902302017c54f7a0965ff6bcd69a3dc03458" resname="policy.limitation.change_owner.forbid"> | ||
<source>Forbid</source> | ||
<target state="new">Forbid</target> | ||
<note>key: policy.limitation.change_owner.forbid</note> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
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,84 @@ | ||
<?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\Limitation\Mapper; | ||
|
||
use Ibexa\AdminUi\Limitation\LimitationFormMapperInterface; | ||
use Ibexa\AdminUi\Limitation\LimitationValueMapperInterface; | ||
use Ibexa\AdminUi\Translation\Extractor\LimitationTranslationExtractor; | ||
use Ibexa\Contracts\Core\Repository\Values\User\Limitation; | ||
use Ibexa\Contracts\Core\Repository\Values\User\Limitation\ChangeOwnerLimitation; | ||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||
use Symfony\Component\Form\FormInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
final class ChangeOwnerLimitationMapper implements LimitationValueMapperInterface, LimitationFormMapperInterface | ||
{ | ||
private TranslatorInterface $translator; | ||
|
||
private ?string $formTemplate = null; | ||
|
||
public function __construct( | ||
TranslatorInterface $translator | ||
) { | ||
$this->translator = $translator; | ||
} | ||
|
||
/** | ||
* @return int[] | ||
*/ | ||
public function mapLimitationValue(Limitation $limitation): array | ||
{ | ||
return $limitation->limitationValues; | ||
} | ||
|
||
public function mapLimitationForm(FormInterface $form, Limitation $data): void | ||
{ | ||
$options = [ | ||
'multiple' => true, | ||
'expanded' => false, | ||
'required' => false, | ||
'label' => LimitationTranslationExtractor::identifierToLabel($data->getIdentifier()), | ||
'choices' => array_flip($this->getSelectionChoices()), | ||
]; | ||
|
||
$form->add('limitationValues', ChoiceType::class, $options); | ||
} | ||
|
||
public function getFormTemplate(): ?string | ||
{ | ||
return $this->formTemplate; | ||
} | ||
|
||
/** | ||
* @return int[] | ||
*/ | ||
public function filterLimitationValues(Limitation $limitation): array | ||
{ | ||
return $limitation->limitationValues; | ||
} | ||
|
||
/** | ||
* @return array<?int, string> | ||
*/ | ||
private function getSelectionChoices(): array | ||
{ | ||
return [ | ||
ChangeOwnerLimitation::LIMITATION_VALUE_SELF => $this->translator->trans(/** @Desc("Forbid") */ | ||
'policy.limitation.change_owner.forbid', | ||
[], | ||
'ibexa_content_forms_role' | ||
), | ||
]; | ||
} | ||
|
||
public function setFormTemplate(string $formTemplate): void | ||
{ | ||
$this->formTemplate = $formTemplate; | ||
} | ||
} |
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