Drupal 8  8.0.2
NodeGrantDatabaseStorage Class Reference
Inheritance diagram for NodeGrantDatabaseStorage:

Public Member Functions

 __construct (Connection $database, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager)
 
 access (NodeInterface $node, $operation, AccountInterface $account)
 
 checkAll (AccountInterface $account)
 
 alterQuery ($query, array $tables, $op, AccountInterface $account, $base_table)
 
 write (NodeInterface $node, array $grants, $realm=NULL, $delete=TRUE)
 
 delete ()
 
 writeDefault ()
 
 count ()
 
 deleteNodeRecords (array $nids)
 

Static Protected Member Functions

static buildGrantsQueryCondition (array $node_access_grants)
 

Protected Attributes

 $database
 
 $moduleHandler
 
 $languageManager
 

Detailed Description

Defines a controller class that handles the node grants system.

This is used to build node query access.

Constructor & Destructor Documentation

__construct ( Connection  $database,
ModuleHandlerInterface  $module_handler,
LanguageManagerInterface  $language_manager 
)

Constructs a NodeGrantDatabaseStorage object.

Parameters
\Drupal\Core\Database\Connection$databaseThe database connection.
\Drupal\Core\Extension\ModuleHandlerInterface$module_handlerThe module handler.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.

References Drupal\database(), Drupal\languageManager(), and Drupal\moduleHandler().

Here is the call graph for this function:

Member Function Documentation

access ( NodeInterface  $node,
  $operation,
AccountInterface  $account 
)

{Determines access to nodes based on node grants.

Parameters
\Drupal\node\NodeInterface$nodeThe entity for which to check 'create' access.
string$operationThe entity operation. Usually one of 'view', 'edit', 'create' or 'delete'.
\Drupal\Core\Session\AccountInterface$accountThe user for which to check access.
Returns
The access result, either allowed or neutral. If there are no node grants, the default grant defined by writeDefault() is applied.
See Also
hook_node_grants()
hook_node_access_records()
::writeDefault()
}

Implements NodeGrantDatabaseStorageInterface.

References AccessResult\allowed(), AccessResult\allowedIf(), NodeGrantDatabaseStorage\count(), Drupal\database(), EntityInterface\id(), NodeInterface\isPublished(), TranslatableInterface\language(), Drupal\moduleHandler(), and AccessResult\neutral().

Here is the call graph for this function:

alterQuery (   $query,
array  $tables,
  $op,
AccountInterface  $account,
  $base_table 
)

{Alters a query when node access is required.

Parameters
mixed$queryQuery that is being altered.
array$tablesA list of tables that need to be part of the alter.
string$opThe operation to be performed on the node. Possible values are:
  • "view"
  • "update"
  • "delete"
  • "create"
\Drupal\Core\Session\AccountInterface$accountA user object representing the user for whom the operation is to be performed.
string$base_tableThe base table of the query.
Returns
int Status of the access check.
}

Implements NodeGrantDatabaseStorageInterface.

References NodeGrantDatabaseStorage\count(), Drupal\database(), and Drupal\languageManager().

Here is the call graph for this function:

static buildGrantsQueryCondition ( array  $node_access_grants)
staticprotected

Creates a query condition from an array of node access grants.

Parameters
array$node_access_grantsAn array of grants, as returned by node_access_grants().
Returns
A condition object to be passed to $query->condition().
See Also
node_access_grants()
checkAll ( AccountInterface  $account)

{Checks all grants for a given account.

Parameters
\Drupal\Core\Session\AccountInterface$accountA user object representing the user for whom the operation is to be performed.
Returns
int. Status of the access check.
}

Implements NodeGrantDatabaseStorageInterface.

References NodeGrantDatabaseStorage\count(), and Drupal\database().

Here is the call graph for this function:

count ( )

{Counts available node grants.

Returns
int Returns the amount of node grants.
}

Implements NodeGrantDatabaseStorageInterface.

References Drupal\database().

Referenced by NodeGrantDatabaseStorage\access(), NodeGrantDatabaseStorage\alterQuery(), NodeGrantDatabaseStorage\checkAll(), and NodeGrantDatabaseStorage\write().

Here is the call graph for this function:

Here is the caller graph for this function:

delete ( )

{Deletes all node access entries.}

Implements NodeGrantDatabaseStorageInterface.

References Drupal\database().

Here is the call graph for this function:

deleteNodeRecords ( array  $nids)

{Remove the access records belonging to certain nodes.

Parameters
array$nidsA list of node IDs. The grant records belonging to these nodes will be deleted.
}

Implements NodeGrantDatabaseStorageInterface.

References Drupal\database().

Here is the call graph for this function:

write ( NodeInterface  $node,
array  $grants,
  $realm = NULL,
  $delete = TRUE 
)

{Writes a list of grants to the database, deleting previously saved ones.If a realm is provided, it will only delete grants from that realm, but it will always delete a grant from the 'all' realm. Modules that use node access can use this method when doing mass updates due to widespread permission changes.Note: Don't call this method directly from a contributed module. Call node_access_write_grants() instead.

Parameters
\Drupal\node\NodeInterface$nodeThe node whose grants are being written.
array$grantsA list of grants to write. Each grant is an array that must contain the following keys: realm, gid, grant_view, grant_update, grant_delete. The realm is specified by a particular module; the gid is as well, and is a module-defined id to define grant privileges. each grant_* field is a boolean value.
string$realm(optional) If provided, read/write grants for that realm only. Defaults to NULL.
bool$delete(optional) If false, does not delete records. This is only for optimization purposes, and assumes the caller has already performed a mass delete of some form. Defaults to TRUE.
See Also
node_access_write_grants()
node_access_acquire_grants()
}

Implements NodeGrantDatabaseStorageInterface.

References NodeGrantDatabaseStorage\count(), Drupal\database(), TranslatableInterface\getTranslationLanguages(), EntityInterface\id(), TranslatableInterface\language(), Drupal\languageManager(), and Drupal\moduleHandler().

Here is the call graph for this function:

writeDefault ( )

{Creates the default node access grant entry.}

Implements NodeGrantDatabaseStorageInterface.

References Drupal\database().

Here is the call graph for this function:


The documentation for this class was generated from the following file: