@@ -11,11 +11,12 @@ Open a command console, enter your project directory and execute the following c
11
11
** Step 2: Enable the Bundle**
12
12
For Symfony declare new service at ` config/services.yaml `
13
13
14
+ ``` yaml
14
15
services :
15
16
// Your services here
16
17
Metadata\AnnotatedFieldsPicker :
17
18
class : ' Metadata\AnnotatedFieldsPicker'
18
-
19
+ ` ` `
19
20
20
21
## How to use
21
22
@@ -32,6 +33,7 @@ To add metadata to field of your class:
32
33
33
34
Imagine we have Product class.
34
35
36
+ ` ` ` php
35
37
class Product
36
38
{
37
39
/** @var int */
@@ -59,6 +61,7 @@ Imagine we have Product class.
59
61
$this->description = $description;
60
62
}
61
63
}
64
+ ` ` `
62
65
63
66
Some of it’s fields should be translated :
64
67
@@ -67,6 +70,7 @@ Some of it’s fields should be translated:
67
70
68
71
To specify which fields should be translated lets create metadata Class called `Translatable`
69
72
73
+ ` ` ` php
70
74
/**
71
75
* @Annotation
72
76
* @Annotation\T arget("PROPERTY")
@@ -79,9 +83,10 @@ To specify which fields should be translated lets create metadata Class called `
79
83
*/
80
84
public $translatable;
81
85
}
82
-
86
+ ` ` `
83
87
Now mark fields `name` and `description` by metadata class
84
88
89
+ ` ` ` php
85
90
// ...
86
91
/**
87
92
* @var string
@@ -95,10 +100,11 @@ Now mark fields `name` and `description` by metadata class
95
100
*/
96
101
private $description
97
102
// ...
98
-
103
+ ` ` `
99
104
100
105
**That all.** All you need now it is use `AnnotatedFieldsPicker` to get this fields
101
106
107
+ ` ` ` php
102
108
<?php
103
109
use Doctrine\C ommon\A nnotations\A nnotationReader;
104
110
use Metadata\A nnotatedFieldsPicker;
@@ -119,9 +125,9 @@ Now mark fields `name` and `description` by metadata class
119
125
}
120
126
}
121
127
}
122
-
128
+ ` ` `
123
129
// result
124
130
// name : 1
125
131
// description : 1
126
-
132
+
127
133
0 commit comments