Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7b6426

Browse files
authored
Update README.md
1 parent 3e5fb92 commit a7b6426

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ Open a command console, enter your project directory and execute the following c
1111
**Step 2: Enable the Bundle**
1212
For Symfony declare new service at `config/services.yaml`
1313

14+
```yaml
1415
services:
1516
// Your services here
1617
Metadata\AnnotatedFieldsPicker:
1718
class: 'Metadata\AnnotatedFieldsPicker'
18-
19+
```
1920
2021
## How to use
2122
@@ -32,6 +33,7 @@ To add metadata to field of your class:
3233

3334
Imagine we have Product class.
3435

36+
```php
3537
class Product
3638
{
3739
/** @var int */
@@ -59,6 +61,7 @@ Imagine we have Product class.
5961
$this->description = $description;
6062
}
6163
}
64+
```
6265

6366
Some of it’s fields should be translated:
6467

@@ -67,6 +70,7 @@ Some of it’s fields should be translated:
6770

6871
To specify which fields should be translated lets create metadata Class called `Translatable`
6972

73+
```php
7074
/**
7175
* @Annotation
7276
* @Annotation\Target("PROPERTY")
@@ -79,9 +83,10 @@ To specify which fields should be translated lets create metadata Class called `
7983
*/
8084
public $translatable;
8185
}
82-
86+
```
8387
Now mark fields `name` and `description` by metadata class
8488

89+
```php
8590
// ...
8691
/**
8792
* @var string
@@ -95,10 +100,11 @@ Now mark fields `name` and `description` by metadata class
95100
*/
96101
private $description
97102
// ...
98-
103+
```
99104

100105
**That all.** All you need now it is use `AnnotatedFieldsPicker` to get this fields
101106

107+
```php
102108
<?php
103109
use Doctrine\Common\Annotations\AnnotationReader;
104110
use Metadata\AnnotatedFieldsPicker;
@@ -119,9 +125,9 @@ Now mark fields `name` and `description` by metadata class
119125
}
120126
}
121127
}
122-
128+
```
123129
// result
124130
// name: 1
125131
// description: 1
126-
132+
127133

0 commit comments

Comments
 (0)