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

Laravel compatibility: filter constructors should not require parameters #97

Open
michaelk83 opened this issue Jul 26, 2016 · 0 comments

Comments

@michaelk83
Copy link

michaelk83 commented Jul 26, 2016

I'm using MtHaml with Laravel 5 with the help of https://github.com/BKWLD/laravel-haml , and I've encountered a compatibility issue in the SCSS filter. I suspect there's a similar issue in the CoffeeScript filter, but haven't tested.

If I instantiate the SCSS filter inside the BKWLD/laravel-haml configuration, I get a PHP Fatal error when the configuration is cached:

Fatal error: Call to undefined method MtHaml\Filter\Scss::__set_state() in .../bootstrap/cache/config.php

On the other hand, if I specify only the filter class name, as it should be done, then the filter constructor fails because it expects the compiler class as a parameter.

The configuration handling is a BKWLD/laravel-haml issue, but the underlying problem is in MtHaml: it should be possible to instantiate all filters without parameters. If a compiler is not provided, it should create a default compiler instance automatically. The constructor should only throw if the compiler class is not found and can't be loaded.

Specifically with Laravel 5, it may be enough to add a type hint on the compiler parameter. Laravel should be able to inject the dependency on its own once it knows which class it needs.

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

1 participant