From ad3ef95a7b7906e0d42d7532223e6f432bcc998e Mon Sep 17 00:00:00 2001 From: bach Date: Thu, 17 Nov 2022 22:36:03 +0100 Subject: [PATCH] added 'add license' action in role_delgation and user edit forms --- .../materio_commerce.links.action.yml | 6 ++++++ .../materio_commerce/materio_commerce.module | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 web/modules/custom/materio_commerce/materio_commerce.links.action.yml diff --git a/web/modules/custom/materio_commerce/materio_commerce.links.action.yml b/web/modules/custom/materio_commerce/materio_commerce.links.action.yml new file mode 100644 index 00000000..76554916 --- /dev/null +++ b/web/modules/custom/materio_commerce/materio_commerce.links.action.yml @@ -0,0 +1,6 @@ +materio_commerce.commerce_license.add_page: + route_name: entity.commerce_license.add_page + title: 'Add license' + appears_on: + - entity.user.edit_form + - role_delegation.edit_form diff --git a/web/modules/custom/materio_commerce/materio_commerce.module b/web/modules/custom/materio_commerce/materio_commerce.module index f2ea2fc2..a0625a5d 100644 --- a/web/modules/custom/materio_commerce/materio_commerce.module +++ b/web/modules/custom/materio_commerce/materio_commerce.module @@ -1,9 +1,10 @@ getFormObject(); + // /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */ + // $form_object = $form_state->getFormObject(); // if (!($form_object instanceof EntityFormInterface)) { // // We're only interested in forms for an entity. // return; // } - /** @var \Drupal\user\UserInterface $account */ - $account = $form_state->getBuildInfo()['args'][0]; // $entity = $form_object->getEntity(); // $entity_type_id = $entity->getEntityTypeId(); // if (!($entity instanceof EntityOwnerInterface) && $entity_type_id != 'user') { @@ -45,6 +43,9 @@ function materio_commerce_form_role_delegation_role_assign_form_alter(&$form, &$ // return; // } + /** @var \Drupal\user\UserInterface $account */ + $account = $form_state->getBuildInfo()['args'][0]; + $license_storage = \Drupal::entityTypeManager()->getStorage('commerce_license'); $licenses = $license_storage->loadByProperties(['uid' => $account->id()]);