diff --git a/components/property_access/introduction.rst b/components/property_access/introduction.rst index 07177d15b5f..2fabbf2119b 100644 --- a/components/property_access/introduction.rst +++ b/components/property_access/introduction.rst @@ -309,6 +309,39 @@ see `Enable other Features`_. echo $person->getWouter(); // array(...) +Checking Property Paths +----------------------- + +.. versionadded:: 2.5 + The methods + :method:`PropertyAccessor::isReadable` + and + :method:`PropertyAccessor::isWritable` + methods were added in Symfony 2.5. + +When you want to check whether :method:`PropertyAccessor::getValue` +can safely be called without actually calling that method, you can use +:method:`PropertyAccessor::isReadable` +instead:: + + $person = new Person(); + + if ($accessor->isReadable($person, 'firstName') { + // ... + } + +The same is possible for :method:`PropertyAccessor::setValue`: +Call the +:method:`PropertyAccessor::isWritable` +method to find out whether a property path can be updated. In the third +argument, you should pass the value that you want to write:: + + $person = new Person(); + + if ($accessor->isWritable($person, 'firstName', 'Wouter') { + // ... + } + Mixing Objects and Arrays ------------------------- pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy