-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make it easier to add multiple extensions #686
Comments
See also: #534 This is definitely something that I want to address. I think I'd be looking at more of an interface based approach to "extensions" going forward as opposed to the current situation—these could be used in a way similar to how you've demonstrated, and we wouldn't need extensions to depend on each other in order to work within the same Parsedown instance. |
Glad to hear it's on the roadmap 👌 |
Once it's finished, this should be solved by: #685 |
you can use decorator pattern until now: class Extension1 {
public function __construct($parent) {
$this->parent = $parent;
}
public function bla($arg) {
$res = $this->parent->bla($arg);
$res = dosomething($res);
return $res;
}
// proxy everything unknown to parent
public function __call($method, $arguments) {
return call_user_func_array([$this->parent, $method], $arguments);
}
} $parsedown = new Parsedown();
$ext1 = new Extension1($parsedown);
$ext2 = new Extension2($ext1); this way the this is not ideal, you still need to modify extension1 and extension2 code at least once. |
It's not released yet, but I've explained a little how I think this will work going forward over in: #708 (comment). Feedback welcome! |
Currently, the only way to register multiple extensions would be
ending in
IMHO it's rather counterintuitive and counterproductive, especially compared to other solutions – like what Twig does, for example:
I propose we should at least discuss the possibility of using a similar approach, i.e.
The text was updated successfully, but these errors were encountered: