@@ -292,6 +292,48 @@ from a given source object, and can be used as an alternative to
292292 $adminProfile = $mapper->map($user, AdminUserProfile::class);
293293 // $adminProfile->ipAddress = '192.168.1.100'
294294
295+ Note: When using conditions like `if: new TargetClass() `, ensure that the
296+ source property exists. If the property does not exist, the PropertyAccess
297+ component may throw an exception. To avoid this, configure Symfony's
298+ PropertyAccess component in `config/packages/framework.yaml `:
299+
300+ .. configuration-block ::
301+ .. code-block :: yaml
302+ # config/framework.yaml
303+ framework :
304+ property_access :
305+ exception_on_invalid_property_path : false
306+
307+ .. code-block :: xml
308+ <!-- config/packages/framework.xml -->
309+ <?xml version =" 1.0" encoding =" UTF-8" ?>
310+ <container xmlns =" http://symfony.com/schema/dic/services"
311+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
312+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
313+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
314+
315+ <framework : config >
316+ <framework : property-access exception-on-invalid-property-path =" false" />
317+ </framework : config >
318+ </container >
319+
320+ .. code-block :: php
321+ // config/services.php
322+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
323+
324+ use Symfony\Config\FrameworkConfig;
325+
326+ return function(ContainerConfigurator $container): void {
327+ $container->extension('framework', [
328+ 'property_access' => [
329+ 'exception_on_invalid_property_path' => false,
330+ ],
331+ ]);
332+ };
333+
334+ This setting ensures that the mapper skips invalid properties gracefully instead
335+ of throwing an exception.
336+
295337Transforming Values
296338-------------------
297339
0 commit comments