class SecondaryContactConnectionPermission in RedHen CRM 8
Provide permission for contacts that share a redhen_connection.
Plugin annotation
@ConnectionPermission(
id = "secondary_contact_connection_permission",
label = @Translation("Secondary Contact"),
description = @Translation("A contact connected to the same entity via connection of the same type. Sitewide permissions will override this setting."),
subject_entity_type = "redhen_contact",
subject_entity_bundle = "",
influencer_entity_type = "redhen_org",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\redhen_connection\Plugin\ConnectionPermissionBase implements ConnectionPermissionInterface
- class \Drupal\redhen_connection\Plugin\ConnectionPermission\SecondaryContactConnectionPermission implements ConnectionPermissionInterface
- class \Drupal\redhen_connection\Plugin\ConnectionPermissionBase implements ConnectionPermissionInterface
Expanded class hierarchy of SecondaryContactConnectionPermission
File
- modules/
redhen_connection/ src/ Plugin/ ConnectionPermission/ SecondaryContactConnectionPermission.php, line 23
Namespace
Drupal\redhen_connection\Plugin\ConnectionPermissionView source
class SecondaryContactConnectionPermission extends ConnectionPermissionBase implements ConnectionPermissionInterface {
/**
* {@inheritdoc}
*/
public function getPermissionKey() {
return 'contact';
}
/**
* {@inheritdoc}
*/
public function getInfluencers(EntityInterface $subject_entity) {
$influencers = [];
// Get all connection types for this subject.
$connection_types = $this->redhenConnectionConnections
->getConnectionTypes($subject_entity);
// Loop over types and find contact and org connection types.
foreach ($connection_types as $type) {
$endpoints[] = $type
->getEndpointEntityTypeId(1);
$endpoints[] = $type
->getEndpointEntityTypeId(2);
// If both there is a contact and an org endpoint take further action.
if (in_array($this
->get('subject_entity_type'), $endpoints) && in_array($this
->get('influencer_entity_type'), $endpoints)) {
// Load up the org from the connection.
$connected_entities = $this->redhenConnectionConnections
->getConnectedEntities($subject_entity, $type
->id());
// Add the connected entities to the influencers array.
foreach ($connected_entities as $entity) {
$influencers[] = $entity;
}
}
}
return $influencers;
}
/**
* {@inheritdoc}
*/
public function hasRolePermissions(EntityInterface $subject_entity, $operation, Contact $contact) {
$access = new AccessResultNeutral();
$influencers = $this
->getInfluencers($subject_entity);
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 |
---|---|---|---|---|
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. | |
SecondaryContactConnectionPermission:: |
public | function |
Get the influencer entity. Overrides ConnectionPermissionBase:: |
|
SecondaryContactConnectionPermission:: |
public | function |
Get the entity key. Overrides ConnectionPermissionBase:: |
|
SecondaryContactConnectionPermission:: |
public | function |
Determine if the contact execute the operation on the subject entity. Overrides ConnectionPermissionBase:: |