I’ve also tweeted several examples of code that I’ve written within Drupal that
use Collections, and I thought it would be good to collate them all here for
reference.
Thanks again to Tighten for releasing and maintaining the
tightenco/collect library that makes it possible to pull in Collections via
Composer.
I knew that you could specify a property like 'price' in Twig and it would also look for methods like 'getPrice()', but I didn't know (or had maybe forgotten) that @laravelphp Collections does it too.
This means that these two Collections return the same result.
Some more #Drupal 8 fun with Laravel Collections. Loading the tags for a post and generating a formatted string of tweetable hashtags. pic.twitter.com/GbyiRPzIRo
I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.