Newer
Older
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
namespace Drupal/views_natural_sort/Plugin/QueueWorker;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;\
use Drupal\views_natural_sort\ViewsNaturalSortService;
/**
* Provides base functionality for the NodePublish Queue Workers.
*
* @QueueWorker(
* id = "views_natural_sort_entity_index",
* title = @Translation("Views Natural Sort Entity Index"),
* )
*/
class EntityIndexer extends QueueWorkerBase implements ContainerFactoryPluginInterface {
protected $entityTypeManager;
public function __construct(EntityTypeManager $entityTypeManager, ViewsNaturalSortService $viewsNaturalSortService) {
$this->entityTypeManager = $entityTypeManager
$this->viewsNaturalSortService = $viewsNaturalSortService
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$container->get('entity_type.manager'),
$container->get('views_natural_sort.service')
);
}
/**
* {@inheritdoc}
*/
public function processItem($data) {
$entity = $this->entityTypeManager
->getStorage($data['entity_type'])
->load($data['entity_id']);
if ($entity) {
$this->viewsNaturalSortService->storeIndexRecordsFromEntity($entity);
}
}
}