Skip to content

Commit

Permalink
configuration for enum fields cache
Browse files Browse the repository at this point in the history
  • Loading branch information
VasekPurchart committed Sep 16, 2017
1 parent 5358ef9 commit 88ad66e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"consistence/consistence-doctrine": "~1.0",
"consistence/consistence-doctrine": "~1.1",
"doctrine/doctrine-bundle": "~1.3",
"symfony/config": "~3.0",
"symfony/dependency-injection": "~3.0",
Expand Down
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,21 @@ class Consistence\Doctrine\Example\User\Sex#5740 (1) {

This means that the objects API is symmetrical (you get the same type as you set) and you can start benefiting from [Enums](https://github.com/consistence/consistence/blob/master/docs/Enum/enums.md) advantages such as being sure, that what you get is already a valid value and having the possibility to define methods on top of the represented values.

Configuration
-------------

You can override services used internally, for example if you want to use a more effective cache in production (which is recommended), you can provide custom instance with an [alias](http://symfony.com/doc/current/components/dependency_injection/advanced.html#aliasing):

```yaml
services:
mycache:
class: Doctrine\Common\Cache\FilesystemCache
arguments:
- '%kernel.cache_dir%/mycache'

consistence.doctrine.enum.enum_fields_cache: '@mycache'
```
Installation
------------
Expand Down
6 changes: 6 additions & 0 deletions src/DependencyInjection/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ services:
class: Consistence\Doctrine\Enum\EnumPostLoadEntityListener
arguments:
- '@annotation_reader'
- '@consistence.doctrine.enum.enum_fields_cache'
tags:
- { name: doctrine.event_listener, event: postLoad }

consistence.doctrine.enum.enum_fields_cache: '@consistence.doctrine.enum.enum_fields_cache_default'

consistence.doctrine.enum.enum_fields_cache_default:
class: Doctrine\Common\Cache\ArrayCache

0 comments on commit 88ad66e

Please sign in to comment.