-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathentity_limit.module
More file actions
39 lines (34 loc) · 978 Bytes
/
entity_limit.module
File metadata and controls
39 lines (34 loc) · 978 Bytes
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
<?php
/**
* @file
* Contains hooks and other things module.
*/
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function entity_limit_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.entity_limit':
$output = file_get_contents(drupal_get_path('module', 'entity_limit') . '/README.md');
return $output;
}
}
/**
* Implements hook_entity_create_access().
*
* @see: hook_entity_access().
*/
function entity_limit_entity_create_access(AccountInterface $account, array $context, $entity_bundle) {
$result = TRUE;
if (!empty($context['entity_type_id'])) {
$result = \Drupal::service('entity_limit.inspector')->checkEntityLimitAccess(
$context['entity_type_id'],
$entity_bundle,
$account
);
}
return ($result) ? AccessResult::neutral() : AccessResult::forbidden();
}