SymfonyTest/symfony-bundle-test

Add CompilerPass with priority to TestKernel

Closed this issue · 3 comments

Currently, you cannot set the $priority argument of ContainerBuilder::addCompilerPass(); when adding a CompilerPass to the TestKernel. In a few cases, this is needed, e.g. to run after another CompilerPass which alters the container (in my case: I am developing a bundle providing a custom translator implementation, before we can alter the translator in the pass of the bundle, the CompilerPass of the FrameworkBundle, which configures the Translator, must have ran).

I see these possibilities here:

  • Add a new method with more arguments (no BC break, but probably bad wording)
  • Change existing method (BC break, but still clear wording)
  • Or something else...?

I am willing to work on this, but I am not sure, which way shall I choose.

Hey, while working on the implementation, I realized that we have our own layer for adding compiler passes to the kernel. It's actually simpler than I initially thought. Take a look at #88

Hi @chapterjason,

Thank you for working on this. Sadly, I don't exactly know, where I needed this feature, since I worked with a lot of bunches of code during that time. But AFAIR: It looks familiar to my workaround from the past, so that my original problem should be solved with that change.