-
Notifications
You must be signed in to change notification settings - Fork 1
/
vipps_recurring_payments.module
51 lines (44 loc) · 1.38 KB
/
vipps_recurring_payments.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @file
* Contains vipps_recurring_payments.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\user\Entity\Role;
/**
* Implements hook_help().
*/
function vipps_recurring_payments_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the vipps_recurring_payments module.
case 'help.page.vipps_recurring':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Drupal 8 module for vipps recurring payments') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_entity_operation().
*/
function vipps_recurring_payments_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) {
$operations = array();
$info = $entity->getEntityType();
$account = \Drupal::currentUser();
$current_user_roles = $account->getRoles();
if($info->id() == 'vipps_agreements' && !in_array('administrator', $current_user_roles)) {
if ($account->hasPermission('manage own vipps agreements entities')) {
$operations['manage-fields'] = array(
'title' => t('Cancel agreement'),
'weight' => 15,
'url' => Url::fromRoute("entity.vipps_agreements.user_cancel_form", [
'vipps_agreements' => $entity->id(),
'user' => \Drupal::currentUser()->id(),
]),
);
}
}
return $operations;
}