getParameter('person')->id(); $markup = ""; // Only offer hat creation on hats they don't already have. $hat_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('hat'); foreach($hat_types as $id => $type) { $hats = \Drupal::entityTypeManager() ->getStorage('hat') ->loadByProperties(['type' => $id, 'person' => $person_id]); if (!reset($hats)) { $label = $type['label']; $markup .= "
"; } } return [ '#cache' => [ 'max-age' => 0, ], '#markup' => "