Skip to content

Commit 82f2431

Browse files
author
Robin Cawser
committed
Update readme
1 parent ef05646 commit 82f2431

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function registerBundles()
2121
## Configure
2222

2323
The default configuration is shown below:
24-
24+
2525
```yaml
2626
vivait_string_generator:
2727
generators:
@@ -33,14 +33,16 @@ vivait_string_generator:
3333
* `SecureBytesGenerator` generates a secure random string using the `Symfony\Component\Security\Core\Util\SecureRandom` class
3434

3535
### Custom generators
36-
You can use your own generators by implementing `GeneratorInterface` and defining the generator in the configuration,
36+
You can use your own generators by implementing `GeneratorInterface` and defining the generator in the configuration,
3737
using either its service or classname.
3838

3939
## Basic usage
4040

41-
Add the `@Generate(generator="generator_name")` annotation to an entity property
41+
Add the `@Generate(generator="generator_name")` annotation to an entity property
4242
(where `generator_name` is the name of a generator defined in the configuration).
4343

44+
`generator` is a required property of the annotation.
45+
4446
```php
4547
use Vivait\StringGeneratorBundle\Annotation\GeneratorAnnotation as Generate;
4648
@@ -79,9 +81,9 @@ To change the length of the generated string, add `length` to the annotation.
7981
```
8082

8183
### Callbacks
82-
83-
It's possible to define callbacks on the `Generator` class that you are using.
84-
For example, with the bundled StringGenerator, you may wish to set the character pool.
84+
85+
It's possible to define callbacks on the `Generator` class that you are using.
86+
For example, with the bundled StringGenerator, you may wish to set the character pool.
8587

8688
This can be achieved by setting the `callbacks` option. For example:
8789

@@ -110,11 +112,20 @@ public function getPrefix()
110112

111113
In this case `StringGenerator::setPrefix("default")` will be called
112114

113-
115+
114116
### Unique
115117

116118
Setting `unique` is boolean and tell if the string must be unique or not, by default `true`
117119

118120
```php
119121
@Generate(generator="secure_bytes", unique=false)
120122
```
123+
124+
### Override
125+
126+
By default, `override` is set to true, so a string is always generated for a property.
127+
However, by setting `override` to false, only null properties will have a string generated for them.
128+
129+
```php
130+
@Generate(generator="string", override=false)
131+
```

0 commit comments

Comments
 (0)