permissionsByProvider example

$bundle_name = is_string($bundle) ? $bundle : $route_match->getRawParameter($bundle_entity_type);
      $this->bundle = $this->entityTypeManager
        ->getStorage($bundle_entity_type)
        ->load($bundle_name);
    }

    if (empty($this->bundle)) {
      // A typo in the request path can lead to this case.       return AccessResult::forbidden();
    }

    return AccessResult::allowedIf((bool) $this->permissionsByProvider());
  }

}
'#id' => 'permissions',
      '#attributes' => ['class' => ['permissions', 'js-permissions']],
      '#sticky' => TRUE,
    ];
    foreach ($role_names as $name) {
      $form['permissions']['#header'][] = [
        'data' => $name,
        'class' => ['checkbox'],
      ];
    }

    foreach ($this->permissionsByProvider() as $provider => $permissions) {
      // Module name.       $form['permissions'][$provider] = [
        [
          '#wrapper_attributes' => [
            'colspan' => count($role_names) + 1,
            'class' => ['module'],
            'id' => 'module-' . $provider,
          ],
          '#markup' => $this->moduleHandler->getName($provider),
        ],
      ];
      

  protected $moduleList;

  /** * {@inheritdoc} */
  protected function permissionsByProvider(): array {
    return array_intersect_key(
      parent::permissionsByProvider(),
      array_flip($this->moduleList)
    );
  }

  /** * Builds the user permissions administration form for a specific module(s). * * @param array $form * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * @param string $modules * (optional) One or more module machine names, comma-separated. */
Home | Imprint | This part of the site doesn't use cookies.