Skip to content

Commit

Permalink
EZP-29748: Replacing the outdated verbiage of eZ Publish from eZ Plat…
Browse files Browse the repository at this point in the history
…form when adding a Policy (ezsystems#259)
  • Loading branch information
mikadamczyk authored and Łukasz Serwatka committed Nov 22, 2018
1 parent 5745796 commit 7abb50e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Form/Type/Role/LimitationType.php
Expand Up @@ -77,7 +77,7 @@ public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => '\eZ\Publish\API\Repository\Values\User\Limitation',
'translation_domain' => 'ezrepoforms_role',
'translation_domain' => 'ezrepoforms_policies',
]);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Limitation/Mapper/MultipleSelectionBasedMapper.php
Expand Up @@ -9,6 +9,7 @@

use eZ\Publish\API\Repository\Values\User\Limitation;
use EzSystems\RepositoryForms\Limitation\LimitationFormMapperInterface;
use EzSystems\RepositoryForms\Translation\LimitationTranslationExtractor;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;

Expand All @@ -28,7 +29,7 @@ public function mapLimitationForm(FormInterface $form, Limitation $data)
{
$options = $this->getChoiceFieldOptions() + [
'multiple' => true,
'label' => $data->getIdentifier(),
'label' => LimitationTranslationExtractor::identifierToLabel($data->getIdentifier()),
'required' => false,
];
$choices = $this->getSelectionChoices();
Expand Down
3 changes: 2 additions & 1 deletion lib/Limitation/Mapper/UDWBasedMapper.php
Expand Up @@ -16,6 +16,7 @@
use EzSystems\RepositoryForms\Limitation\DataTransformer\UDWBasedValueTransformer;
use EzSystems\RepositoryForms\Limitation\LimitationFormMapperInterface;
use EzSystems\RepositoryForms\Limitation\LimitationValueMapperInterface;
use EzSystems\RepositoryForms\Translation\LimitationTranslationExtractor;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormInterface;

Expand Down Expand Up @@ -69,7 +70,7 @@ public function mapLimitationForm(FormInterface $form, Limitation $data)
$form->getConfig()->getFormFactory()->createBuilder()
->create('limitationValues', HiddenType::class, [
'required' => false,
'label' => $data->getIdentifier(),
'label' => LimitationTranslationExtractor::identifierToLabel($data->getIdentifier()),
])
->addModelTransformer(new UDWBasedValueTransformer())
// Deactivate auto-initialize as we're not on the root form.
Expand Down
12 changes: 10 additions & 2 deletions lib/Translation/LimitationTranslationExtractor.php
Expand Up @@ -23,8 +23,6 @@ class LimitationTranslationExtractor implements ExtractorInterface
private $policyMap;

/**
* LimitationTranslationExtractor constructor.
*
* @param array $policyMap
*/
public function __construct(array $policyMap)
Expand Down Expand Up @@ -52,6 +50,16 @@ public function extract()
return $catalogue;
}

/**
* @param string $limitationIdentifier
*
* @return string
*/
public static function identifierToLabel(string $limitationIdentifier): string
{
return self::MESSAGE_ID_PREFIX . strtolower($limitationIdentifier);
}

/**
* Returns all known limitation types.
*
Expand Down

0 comments on commit 7abb50e

Please sign in to comment.