added 'add license' action in role_delgation and user edit forms
This commit is contained in:
		| @@ -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 | ||||||
| @@ -1,9 +1,10 @@ | |||||||
| <?php | <?php | ||||||
| // use Drupal\Core\Form\FormBuilder; | // use Drupal\Core\Form\FormBuilder; | ||||||
|  | // use Drupal\Core\Url; | ||||||
| use \Drupal\Core\Link; | use \Drupal\Core\Link; | ||||||
| use Drupal\Core\Entity\EntityInterface; | // use Drupal\Core\Entity\EntityInterface; | ||||||
| use Drupal\Core\Entity\EntityFormInterface; | use Drupal\Core\Entity\EntityFormInterface; | ||||||
| use Drupal\Core\Form\FormStateInterface; | // use Drupal\Core\Form\FormStateInterface; | ||||||
| use Drupal\user\EntityOwnerInterface; | use Drupal\user\EntityOwnerInterface; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @@ -29,15 +30,12 @@ function materio_commerce_form_commerce_order_add_form_alter(&$form, &$form_stat | |||||||
| 
 | 
 | ||||||
| function materio_commerce_form_role_delegation_role_assign_form_alter(&$form, &$form_state, $form_id) { | function materio_commerce_form_role_delegation_role_assign_form_alter(&$form, &$form_state, $form_id) { | ||||||
| 
 | 
 | ||||||
| 
 |   // /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */ | ||||||
|   /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */ |   // $form_object = $form_state->getFormObject(); | ||||||
|   $form_object = $form_state->getFormObject(); |  | ||||||
|   // if (!($form_object instanceof EntityFormInterface)) { |   // if (!($form_object instanceof EntityFormInterface)) { | ||||||
|   //   // We're only interested in forms for an entity. |   //   // We're only interested in forms for an entity. | ||||||
|   //   return; |   //   return; | ||||||
|   // } |   // } | ||||||
|   /** @var \Drupal\user\UserInterface $account */ |  | ||||||
|   $account = $form_state->getBuildInfo()['args'][0]; |  | ||||||
|   // $entity = $form_object->getEntity(); |   // $entity = $form_object->getEntity(); | ||||||
|   // $entity_type_id = $entity->getEntityTypeId(); |   // $entity_type_id = $entity->getEntityTypeId(); | ||||||
|   // if (!($entity instanceof EntityOwnerInterface) && $entity_type_id != 'user') { |   // if (!($entity instanceof EntityOwnerInterface) && $entity_type_id != 'user') { | ||||||
| @@ -45,6 +43,9 @@ function materio_commerce_form_role_delegation_role_assign_form_alter(&$form, &$ | |||||||
|   //   return; |   //   return; | ||||||
|   // } |   // } | ||||||
| 
 | 
 | ||||||
|  |   /** @var \Drupal\user\UserInterface $account */ | ||||||
|  |   $account = $form_state->getBuildInfo()['args'][0]; | ||||||
|  | 
 | ||||||
|   $license_storage = \Drupal::entityTypeManager()->getStorage('commerce_license'); |   $license_storage = \Drupal::entityTypeManager()->getStorage('commerce_license'); | ||||||
|   $licenses = $license_storage->loadByProperties(['uid' => $account->id()]); |   $licenses = $license_storage->loadByProperties(['uid' => $account->id()]); | ||||||
|    |    | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user