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

Appearance settings

Commit f4d4ff2

Browse filesBrowse files
committed
Annotations have been changed
1 parent f2bdb4f commit f4d4ff2
Copy full SHA for f4d4ff2

File tree

1 file changed

+13
-10
lines changed
Filter options

1 file changed

+13
-10
lines changed

‎components/property_access.rst

Copy file name to clipboardExpand all lines: components/property_access.rst
+13-10Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ You can also mix objects and arrays::
374374
Custom method calls and virtual properties in a class
375375
-----------------------------------------------------
376376

377+
.. versionadded:: 3.4
378+
Support for custom accessors was introduced in Symfony 3.4.
379+
377380
Sometimes you may not want the component to guess which method has to be called
378381
when reading or writing properties. This is especially interesting when property
379382
names are not in English or its singularization is not properly detected.
@@ -400,7 +403,7 @@ configuration files.
400403
There are four method calls that can be overriden: ``getter``, ``setter``, ``adder`` and
401404
``remover``.
402405

403-
When using annotations you can precede a property with ``@Property`` to state which
406+
When using annotations you can precede a property with ``@PropertyAccessor`` to state which
404407
method should be called when a get, set, add or remove operation is needed on the
405408
property.
406409

@@ -409,17 +412,17 @@ property.
409412
.. code-block:: php-annotations
410413
411414
// ...
412-
use Symfony\Component\PropertyAccess\Annotation\Property;
415+
use Symfony\Component\PropertyAccess\Annotation\PropertyAccessor;
413416
414417
class Person
415418
{
416419
/**
417-
* @Property(getter="getFullName", setter="setFullName")
420+
* @PropertyAccessor(getter="getFullName", setter="setFullName")
418421
*/
419422
private $name;
420423
421424
/**
422-
* @Property(adder="addNewChild", remover="discardChild")
425+
* @PropertyAccessor(adder="addNewChild", remover="discardChild")
423426
*/
424427
private $children;
425428
@@ -474,8 +477,8 @@ Then, using the overriden methods is automatic:
474477
// will return 'Hello John Doe'
475478
476479
You can also associate a particular method with an operation on a property
477-
using the ``@PropertyGetter``, ``@PropertySetter``, ``@PropertyAdder`` and
478-
``@PropertyRemover`` annotations. All of them take only one parameter: ``property``.
480+
using the ``@GetterAccessor``, ``@SetterAccessor``, ``@AdderAccessor`` and
481+
``@RemoverAccessor`` annotations. All of them take only one parameter: ``property``.
479482

480483
This allows creating virtual properties that are not directly stored in the
481484
object:
@@ -485,8 +488,8 @@ object:
485488
.. code-block:: php-annotations
486489
487490
// ...
488-
use Symfony\Component\PropertyAccess\Annotation\PropertyGetter;
489-
use Symfony\Component\PropertyAccess\Annotation\PropertySetter;
491+
use Symfony\Component\PropertyAccess\Annotation\GetterAccessor;
492+
use Symfony\Component\PropertyAccess\Annotation\SetterAccessor;
490493
491494
class Invoice
492495
{
@@ -497,7 +500,7 @@ object:
497500
// Notice that there is no real "total" property
498501
499502
/**
500-
* @PropertyGetter(property="total")
503+
* @GetterAccessor(property="total")
501504
*/
502505
public function getTotal()
503506
{
@@ -506,7 +509,7 @@ object:
506509
507510
// Notice that 'property' can be omitted in the parameter
508511
/**
509-
* @PropertySetter("total")
512+
* @SetterAccessor("total")
510513
*
511514
* @param mixed $total
512515
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.