-
Notifications
You must be signed in to change notification settings - Fork 51
Conversation
we generally only put "require" on things that are required to make any use of the given Bundle. however the MenuBlock is optional, which is why its only a "require-dev" .. but it should be added to the "suggest" as well. /cc @dbu |
@lsmith77 I agree, that the bundle shouldn't be required. at in fact, the code in the MenuBlock requires Knp\Menu\NodeInterface I don't know how we can remove the dependency, so my suggest was to require the menu-bundle |
well at this point, we have not done into the direction of offering bridges like Symfony core does at it complicates testing, release management etc. so we essentially have these options:
|
@lsmith77 What do you think about this interface possible solutions: a, we can duplicate the interface in the BlockBundle b, check the instance of the argument in the method
If you decide which solution you prefer, I will update the pull request. greetings, Sebastian |
hmm changing the method signature like this a a BC break. |
as long as its possible to ignore that there is a class that has an unknown dependency, we can just ignore this. but is the problem that the dependency is not really weak, as generating the doctrine proxies reveils that we miss the menu bundle? is there a possibility to make doctrine ignore that class when menu bundle code is not available? like hiding the mapping or something? |
ah .. now I understand the issue. hiding the mapping is probably only possible via some class meta data laod listener but that seems quite hacky. |
well, if that is possible, i would chose that over a separate bundle for just one document. and removing it again and just having a cookbook article how to do it yourself seems awkward... but i am not sure if that even would work or if doctrine then still would try to load the class to check for annotations. as its not in the default folder, maybe not. @sebastianblum can you check what happens if you remove the xml mapping file https://github.com/symfony-cmf/BlockBundle/blob/master/Resources/config/doctrine-phpcr/MenuBlock.phpcr.xml ? if that solves the problem, i will look into the metadata listener and see if this is where we can prevent the problem from showing up. |
Hello @dbu, the weird thing is, that I only get the error message in prod-environment
@ddu yes it works, if I delete https://github.com/symfony-cmf/BlockBundle/blob/master/Resources/config/doctrine-phpcr/MenuBlock.phpcr.xml On word to the backward compatibility @lsmith77 says above. changing a method from
to
is backyard compatible because because it works like expected. @dbu you suggestion is too complicated in my opinion. I know that I'm a special case, that I want to use the BlockBundle without the MenuBundle, but I would like to remove the hardcodes dependency. |
its to be expected that the problem only comes in prod environment. in dev, doctrine proxies are created on the fly - in prod they are pre-generated during warmup. good to know that without metadata it would work. i will see what i can do. your use case is one that we really want to encourage. that is one of the goals of the cmf, to be modular. the only place where this change is not BC is when somebody extended the block class and overwrote that method. his code will then become invalid. i think we should do the change you propose if that line is all that is needed - but only for the 1.3 version to not have a potential BC break in a dot upgrade. until then you would need to use @lsmith77 wdyt, stupid idea or good enough? i am not even sure if the doctrine metadata thing would allow to completely un-map a document. |
well, the method could be overwritten to do something and then call its parent. but i think its not very likely. looking forward for the pull request. |
…octrine proxies will work in production environment menuNode should be null if null or an invalid node are passed to setMenuNode
@dbu is my solution good enough or do you have any suggestions for me? |
if ($menuNode instanceof NodeInterface) { | ||
$this->menuNode = $menuNode; | ||
} else { | ||
$this->menuNode = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should be a bit more strict. something like
if (! (null === $menuNode || $menuNode instanceof NodeInterface)) {
throw new \InvalidArgumentException('$menuNode must be an instane of NodeInterface');
}
$this-> menuNode = $menuNode;
sorry, seems i completely missed that. merged now. |
should we tag 1.2.2? |
done |
thank you very much @dbu |
I'm playing with symfony-cmf and I'm only using the BlockBundle (without the MenuBundle).
I got this exception
https://github.com/symfony-cmf/BlockBundle/blob/master/Doctrine/Phpcr/MenuBlock.php
The MenuBlock has a dependency to Knp\Menu\NodeInterface
So I would change the require-dev dependency to require to solve the issue.
The other possibility is to require the sonata-menu-bundle instead of menu-bundle.