@@ -394,6 +394,45 @@ and ``removeChild()`` methods to access to the ``children`` property.
394394
395395If available, *adder * and *remover * methods have priority over a *setter * method.
396396
397+ Using non-standard adder/remover methods
398+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399+
400+ Sometimes, adder and remover methods don't use the standard ``add `` or ``remove `` prefix, like in this example::
401+
402+ // ...
403+ class PeopleList
404+ {
405+ // ...
406+
407+ public function joinPeople(string $people): void
408+ {
409+ $this->peoples[] = $people;
410+ }
411+
412+ public function leavePeople(string $people): void
413+ {
414+ foreach ($this->peoples as $id => $item) {
415+ if ($people === $item) {
416+ unset($this->peoples[$id]);
417+ break;
418+ }
419+ }
420+ }
421+ }
422+
423+ use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
424+ use Symfony\Component\PropertyAccess\PropertyAccessor;
425+
426+ $list = new PeopleList();
427+ $reflectionExtractor = new ReflectionExtractor(null, null, ['join', 'leave']);
428+ $propertyAccessor = new PropertyAccessor(false, false, null, true, $reflectionExtractor, $reflectionExtractor);
429+ $propertyAccessor->setValue($person, 'peoples', ['kevin', 'wouter']);
430+
431+ var_dump($person->getPeoples()); // ['kevin', 'wouter']
432+
433+ Instead of calling ``add<SingularOfThePropertyName>() `` and ``remove<SingularOfThePropertyName>() ``, the PropertyAccess
434+ component will call ``join<SingularOfThePropertyName>() `` and ``leave<SingularOfThePropertyName>() `` methods.
435+
397436Checking Property Paths
398437-----------------------
399438
0 commit comments