CronHotspotsWorker.php in Image Hotspots 8
File
src/Plugin/QueueWorker/CronHotspotsWorker.php
View source
<?php
namespace Drupal\image_hotspots\Plugin\QueueWorker;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Queue\QueueWorkerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CronHotspotsWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
protected $hotspotsStorage;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $hotspots_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->hotspotsStorage = $hotspots_storage;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager')
->getStorage('image_hotspot'));
}
public function processItem($data) {
$hotspot = $this->hotspotsStorage
->load($data['hid']);
if (!is_null($hotspot)) {
$hotspot
->delete();
}
}
}