Get values of a specific property for everything in an array of objects
Don’t use below PHP 7 and you can just use array_column()
!
$TermStorage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$neighborhood_terms = $TermStorage->loadTree('findit_neighborhoods');
// $neighborhood_terms are objects, but this works in PHP 7.
$neighborhoods = array_column($neighborhood_terms, 'name');
To set the PHP minimum for a Drupal module, add this to your .info.yml file:
php: 7.0
Should only do this if you’re using more important features of PHP 7, though all of Drupal is upping the minimum.