forked from freelock/entityqueue_taxonomy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentityqueue_taxonomy.module
More file actions
49 lines (44 loc) · 1.46 KB
/
entityqueue_taxonomy.module
File metadata and controls
49 lines (44 loc) · 1.46 KB
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
<?php
/**
* @file
* Contains entityqueue_taxonomy.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\entityqueue\Entity\EntityQueue;
use Drupal\entityqueue\Entity\EntitySubqueue;
/**
* Implements hook_help().
*/
function entityqueue_taxonomy_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the entityqueue_taxonomy module.
case 'help.page.entityqueue_taxonomy':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Entityqueue Taxonomy -- smart queues for taxonomy terms') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_ENTITY_TYPE_insert.
*/
function entityqueue_taxonomy_term_insert(\Drupal\taxonomy\TermInterface $term) {
/** @var EntityQueue $entityqueues */
$entityqueues = EntityQueue::loadMultiple();
foreach ($entityqueues as $id => $entityqueue) {
if ($entityqueue->getHandler() === 'taxonomy_term') {
/** @var \Drupal\entityqueue_taxonomy\Plugin\EntityQueueHandler\Taxonomy $plugin */
$plugin = $entityqueue->getHandlerPlugin();
if ($plugin->getConfiguration()['vocabulary'] == $term->bundle()) {
$subqueue = EntitySubqueue::create([
'queue' => $entityqueue->id(),
'name' => $entityqueue->id() . '_' . $term->id(),
'title' => $term->label(),
'langcode' => $entityqueue->language()->getId(),
]);
$subqueue->save();
}
}
}
}