From 7949a466438cc10f761260110e95fa02ddd2ab5a Mon Sep 17 00:00:00 2001 From: Serhey Dolgushev Date: Thu, 21 May 2020 15:10:41 +0100 Subject: [PATCH] EZP-31647: more flexibility added to AttributeMapper::supports --- src/lib/Configuration/UI/Mapper/CustomTag.php | 2 +- src/lib/Configuration/UI/Mapper/CustomTag/AttributeMapper.php | 4 +++- .../UI/Mapper/CustomTag/ChoiceAttributeMapper.php | 2 +- .../UI/Mapper/CustomTag/CommonAttributeMapper.php | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/Configuration/UI/Mapper/CustomTag.php b/src/lib/Configuration/UI/Mapper/CustomTag.php index 2dc0b8d3..7c905f82 100644 --- a/src/lib/Configuration/UI/Mapper/CustomTag.php +++ b/src/lib/Configuration/UI/Mapper/CustomTag.php @@ -141,7 +141,7 @@ private function getAttributeTypeMapper( foreach ($this->customTagAttributeMappers as $attributeMapper) { // get first supporting, order of these mappers is controlled by 'priority' DI tag attribute - if ($attributeMapper->supports($attributeType)) { + if ($attributeMapper->supports($tagName, $attributeName, $attributeType)) { return $this->supportedTagAttributeMappersCache[$attributeType] = $attributeMapper; } } diff --git a/src/lib/Configuration/UI/Mapper/CustomTag/AttributeMapper.php b/src/lib/Configuration/UI/Mapper/CustomTag/AttributeMapper.php index 0877cd1d..39e24e5d 100644 --- a/src/lib/Configuration/UI/Mapper/CustomTag/AttributeMapper.php +++ b/src/lib/Configuration/UI/Mapper/CustomTag/AttributeMapper.php @@ -18,11 +18,13 @@ interface AttributeMapper /** * Check if mapper supports given Custom Tag attribute type. * + * @param string $tagName + * @param string $attributeName * @param string $attributeType * * @return bool */ - public function supports(string $attributeType): bool; + public function supports(string $tagName, string $attributeName, string $attributeType): bool; /** * Map Configuration for the given Custom Tag attribute type. diff --git a/src/lib/Configuration/UI/Mapper/CustomTag/ChoiceAttributeMapper.php b/src/lib/Configuration/UI/Mapper/CustomTag/ChoiceAttributeMapper.php index 0f9cfe86..3ec9fc1f 100644 --- a/src/lib/Configuration/UI/Mapper/CustomTag/ChoiceAttributeMapper.php +++ b/src/lib/Configuration/UI/Mapper/CustomTag/ChoiceAttributeMapper.php @@ -15,7 +15,7 @@ */ final class ChoiceAttributeMapper extends CommonAttributeMapper implements AttributeMapper { - public function supports(string $attributeType): bool + public function supports(string $tagName, string $attributeName, string $attributeType): bool { return 'choice' === $attributeType; } diff --git a/src/lib/Configuration/UI/Mapper/CustomTag/CommonAttributeMapper.php b/src/lib/Configuration/UI/Mapper/CustomTag/CommonAttributeMapper.php index 83802553..ae75f88b 100644 --- a/src/lib/Configuration/UI/Mapper/CustomTag/CommonAttributeMapper.php +++ b/src/lib/Configuration/UI/Mapper/CustomTag/CommonAttributeMapper.php @@ -18,7 +18,7 @@ class CommonAttributeMapper implements AttributeMapper /** * {@inheritdoc} */ - public function supports(string $attributeType): bool + public function supports(string $tagName, string $attributeName, string $attributeType): bool { return true; }