Bonjour,

Je teste le composant PropertyInfo. J'arrive à le faire fonctionner notamment via l'exemple de la doc: https://symfony.com/doc/current/comp...nfo.html#usage.

On suppose cette entité Personne:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
<?php
 
#[ORM\Entity(repositoryClass: PersonneRepository::class)]
class Personne
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;
 
    #[ORM\Column(length: 255)]
    private ?string $lastName = null;
 
    #[ORM\Column(length: 255)]
    private ?string $firstName = null;
 
    #[ORM\Column(nullable: true)]
    private ?float $height = null;
 
    #[ORM\Column(type: Types::TEXT)]
    private ?string $bio = null;
 
    #[ORM\Column(length: 255)]
    private ?string $hobby;
 
    public function getId(): ?int
    {
        return $this->id;
    }
 
    /**
     * Getter of the lastName
     * 
     * @return ?string
     */
    public function getLastName(): ?string
    {
        return $this->lastName;
    }
 
    /**
     * Setter of the lastName
     * 
     * @param ?string $lastName
     * 
     * @return static
     */
    public function setLastName(?string $lastName): static
    {
        $this->lastName = $lastName;
 
        return $this;
    }
 
    /**
     * Getter of the firstName
     * 
     * @return ?string
     */
    public function getFirstName(): ?string
    {
        return $this->firstName;
    }
 
    /**
     * Setter of the firstName
     * 
     * @param ?string $firstName
     * 
     * @return static
     */
    public function setFirstName(?string $firstName): static
    {
        $this->firstName = $firstName;
 
        return $this;
    }
 
    public function getHeight(): ?float
    {
        return $this->height;
    }
 
    public function setHeight(?float $height): static
    {
        $this->height = $height;
 
        return $this;
    }
 
    public function getBio(): ?string
    {
        return $this->bio;
    }
 
    public function setBio(string $bio): static
    {
        $this->bio = $bio;
 
        return $this;
    }
 
    /**
     * Getter of the hobby
     * 
     * Une description un peu plus longue sur plusieurs ligne
     * à propos de cette propriétés pour avoir justement plus d'info
     * et le tester
     * 
     * @return ?string
     */
    public function getHobby(): ?string
    {
        return $this->hobby;
    }
 
    /**
     * Setter of the hobby
     * 
     * @param string $hobby
     * 
     * @return static
     */
    public function setHobby(string $hobby): static
    {
        $this->hobby = $hobby;
 
        return $this;
    }
}
Et on suppose ce controlleur PersonneController pour tester l'exemple de la doc:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
<?php
 
class PersonneController extends AbstractController
{
    #[Route('/info', name: 'info_personne')]
    public function infoPersonne() 
    {
        // a full list of extractors is shown further below
        $phpDocExtractor = new PhpDocExtractor();
        $reflectionExtractor = new ReflectionExtractor();
 
        // list of PropertyListExtractorInterface (any iterable)
        $listExtractors = [$reflectionExtractor];
 
        // list of PropertyTypeExtractorInterface (any iterable)
        $typeExtractors = [$phpDocExtractor, $reflectionExtractor];
 
        // list of PropertyDescriptionExtractorInterface (any iterable)
        $descriptionExtractors = [$phpDocExtractor];
 
        // list of PropertyAccessExtractorInterface (any iterable)
        $accessExtractors = [$reflectionExtractor];
 
        // list of PropertyInitializableExtractorInterface (any iterable)
        $propertyInitializableExtractors = [$reflectionExtractor];
 
        $propertyInfo = new PropertyInfoExtractor(
            $listExtractors,
            $typeExtractors,
            $descriptionExtractors,
            $accessExtractors,
            $propertyInitializableExtractors
        );
 
        // see below for more examples
        $class = Personne::class;
        $properties = $propertyInfo->getProperties($class);
 
        dd($properties);
    }
}
Le dd($properties) me renvoie:

array:6 [▼
0 => "id"
1 => "lastName"
2 => "firstName"
3 => "height"
4 => "bio"
5 => "hobby"
]
Du coup, le composant fonctionne bien.

Moi, ce que je souhaite comprendre, c'est comment utiliser ce composant lorsqu'il sera registered en tant que service grâce à la configuration qu'on trouve ici https://symfony.com/doc/current/comp...ctionextractor, c'est à dire cette configuration:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
# config/packages/framework.yaml
framework:
    property_info:
        enabled: true
Voyez vous comment faire pour le faire fonctionner sans avoir à instancier PropertyInfoExtractor s'il vous plaît?

Je vous remercie par avance,