diff --git a/src/Controller/HatController.php b/src/Controller/HatController.php index 26d4b1b..9440acf 100644 --- a/src/Controller/HatController.php +++ b/src/Controller/HatController.php @@ -15,9 +15,9 @@ class HatController extends ControllerBase { * @return string * Return Hello string. */ - public function createHatForPerson($type, $person_id) { + public function createHatForPerson($person_id, $hat_type_id) { $values = array( - 'type' => $type, + 'type' => $hat_type_id, 'person' => $person_id ); diff --git a/src/Plugin/Block/HatCreator.php b/src/Plugin/Block/HatCreator.php index 8e2b22a..6b06160 100644 --- a/src/Plugin/Block/HatCreator.php +++ b/src/Plugin/Block/HatCreator.php @@ -25,13 +25,13 @@ class HatCreator extends BlockBase { // 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) { + foreach($hat_types as $hat_type_id => $type) { $hats = \Drupal::entityTypeManager() ->getStorage('hat') - ->loadByProperties(['type' => $id, 'person' => $person_id]); + ->loadByProperties(['type' => $hat_type_id, 'person' => $person_id]); if (!reset($hats)) { $label = $type['label']; - $markup .= "

Add a $label Hat

"; + $markup .= "

Add a $label Hat

"; } } return [ diff --git a/zencrm.routing.yml b/zencrm.routing.yml index 7abe79d..8721158 100644 --- a/zencrm.routing.yml +++ b/zencrm.routing.yml @@ -1,5 +1,5 @@ zencrm.hat.create: - path: '/zencrm/hat/add/{type}/{person_id}' + path: '/zencrm/hat/{person_id}/add/{hat_type_id}' defaults: _controller: '\Drupal\zencrm\Controller\HatController::createHatForPerson' _title: 'Add New Hat'