Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

updated PropertyAccess docs for PR 30536#11156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wouterj merged 1 commit intosymfony:masterfromwuestkamp:30536
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletionscomponents/property_access.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -168,6 +168,30 @@ getters, this means that you can do something like this::

This will produce: ``He is an author``

Accessing a non existing property path
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By default a :class:`Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException` is thrown if the property path passed to :method:`PropertyAccessor::getValue<Symfony\\Component\\PropertyAccess\\PropertyAccessor::getValue>`
does not exist.
You can change this behaviour using the :method:`Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::disableExceptionOnInvalidPropertyPath`
method::

// ...
$propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
->disableExceptionOnInvalidPropertyPath()
->getPropertyAccessor();

class Person
{
public $name;
}

$person = new Person();

// instead of throwing an exception the following code returns null
$value = $propertyAccessor->getValue($person, 'birthday');


Magic ``__get()`` Method
~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
13 changes: 13 additions & 0 deletionsreference/configuration/framework.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,6 +107,7 @@ Configuration

* `magic_call`_
* `throw_exception_on_invalid_index`_
* `throw_exception_on_invalid_property_path`_

* `property_info`_

Expand DownExpand Up@@ -1726,6 +1727,18 @@ throw_exception_on_invalid_index
When enabled, the ``property_accessor`` service throws an exception when you
try to access an invalid index of an array.

throw_exception_on_invalid_property_path
........................................

**type**: ``boolean`` **default**: ``true``

.. versionadded:: 4.3

The ``throw_exception_on_invalid_property_path`` option was introduced in Symfony 4.3.

When enabled, the ``property_accessor`` service throws an exception when you
try to access an invalid property path of an object.

property_info
~~~~~~~~~~~~~

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp