Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle] Allow custom services for validator mapping cache.#12975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:2.5fromjakzal:validator-doctrine-cache
Dec 24, 2014

Conversation

@jakzal
Copy link
Contributor

QA
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#12803
LicenseMIT
Doc PR-
#9892 introducedDoctrineCache, but it's not really used by the FrameworkBundle. This was overlooked, therefore I think it should go into 2.5.

This PR will let us to configure a service id, instead of a driver name. The only exception is apc, which is converted tovalidator.mapping.cache.apc to keep BC.

Examples:

framework:validation:cache:apc# converted to validator.mapping.cache.apc
framework:validation:cache:my_custom_cache_service

It would be nice to be able to provide a doctrine service id, instead ofCacheInterface implementation. It could be automatically decorated withDoctrineCache:

framework:validation:cache:doctrine:my_doctrine_cache_service# could be provided by DoctrineCacheBundle

I'll work on it next.

@fabpot
Copy link
Member

Thank you@jakzal.

@fabpotfabpot merged commit4cdcf10 intosymfony:2.5Dec 24, 2014
fabpot added a commit that referenced this pull requestDec 24, 2014
…ing cache. (jakzal)This PR was merged into the 2.5 branch.Discussion----------[FrameworkBundle] Allow custom services for validator mapping cache.| Q             | A| ------------- | ---| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#12803| License       | MIT| Doc PR        | -#9892 introduced `DoctrineCache`, but it's not really used by the FrameworkBundle. This was overlooked, therefore I think it should go into 2.5.This PR will let us to configure a service id, instead of a driver name. The only exception is apc, which is converted to `validator.mapping.cache.apc` to keep BC.Examples:```yamlframework:    validation:        cache: apc # converted to validator.mapping.cache.apc``````yamlframework:    validation:        cache: my_custom_cache_service```It would be nice to be able to provide a doctrine service id, instead of `CacheInterface` implementation. It could be automatically decorated with `DoctrineCache`:```yamlframework:    validation:        cache:            doctrine: my_doctrine_cache_service # could be provided by DoctrineCacheBundle```I'll work on it next.Commits-------4cdcf10 [FrameworkBundle] Allow custom services for validator mapping cache.
@jakzaljakzal deleted the validator-doctrine-cache branchDecember 24, 2014 11:29
@jakzal
Copy link
ContributorAuthor

Note that a cache service implementing our interface still needs to be created by the end user. At least it's possible now. I'll work on making it easier next.

@xabbuh
Copy link
Member

Just two quick questions about this change:

  • Doesn't this break BC? If someone already used this feature by setting thecache option tofoo and defined avalidator.mapping.cache.foo service on their own? This won't not work anymore now since thefoo service will probably not exist.
  • We are currently in the progress of adding documentation for the validation configuration options to the reference documentation (see[Reference] add validation config reference section symfony-docs#4673 and[Reference] document the2.5 validation options symfony-docs#4682). Am I right that we needed to different descriptions for 2.3 and 2.5 (I thought the behaviour with this option was the same for 2.3 and 2.5 before this change, but this seems to be different now if I don't misunderstand anything).

@weaverryan
Copy link
Member

I agree with@xabbuh - this looks like a very small BC break. But if you're relying on this behavior, things would blow up when your container is being built, so it'll be an obvious (and small) BC break. So perhaps it's "ok"?

@cmodijk
Copy link

@jakzal Did you ever get to implement the doctrine decorator?

@jakzal
Copy link
ContributorAuthor

@cmodijk no, but all you have to do in your own project is to register a new caching service:

        <serviceid="my_validator_mapping_cache"class="Symfony\Component\Validator\Mapping\Cache\DoctrineCache"public="false">            <argumenttype="service">                <serviceclass="Doctrine\Common\Cache\ApcCache">                    <callmethod="setNamespace">                        <argument>%validator.mapping.cache.prefix%</argument>                    </call>                </service>            </argument>        </service>

and tell validator to use it:

framework:validation:cache:my_validator_mapping_cache

@cmodijk
Copy link

Hmm yeah but it would be nice to directly give a doctrine cache service and that the wrapping is done by Symfony because of the fact that you have thehttps://github.com/doctrine/DoctrineCacheBundle that generates these service id's for you. Know you need to create your own service just to wrap around the cache. With the possibility to directly inject the doctrine cache service id you don't need anything extra.

@pwm
Copy link

pwm commentedJun 17, 2015

Hi, is there a way to do this using Redis?

@jakzal
Copy link
ContributorAuthor

@pwm yes, see the supported drivers here:https://github.com/doctrine/cache/tree/master/lib/Doctrine/Common/Cache

fabpot added a commit that referenced this pull requestJun 23, 2015
…ion for validator mapping (jakzal)This PR was merged into the 2.8 branch.Discussion----------[FrameworkBundle] Add a doctrine cache service definition for validator mapping| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        |symfony/symfony-docs#5409Following#12975, this PR only registers a new service so it's possible to use the new doctrine based cache implementation instead of the deprecated one. To use it, the end user would need to configure it in his `config.yml`:```yamlframework:    validation:        cache: validator.mapping.cache.doctrine.apc```In 3.0 we'll be able to replace the deprecated definition by aliasing `validator.mapping.cache.apc` to `validator.mapping.cache.doctrine.apc`.I thought of automatic wrapping of services which implement doctrine interface, but decided it would be too magic.I'm not convinced if APC is a good default anymore and hope for some discussion. I've used it as it's also used in serializer, and probably translation (see#13986). Since there's a built in opcache in more recent PHP versions, and apcu doesn't seem to be stable, there are better choices. Perhaps a better default would be a filesystem cache (not better performing, but it works anywhere).Commits-------0642911 [FrameworkBundle] Add a doctrine cache service definition for validator mapping
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@jakzal@fabpot@xabbuh@weaverryan@cmodijk@pwm

[8]ページ先頭

©2009-2025 Movatter.jp