Quantcast
Viewing all articles
Browse latest Browse all 295701

Twig files can call the delete method on some content entities

I tried running {{ node.delete }} within node.html.twig and the node deleted. Bug or feature? I was talking with Larry Garfield and Lewis Nyman at Drupal Camp Twin Cities about the idea of only passing "ViewModels" or otherwise stripped down data into our templates rather than full entities with all methods available. We agreed that the presence of a delete method in Twig cuts against one of the original Twig selling points. The discussion around Twig originally (and still) often highlights that queries and other "bad" methods and functions simply can't be called from a template file. Someone shouldn't be able to destroy data on their site by editing a template.

Which entity methods (if any) should be available from a Twig template?


Viewing all articles
Browse latest Browse all 295701


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>