Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Adam Wójs <[email protected]>
  • Loading branch information
mikadamczyk and adamwojs committed May 22, 2019
1 parent 66803c5 commit f60e7dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
*/
class FieldTypeFormMapperDispatcherPass implements CompilerPassInterface
{
const FIELD_TYPE_FORM_MAPPER_DISPATCHER = 'ezrepoforms.field_type_form_mapper.dispatcher';
public const FIELD_TYPE_FORM_MAPPER_DISPATCHER = 'ezrepoforms.field_type_form_mapper.dispatcher';
public const FIELD_FORM_MAPPER_VALUE = 'ez.fieldFormMapper.value';
public const FIELD_FORM_MAPPER_DEFINITION = 'ez.fieldFormMapper.definition';
public const EZPLATFORM_FIELD_TYPE_FORM_MAPPER_VALUE = 'ezplatform.field_type.form_mapper.value';
public const EZPLATFORM_FIELD_TYPE_FORM_MAPPER_DEFINITION = 'ezplatform.field_type.form_mapper.definition';

public function process(ContainerBuilder $container)
{
Expand All @@ -32,7 +36,7 @@ public function process(ContainerBuilder $container)
foreach ($tags as $tag) {
if (!isset($tag['fieldType'])) {
throw new LogicException(
'ez.fieldFormMapper or ezplatform.field_type.form_mapper service tags need a "fieldType" attribute to identify which field type the mapper is for. None given.'
'`ezplatform.field_type.form_mapper` or deprecated `ez.fieldFormMapper` service tags need a "fieldType" attribute to identify which field type the mapper is for. None given.'
);
}

Expand All @@ -43,8 +47,8 @@ public function process(ContainerBuilder $container)

/**
* Gathers services tagged as either
* - ez.fieldFormMapper.value
* - ez.fieldFormMapper.definition
* - ez.fieldFormMapper.value (deprecated)
* - ez.fieldFormMapper.definition (deprecated)
* - ezplatform.field_type.form_mapper.value
* - ezplatform.field_type.form_mapper.definition.
*
Expand All @@ -54,10 +58,10 @@ public function process(ContainerBuilder $container)
*/
private function findTaggedFormMapperServices(ContainerBuilder $container): array
{
$ezFieldFormMapperValueTags = $container->findTaggedServiceIds('ez.fieldFormMapper.value');
$ezFieldFormMapperDefinitionTags = $container->findTaggedServiceIds('ez.fieldFormMapper.definition');
$ezplatformFieldFormMapperValueTags = $container->findTaggedServiceIds('ezplatform.field_type.form_mapper.value');
$ezplatformFieldFormMapperDefinitionTags = $container->findTaggedServiceIds('ezplatform.field_type.form_mapper.definition');
$ezFieldFormMapperValueTags = $container->findTaggedServiceIds(self::FIELD_FORM_MAPPER_VALUE);
$ezFieldFormMapperDefinitionTags = $container->findTaggedServiceIds(self::FIELD_FORM_MAPPER_DEFINITION);
$ezplatformFieldFormMapperValueTags = $container->findTaggedServiceIds(self::EZPLATFORM_FIELD_TYPE_FORM_MAPPER_VALUE);
$ezplatformFieldFormMapperDefinitionTags = $container->findTaggedServiceIds(self::EZPLATFORM_FIELD_TYPE_FORM_MAPPER_DEFINITION);

foreach ($ezFieldFormMapperValueTags as $ezFieldFormMapperValueTag) {
@trigger_error('`ez.fieldFormMapper.value` service tag is deprecated and will be removed in version 9. Please use `ezplatform.field_type.form_mapper.value` instead.', E_USER_DEPRECATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function testRegisterMappers(string $tag)
$serviceId = 'service_id';
$def = new Definition();
$def->addTag($tag, ['fieldType' => $fieldTypeIdentifier]);
// $def->setClass(\get_class($this->createMock(LimitationValueMapperInterface::class)));
$this->setDefinition($serviceId, $def);

$this->compile();
Expand All @@ -53,10 +52,10 @@ public function testRegisterMappers(string $tag)
public function tagsProvider(): array
{
return [
['ez.fieldFormMapper.value'],
['ez.fieldFormMapper.definition'],
['ezplatform.field_type.form_mapper.value'],
['ezplatform.field_type.form_mapper.definition'],
[FieldTypeFormMapperDispatcherPass::FIELD_FORM_MAPPER_VALUE],
[FieldTypeFormMapperDispatcherPass::FIELD_FORM_MAPPER_DEFINITION],
[FieldTypeFormMapperDispatcherPass::EZPLATFORM_FIELD_TYPE_FORM_MAPPER_VALUE],
[FieldTypeFormMapperDispatcherPass::EZPLATFORM_FIELD_TYPE_FORM_MAPPER_DEFINITION],
];
}
}

0 comments on commit f60e7dc

Please sign in to comment.