Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. node.install

function node_requirements

Implements hook_requirements().

File

core/modules/node/node.install, line 15

Code

function node_requirements($phase) {
    $requirements = [];
    if ($phase === 'runtime') {
        // Only show rebuild button if there are either 0, or 2 or more, rows
        // in the {node_access} table, or if there are modules that
        // implement hook_node_grants().
        $grant_count = \Drupal::entityTypeManager()->getAccessControlHandler('node')
            ->countGrants();
        if ($grant_count != 1 || \Drupal::moduleHandler()->hasImplementations('node_grants')) {
            $value = \Drupal::translation()->formatPlural($grant_count, 'One permission in use', '@count permissions in use', [
                '@count' => $grant_count,
            ]);
        }
        else {
            $value = t('Disabled');
        }
        $requirements['node_access'] = [
            'title' => t('Node Access Permissions'),
            'value' => $value,
            'description' => t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Rebuilding will remove all privileges to content and replace them with permissions based on the current modules and settings. Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed, content will automatically use the new permissions. <a href=":rebuild">Rebuild permissions</a>', [
                ':rebuild' => Url::fromRoute('node.configure_rebuild_confirm')->toString(),
            ]),
        ];
    }
    return $requirements;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal