From 689d208463668cfe3ea0485a631658413881ee7a Mon Sep 17 00:00:00 2001 From: naomi Date: Wed, 11 Apr 2018 14:24:29 +0200 Subject: [PATCH] Added route and controller for adding new contact details to a person --- src/Controller/ContactDetailsController.php | 31 +++++++++++++++++++++ src/Plugin/Block/HatCreator.php | 2 +- zencrm.routing.yml | 8 ++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/Controller/ContactDetailsController.php diff --git a/src/Controller/ContactDetailsController.php b/src/Controller/ContactDetailsController.php new file mode 100644 index 0000000..17401f7 --- /dev/null +++ b/src/Controller/ContactDetailsController.php @@ -0,0 +1,31 @@ + $person_id + ); + + $node = \Drupal::entityTypeManager() + ->getStorage('contact_details') + ->create($values); + + $form = \Drupal::entityTypeManager() + ->getFormObject('contact_details', 'default') + ->setEntity($node); + return \Drupal::formBuilder()->getForm($form); + } + +} diff --git a/src/Plugin/Block/HatCreator.php b/src/Plugin/Block/HatCreator.php index 25e5d14..8e2b22a 100644 --- a/src/Plugin/Block/HatCreator.php +++ b/src/Plugin/Block/HatCreator.php @@ -31,7 +31,7 @@ class HatCreator extends BlockBase { ->loadByProperties(['type' => $id, 'person' => $person_id]); if (!reset($hats)) { $label = $type['label']; - $markup .= "

Create $label Hat

"; + $markup .= "

Add a $label Hat

"; } } return [ diff --git a/zencrm.routing.yml b/zencrm.routing.yml index 3cfef4d..7abe79d 100644 --- a/zencrm.routing.yml +++ b/zencrm.routing.yml @@ -5,3 +5,11 @@ zencrm.hat.create: _title: 'Add New Hat' requirements: _permission: 'access content' + +zencrm.contact_details.create: + path: '/zencrm/contact_details/add/{person_id}' + defaults: + _controller: '\Drupal\zencrm\Controller\ContactDetailsController::createContactDetailsForPerson' + _title: 'Add New Contact Details' + requirements: + _permission: 'access content'