-
Notifications
You must be signed in to change notification settings - Fork 5
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
CraftCMS support #10
Comments
Making that line return the entire command will make other developers reimplement the same logic of collecting all of the information. That is not desired. Better: introduce the new collection logic for CraftCMS inside of the Twiggy language server. We could detect Symfony and CraftCMS projects separately, and if it is the Craft project, then we will run some other logic instead. The next question here is As far as I understand, Craft is built on top of Yii. Does Yii have such kind of command out of the box? The farthest I could get is this: https://github.com/craftcms/cms/blob/856f45f2766b1a1df5db437b5cd3fe5cce896b5b/src/web/View.php#L364-L406 |
To my knowledge, Yii2 doesn't implement Twig out of the box in any way, it's purely Craft.
In addition to the setter you linked here, there is also the getter just above it. It retrieves the instance of the I have managed to get all the relevant information for the project by using the snippet below, although, it should be parsed/"JSONified" for metadata, similarly (or, more likely, exactly) how it's done in Symfony, especially the globals, as they mix twig globals and craft global sets, which can branch out infinitely, and will always exhaust the memory. /** @var \craft\web\View $view */
$view = Craft::$app->getView();
$twig = Craft::$app->getView()->getTwig();
$tests = $twig->getTests();
$functions = $twig->getFunctions();
$filters = $twig->getFilters();
$globals = $twig->getGlobals();
$paths = $view->getSiteTemplateRoots(); The caveat is that there is no OOB way to use this in Craft, and any implementation is (for now) strictly per-project, but having this feature in the extension might incentivize the creators of Craft to provide such a command of their own. |
#11 is a draft, although is open for suggestions and testing. Kinda works on my machine, let's see if it does on yours. Tested on DDEV starter with php-legacy arch package. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Let's call it a |
Currently, the extension only supports the first half of the twig debug command, which is to target the binary, however, the 2nd part of the command is hardcoded, and thus only useable in symfony (possibly laravel) applications.
It would be a great quality of life to allow users of other frameworks, namely CraftCMS, to submit their local twig environments. Craft doesn't come with such a command out of the box, but it's possible to collect all the information which symfony command retrieves, and send it through a console command.
I have tried fiddling with your source code locally, but I am not familiar with the VSCE API and I am too busy at the moment to learn it and to be able to contribute with a PR.
I have found that the easiest way to go about it would be to make this line return the entire command and remove the hard-coded part, and then no additional work would need to be implemented. That way everyone would have to provide the whole console command, but it would work the same way for everyone.
Thank you for your good work,
Best regards,
Marko
The text was updated successfully, but these errors were encountered: