class ConnectionConnectionPermission in RedHen CRM 8
Provide permissions for the connection entity of a redhen_connection.
Plugin annotation
@ConnectionPermission(
id = "connection_connection_permission",
label = @Translation("Connection"),
description = @Translation("Applies to both current users connection and secondary connections. Sitewide permissions will override this permission."),
subject_entity_type = "redhen_connection",
subject_entity_bundle = "",
influencer_entity_type = "",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\redhen_connection\Plugin\ConnectionPermissionBase implements ConnectionPermissionInterface
- class \Drupal\redhen_connection\Plugin\ConnectionPermission\ConnectionConnectionPermission implements ConnectionPermissionInterface
- class \Drupal\redhen_connection\Plugin\ConnectionPermissionBase implements ConnectionPermissionInterface
Expanded class hierarchy of ConnectionConnectionPermission
File
- modules/
redhen_connection/ src/ Plugin/ ConnectionPermission/ ConnectionConnectionPermission.php, line 24
Namespace
Drupal\redhen_connection\Plugin\ConnectionPermissionView source
class ConnectionConnectionPermission extends ConnectionPermissionBase implements ConnectionPermissionInterface {
/**
* A Redhen Contact Object.
*
* @var \Drupal\Core\Entity\EntityInterface
*/
private $contact;
/**
* {@inheritdoc}
*/
public function getPermissionKey() {
return 'connection';
}
/**
* {@inheritdoc}
*/
public function getInfluencers(EntityInterface $subject_entity) {
// Return the connections for current contact and the subject.
return $this->redhenConnectionConnections
->getConnectedEntities($this->contact, $subject_entity
->getType());
}
/**
* {@inheritdoc}
*/
public function hasRolePermissions(EntityInterface $subject_entity, $operation, Contact $contact) {
$this->contact = $contact;
$access = new AccessResultNeutral();
// Only check permissions for connections that are of a type with contacts.
$connection_type = ConnectionType::load($subject_entity
->getType());
if ($connection_type
->getEndpointEntityTypeId(1) == 'redhen_contact' || $connection_type
->getEndpointEntityTypeId(2) == 'redhen_contact') {
$influencers = $this
->getInfluencers($subject_entity);
if ($influencers) {
foreach ($influencers as $influencer) {
$access = $this->redhenConnectionConnections
->checkConnectionPermission($contact, $influencer, $operation, $this
->getPermissionKey());
if ($access
->isAllowed()) {
return $access;
}
}
}
}
return $access;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConnectionConnectionPermission:: |
private | property | A Redhen Contact Object. | |
ConnectionConnectionPermission:: |
public | function |
Get the influencer entity. Overrides ConnectionPermissionBase:: |
|
ConnectionConnectionPermission:: |
public | function |
Get the entity key. Overrides ConnectionPermissionBase:: |
|
ConnectionConnectionPermission:: |
public | function |
Determine if the contact execute the operation on the subject entity. Overrides ConnectionPermissionBase:: |
|
ConnectionPermissionBase:: |
public | property | Connection Service. | |
ConnectionPermissionBase:: |
public | function | Get values from plugin definition. | |
ConnectionPermissionBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. |