@@ -36,7 +36,7 @@ your application::
36
36
37
37
class Author
38
38
{
39
- public $name;
39
8000
+ private $name;
40
40
}
41
41
42
42
So far, this is just an ordinary class that serves some purpose inside your
@@ -55,6 +55,7 @@ following:
55
55
.. code-block :: php-annotations
56
56
57
57
// src/Entity/Author.php
58
+ namespace App\Entity;
58
59
59
60
// ...
60
61
use Symfony\Component\Validator\Constraints as Assert;
@@ -64,7 +65,7 @@ following:
64
65
/**
65
66
* @Assert\NotBlank
66
67
*/
67
- public $name;
68
+ private $name;
68
69
}
69
70
70
71
.. code-block :: yaml
@@ -94,14 +95,14 @@ following:
94
95
.. code-block :: php
95
96
96
97
// src/Entity/Author.php
97
-
98
+ namespace App\Entity;
98
99
// ...
99
100
use Symfony\Component\Validator\Constraints\NotBlank;
100
101
use Symfony\Component\Validator\Mapping\ClassMetadata;
101
102
102
103
class Author
103
104
{
104
- public $name;
105
+ private $name;
105
106
106
107
public static function loadValidatorMetadata(ClassMetadata $metadata)
107
108
{
@@ -325,7 +326,8 @@ literature genre mostly associated with the author, which can be set to either
325
326
.. code-block :: php-annotations
326
327
327
328
// src/Entity/Author.php
328
-
329
+ namespace App\Entity;
330
+
329
331
// ...
330
332
use Symfony\Component\Validator\Constraints as Assert;
331
333
@@ -337,7 +339,7 @@ literature genre mostly associated with the author, which can be set to either
337
339
* message = "Choose a valid genre."
338
340
* )
339
341
*/
340
- public $genre;
342
+ private $genre;
341
343
342
344
// ...
343
345
}
@@ -378,14 +380,15 @@ literature genre mostly associated with the author, which can be set to either
378
380
.. code-block :: php
379
381
380
382
// src/Entity/Author.php
381
-
383
+ namespace App\Entity;
384
+
382
385
// ...
383
386
use Symfony\Component\Validator\Constraints as Assert;
384
387
use Symfony\Component\Validator\Mapping\ClassMetadata;
385
388
386
389
class Author
387
390
{
388
- public $genre;
391
+ private $genre;
389
392
390
393
// ...
391
394
@@ -412,7 +415,8 @@ options can be specified in this way.
412
415
.. code-block :: php-annotations
413
416
414
417
// src/Entity/Author.php
415
-
418
+ namespace App\Entity;
419
+
416
420
// ...
417
421
use Symfony\Component\Validator\Constraints as Assert;
418
422
@@ -421,7 +425,7 @@ options can be specified in this way.
421
425
/**
422
426
* @Assert\Choice({"fiction", "non-fiction"})
423
427
*/
424
- protected $genre;
428
+ private $genre;
425
429
426
430
// ...
427
431
}
@@ -459,14 +463,15 @@ options can be specified in this way.
459
463
.. code-block :: php
460
464
461
465
// src/Entity/Author.php
462
-
466
+ namespace App\Entity;
467
+
463
468
// ...
464
469
use Symfony\Component\Validator\Constraints as Assert;
465
470
use Symfony\Component\Validator\Mapping\ClassMetadata;
466
471
467
472
class Author
468
473
{
469
- protected $genre;
474
+ private $genre;
470
475
471
476
public static function loadValidatorMetadata(ClassMetadata $metadata)
472
477
{
@@ -579,7 +584,8 @@ class to have at least 3 characters.
579
584
.. code-block :: php
580
585
581
586
// src/Entity/Author.php
582
-
587
+ namespace App\Entity;
588
+
583
589
// ...
584
590
use Symfony\Component\Validator\Constraints as Assert;
585
591
use Symfony\Component\Validator\Mapping\ClassMetadata;
@@ -620,7 +626,8 @@ this method must return ``true``:
620
626
.. code-block :: php-annotations
621
627
622
628
// src/Entity/Author.php
623
-
629
+ namespace App\Entity;
630
+
624
631
// ...
625
632
use Symfony\Component\Validator\Constraints as Assert;
626
633
@@ -664,7 +671,8 @@ this method must return ``true``:
664
671
.. code-block :: php
665
672
666
673
// src/Entity/Author.php
667
-
674
+ namespace App\Entity;
675
+
668
676
// ...
669
677
use Symfony\Component\Validator\Constraints as Assert;
670
678
use Symfony\Component\Validator\Mapping\ClassMetadata;
0 commit comments