-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrepec.module
98 lines (88 loc) · 3.06 KB
/
repec.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* @file
* Contains repec.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\node\Entity\Node;
use Drupal\repec\Repec;
/**
* Implements hook_help().
*/
function repec_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the repec module.
case 'help.page.repec':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('RDF integration with Research Papers in Economics (RePEc).') . '</p>';
// @todo translation
$output .= '<p>This module helps you create a repository for <a href="http://repec.org" target="_blank">Research Papers in Economics</a> (RePEc). A template is created an updated automatically when new content is added to a content type matched in the Paper Series. <br>
RePEc is a collaborative effort of hundreds of volunteers in 82 countries to enhance the dissemination of research in Economics and related sciences. Collected papers are searchable from the <a href="http://ideas.repec.org" target="_blank">RePEc Ideas website.</a></p>';
return $output;
default:
}
}
/**
* Implements hook_entity_insert().
*/
function repec_entity_insert(EntityInterface $entity) {
/** @var \Drupal\repec\RepecInterface $repec */
$repec = \Drupal::service('repec');
// @todo remove limitation to node while covering other entity types
if ($entity->getEntityTypeId() === 'node' && $repec->isBundleEnabled($entity)) {
assert($entity instanceof Node);
if ($repec->isEntityShareable($entity)) {
$repec->createEntityTemplate($entity, Repec::SERIES_WORKING_PAPER);
}
}
}
/**
* Implements hook_entity_update().
*/
function repec_entity_update(EntityInterface $entity) {
/** @var \Drupal\repec\RepecInterface $repec */
$repec = \Drupal::service('repec');
// @todo remove limitation to node while covering other entity types
if ($entity->getEntityTypeId() === 'node' && $repec->isBundleEnabled($entity)) {
assert($entity instanceof Node);
if ($repec->isEntityShareable($entity)) {
$repec->updateEntityTemplate($entity, Repec::SERIES_WORKING_PAPER);
}
else {
$repec->deleteEntityTemplate($entity);
}
}
}
/**
* Implements hook_entity_delete().
*/
function repec_entity_delete(EntityInterface $entity) {
/** @var \Drupal\repec\RepecInterface $repec */
$repec = \Drupal::service('repec');
// @todo remove limitation to node while covering other entity types
if ($entity->getEntityTypeId() === 'node' && $repec->isBundleEnabled($entity)) {
assert($entity instanceof Node);
$repec->deleteEntityTemplate($entity);
}
}
/**
* Implements hook_repec_paper_mapping().
*/
function repec_repec_paper_mapping(ContentEntityInterface $entity) {
// @todo implement
}
/**
* Implements hook_repec_series_mapping().
*/
function repec_repec_series_mapping() {
// @todo implement
}
/**
* Implements hook_repec_archive_mapping().
*/
function repec_repec_archive_mapping() {
// @todo implement
}