Skip to content

Commit 50e54c5

Browse files
authored
add service definition for form field title extractor (#395)
* added form field title extractor * trigger travis * added requested changes * use alias * use alias_id * add resources for visitor namespace * added binding * added missing definition
1 parent 461a05a commit 50e54c5

File tree

3 files changed

+77
-108
lines changed

3 files changed

+77
-108
lines changed

DependencyInjection/TranslationExtension.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class TranslationExtension extends Extension
4242
*/
4343
public function load(array $configs, ContainerBuilder $container): void
4444
{
45+
$container->setParameter('extractor_vendor_dir', $this->getExtractorVendorDirectory());
46+
4547
$configuration = new Configuration($container);
4648
$config = $this->processConfiguration($configuration, $configs);
4749
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
@@ -232,4 +234,11 @@ public function getConfiguration(array $config, ContainerBuilder $container): Co
232234
{
233235
return new Configuration($container);
234236
}
237+
238+
private function getExtractorVendorDirectory(): string
239+
{
240+
$vendorReflection = new \ReflectionClass(FormTypeChoices::class);
241+
242+
return \dirname($vendorReflection->getFileName(), 4);
243+
}
235244
}

Resources/config/extractors.yaml

Lines changed: 68 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,76 @@
11
services:
2-
Translation\Extractor\FileExtractor\PHPFileExtractor:
3-
tags:
4-
- { name: 'php_translation.extractor', type: 'php' }
2+
_defaults:
3+
bind:
4+
$metadataFactory: '@validator'
55

6-
Translation\Extractor\FileExtractor\TwigFileExtractor:
7-
arguments: ["@twig"]
8-
tags:
9-
- { name: 'php_translation.extractor', type: 'twig' }
6+
_instanceof:
7+
PhpParser\NodeVisitor:
8+
tags:
9+
- { name: 'php_translation.visitor', type: 'php' }
1010

11-
# PHP Visitors:
12-
Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans:
13-
tags:
14-
- { name: 'php_translation.visitor', type: 'php' }
11+
Translation\Extractor\FileExtractor\PHPFileExtractor:
12+
tags:
13+
- { name: 'php_translation.extractor', type: 'php' }
1514

16-
Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice:
17-
tags:
18-
- { name: 'php_translation.visitor', type: 'php' }
15+
Translation\Extractor\FileExtractor\TwigFileExtractor:
16+
arguments: ['@twig']
17+
tags:
18+
- { name: 'php_translation.extractor', type: 'twig' }
1919

20-
Translation\Extractor\Visitor\Php\Symfony\FlashMessage:
21-
tags:
22-
- { name: 'php_translation.visitor', type: 'php' }
20+
# PHP Visitors:
21+
Translation\Extractor\Visitor\Php\Symfony\:
22+
resource: "%extractor_vendor_dir%/Visitor/Php/Symfony/*"
2323

24-
Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices:
25-
tags:
26-
- { name: 'php_translation.visitor', type: 'php' }
24+
Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor: ~
2725

28-
Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue:
29-
tags:
30-
- { name: 'php_translation.visitor', type: 'php' }
26+
# Twig Visitors:
27+
Translation\Extractor\Visitor\Twig\TwigVisitor:
28+
tags:
29+
- { name: 'php_translation.visitor', type: 'twig' }
3130

32-
Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp:
33-
tags:
34-
- { name: 'php_translation.visitor', type: 'php' }
35-
36-
Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage:
37-
tags:
38-
- { name: 'php_translation.visitor', type: 'php' }
39-
40-
Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit:
41-
tags:
42-
- { name: 'php_translation.visitor', type: 'php' }
43-
44-
Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit:
45-
tags:
46-
- { name: 'php_translation.visitor', type: 'php' }
47-
48-
Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder:
49-
tags:
50-
- { name: 'php_translation.visitor', type: 'php' }
51-
52-
Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation:
53-
arguments: ['@validator']
54-
tags:
55-
- { name: 'php_translation.visitor', type: 'php' }
56-
57-
Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor:
58-
tags:
59-
- { name: 'php_translation.visitor', type: 'php' }
60-
61-
# Twig Visitors:
62-
Translation\Extractor\Visitor\Twig\TwigVisitor:
63-
tags:
64-
- { name: 'php_translation.visitor', type: 'twig' }
65-
66-
# To remove in next major release
67-
php_translation.extractor.php:
68-
parent: Translation\Extractor\FileExtractor\PHPFileExtractor
69-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
70-
php_translation.extractor.twig:
71-
parent: Translation\Extractor\FileExtractor\TwigFileExtractor
72-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
73-
php_translation.extractor.php.visitor.ContainerAwareTrans:
74-
parent: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans
75-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
76-
php_translation.extractor.php.visitor.ContainerAwareTransChoice:
77-
parent: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice
78-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
79-
php_translation.extractor.php.visitor.FlashMessage:
80-
parent: Translation\Extractor\Visitor\Php\Symfony\FlashMessage
81-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
82-
php_translation.extractor.php.visitor.FormTypeChoices:
83-
parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices
84-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
85-
php_translation.extractor.php.visitor.FormTypeEmptyValue:
86-
parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue
87-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
88-
php_translation.extractor.php.visitor.FormTypeHelp:
89-
parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp
90-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
91-
php_translation.extractor.php.visitor.FormTypeInvalidMessage:
92-
parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage
93-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
94-
php_translation.extractor.php.visitor.FormTypeLabelExplicit:
95-
parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit
96-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
97-
php_translation.extractor.php.visitor.FormTypeLabelImplicit:
98-
parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit
99-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
100-
php_translation.extractor.php.visitor.FormTypePlaceholder:
101-
parent: Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder
102-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
103-
php_translation.extractor.php.visitor.ValidationAnnotation:
104-
parent: Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation
105-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
106-
php_translation.extractor.php.visitor.SourceLocationContainerVisitor:
107-
parent: Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor
108-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
109-
php_translation.extractor.twig.factory.twig:
110-
parent: Translation\Extractor\Visitor\Twig\TwigVisitor
111-
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
31+
# To remove in next major release
32+
php_translation.extractor.php:
33+
alias: Translation\Extractor\FileExtractor\PHPFileExtractor
34+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
35+
php_translation.extractor.twig:
36+
alias: Translation\Extractor\FileExtractor\TwigFileExtractor
37+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
38+
php_translation.extractor.php.visitor.ContainerAwareTrans:
39+
alias: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans
40+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
41+
php_translation.extractor.php.visitor.ContainerAwareTransChoice:
42+
alias: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice
43+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
44+
php_translation.extractor.php.visitor.FlashMessage:
45+
alias: Translation\Extractor\Visitor\Php\Symfony\FlashMessage
46+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
47+
php_translation.extractor.php.visitor.FormTypeChoices:
48+
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices
49+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
50+
php_translation.extractor.php.visitor.FormTypeEmptyValue:
51+
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue
52+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
53+
php_translation.extractor.php.visitor.FormTypeHelp:
54+
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp
55+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
56+
php_translation.extractor.php.visitor.FormTypeInvalidMessage:
57+
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage
58+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
59+
php_translation.extractor.php.visitor.FormTypeLabelExplicit:
60+
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit
61+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
62+
php_translation.extractor.php.visitor.FormTypeLabelImplicit:
63+
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit
64+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
65+
php_translation.extractor.php.visitor.FormTypePlaceholder:
66+
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder
67+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
68+
php_translation.extractor.php.visitor.ValidationAnnotation:
69+
alias: Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation
70+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
71+
php_translation.extractor.php.visitor.SourceLocationContainerVisitor:
72+
alias: Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor
73+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
74+
php_translation.extractor.twig.factory.twig:
75+
alias: Translation\Extractor\Visitor\Twig\TwigVisitor
76+
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ parameters:
2525
count: 1
2626
path: Command/StatusCommand.php
2727

28-
-
29-
message: "#^Call to method getValue\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\DataCollector\\\\Data\\.$#"
30-
count: 1
31-
path: Controller/SymfonyProfilerController.php
32-
3328
-
3429
message: "#^Call to an undefined static method Symfony\\\\Component\\\\Intl\\\\Intl\\:\\:getLocaleBundle\\(\\)\\.$#"
3530
count: 1

0 commit comments

Comments
 (0)