Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strict check for BuilderAliasProvider #327

Open
vudaltsov opened this issue Aug 1, 2016 · 3 comments
Open

Add strict check for BuilderAliasProvider #327

vudaltsov opened this issue Aug 1, 2016 · 3 comments

Comments

@vudaltsov
Copy link

vudaltsov commented Aug 1, 2016

I have a bundle which uses bundle:path:file.yml syntax. But since the requirements in BuilderAliasProvider are not strict enough (2 == substr_count($name, ':')), my custom Provider is not reached by the ChainProvider.

I suggest checking for smth like:

<?php

namespace Knp\Bundle\MenuBundle\Provider;

use Knp\Menu\Provider\MenuProviderInterface;

class BuilderAliasProvider implements MenuProviderInterface
{
    public function has($name, array $options = array())
    {
        return 0 < preg_match('/^\w+:[\w\\\]+:\w+$/', $name);
    }
}
@dbu
Copy link
Collaborator

dbu commented Aug 2, 2016

ah, and providers have no priority. that is a pitty, otherwise you could just put your provider first. i think adding a priority option to the container tag should be easy, do you want to do a pull request for that?

@stof is there a problem with the regular expression @vudaltsov proposes? could it lead to things not being accepted that are supposed to be accepted?

@vudaltsov
Copy link
Author

I am happy to make a PR on whatever you decide.
Imho it will be good to do both things: to add preg_match and priorities.

@dbu
Copy link
Collaborator

dbu commented Aug 2, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants