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 1abbb44

Browse filesBrowse files
committed
Annotations have been changed
1 parent 2ea2372 commit 1abbb44
Copy full SHA for 1abbb44

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
@@ -427,6 +427,9 @@ You can also mix objects and arrays::
427427
Custom method calls and virtual properties in a class
428428
-----------------------------------------------------
429429

430+
.. versionadded:: 3.4
431+
Support for custom accessors was introduced in Symfony 3.4.
432+
430433
Sometimes you may not want the component to guess which method has to be called
431434
when reading or writing properties. This is especially interesting when property
432435
names are not in English or its singularization is not properly detected.
@@ -453,7 +456,7 @@ configuration files.
453456
There are four method calls that can be overriden: ``getter``, ``setter``, ``adder`` and
454457
``remover``.
455458

456-
When using annotations you can precede a property with ``@Property`` to state which
459+
When using annotations you can precede a property with ``@PropertyAccessor`` to state which
457460
method should be called when a get, set, add or remove operation is needed on the
458461
property.
459462

@@ -462,17 +465,17 @@ property.
462465
.. code-block:: php-annotations
463466
464467
// ...
465-
use Symfony\Component\PropertyAccess\Annotation\Property;
468+
use Symfony\Component\PropertyAccess\Annotation\PropertyAccessor;
466469
467470
class Person
468471
{
469472
/**
470-
* @Property(getter="getFullName", setter="setFullName")
473+
* @PropertyAccessor(getter="getFullName", setter="setFullName")
471474
*/
472475
private $name;
473476
474477
/**
475-
* @Property(adder="addNewChild", remover="discardChild")
478+
* @PropertyAccessor(adder="addNewChild", remover="discardChild")
476479
*/
477480
private $children;
478481
@@ -527,8 +530,8 @@ Then, using the overriden methods is automatic:
527530
// will return 'Hello John Doe'
528531
529532
You can also associate a particular method with an operation on a property
530-
using the ``@PropertyGetter``, ``@PropertySetter``, ``@PropertyAdder`` and
531-
``@PropertyRemover`` annotations. All of them take only one parameter: ``property``.
533+
using the ``@GetterAccessor``, ``@SetterAccessor``, ``@AdderAccessor`` and
534+
``@RemoverAccessor`` annotations. All of them take only one parameter: ``property``.
532535

533536
This allows creating virtual properties that are not directly stored in the
534537
object:
@@ -538,8 +541,8 @@ object:
538541
.. code-block:: php-annotations
539542
540543
// ...
541-
use Symfony\Component\PropertyAccess\Annotation\PropertyGetter;
542-
use Symfony\Component\PropertyAccess\Annotation\PropertySetter;
544+
use Symfony\Component\PropertyAccess\Annotation\GetterAccessor;
545+
use Symfony\Component\PropertyAccess\Annotation\SetterAccessor;
543546
544547
class Invoice
545548
{
@@ -550,7 +553,7 @@ object:
550553
// Notice that there is no real "total" property
551554
552555
/**
553-
* @PropertyGetter(property="total")
556+
* @GetterAccessor(property="total")
554557
*/
555558
public function getTotal()
556559
{
@@ -559,7 +562,7 @@ object:
559562
560563
// Notice that 'property' can be omitted in the parameter
561564
/**
562-
* @PropertySetter("total")
565+
* @SetterAccessor("total")
563566
*
564567
* @param mixed $total
565568
*/

0 commit comments

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