Commit 9eedcf25 authored by Florent Torregrosa's avatar Florent Torregrosa Committed by Florent Torregrosa
Browse files

Issue #3258955 by Grimreaper, meyerrob: Handle password user data access per user.

parent 9f6c7773
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@

declare(strict_types = 1);

use Drupal\entity_access_password_user_data_backend\Service\UserDataBackend;
use Drupal\entity_access_password_user_data_backend\Service\UserDataBackendInterface;

/**
 * Implements hook_uninstall().
@@ -15,5 +15,5 @@ use Drupal\entity_access_password_user_data_backend\Service\UserDataBackend;
function entity_access_password_user_data_backend_uninstall(bool $is_syncing) : void {
  /** @var \Drupal\user\UserDataInterface $user_data */
  $user_data = \Drupal::service('user.data');
  $user_data->delete(UserDataBackend::MODULE_NAME);
  $user_data->delete(UserDataBackendInterface::MODULE_NAME);
}
+6 −0
Original line number Diff line number Diff line
@@ -9,6 +9,12 @@ entity_access_password_user_data_backend.user_data_form.global:
  parent_id: entity_access_password_user_data_backend.admin_tab
  weight: -10

entity.user.entity_access_password_user_data_backend:
  title: 'Password access'
  route_name: entity_access_password_user_data_backend.user_data_form.user
  base_route: entity.user.canonical
  weight: 10

entity_access_password_user_data_backend.bundles_form:
  class: \Drupal\Core\Menu\LocalTaskDefault
  deriver: \Drupal\entity_access_password_user_data_backend\Plugin\Derivative\UserDataBackendBundleLocalTask
+12 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
declare(strict_types = 1);

use Drupal\Core\Entity\EntityInterface;
use Drupal\entity_access_password_user_data_backend\HookHandler\EntityDelete;
use Drupal\entity_access_password_user_data_backend\HookHandler\EntityTypeInfo;

/**
@@ -19,3 +20,13 @@ function entity_access_password_user_data_backend_entity_operation(EntityInterfa
    ->getInstanceFromDefinition(EntityTypeInfo::class);
  return $instance->entityOperation($entity);
}

/**
 * Implements hook_entity_delete().
 */
function entity_access_password_user_data_backend_entity_delete(EntityInterface $entity): void {
  /** @var \Drupal\entity_access_password_user_data_backend\HookHandler\EntityDelete $instance */
  $instance = \Drupal::service('class_resolver')
    ->getInstanceFromDefinition(EntityDelete::class);
  $instance->entityDelete($entity);
}
+5 −0
Original line number Diff line number Diff line
@@ -12,3 +12,8 @@ entity_access_password_user_data_backend_access_global_form:
  title: 'Access global user data form'
  description: 'Access form to edit global access user data.'
  restrict access: TRUE

entity_access_password_user_data_backend_access_user_form:
  title: "Access user's user data form"
  description: 'Access form to all user data of a specific user.'
  restrict access: TRUE
+13 −0
Original line number Diff line number Diff line
@@ -14,6 +14,19 @@ entity_access_password_user_data_backend.user_data_form.global:
  requirements:
    _permission: 'entity_access_password_user_data_backend_access_global_form'

entity_access_password_user_data_backend.user_data_form.user:
  path: '/user/{user}/password_user_data'
  defaults:
    _title: 'User password user data'
    _form: '\Drupal\entity_access_password_user_data_backend\Form\UserUserDataEditForm'
  options:
    _admin_route: TRUE
    parameters:
      user:
        type: 'entity:user'
  requirements:
    _permission: 'entity_access_password_user_data_backend_access_user_form'

route_callbacks:
  - '\Drupal\entity_access_password_user_data_backend\Routing\BundleFormRoutes::routes'
  - '\Drupal\entity_access_password_user_data_backend\Routing\EntityFormRoutes::routes'
Loading