GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
I often found myself extending YamlFileLoader to add custom routing options, and I think it's quite hard to avoid duplicating the whole class. Validation of routes is a must, and I'd like to extend the default one with more keys, but this can't be done because declaration is private static and static binding is used. I think it would be nice to have an easy way to extend from this class.
Some solutions come to mind:
I attach the code for the second solution (extraction to protected method).
This is an easy patch, but I would love to hear some opinions in the subject.
Allow easy extension of Routing/YamlFileLoader
static method? and then static::getAvailableKeys()
Sorry if I'm missing something, but I can't see the benefits of that. Could you elaborate, please? I think a non-static method serves better for extending. I can imagine, for example, multiple instances of this class behaving different based on some construction parameters.
"I can imagine, for example, multiple instances of this class behaving different based on some construction parameters."
Good point, commented because you were passing a private static var to a non static method.
The way to add custom routing options is to actually add them under the existing options item.