You are here

class CronHotspotsWorker in Image Hotspots 8

Deletes hotspots in queue on CRON run.

Plugin annotation


@QueueWorker(
  id = "cron_image_hotspots_deletion",
  title = @Translation("Cron image hotspots deletion"),
  cron = {"time" = 10}
)

Hierarchy

Expanded class hierarchy of CronHotspotsWorker

File

src/Plugin/QueueWorker/CronHotspotsWorker.php, line 19

Namespace

Drupal\image_hotspots\Plugin\QueueWorker
View source
class CronHotspotsWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {

  /**
   * The image hotspots storage.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $hotspotsStorage;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $hotspots_storage) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->hotspotsStorage = $hotspots_storage;
  }

  /**
   * {@inheritdoc}
   */
  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'));
  }

  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    $hotspot = $this->hotspotsStorage
      ->load($data['hid']);
    if (!is_null($hotspot)) {
      $hotspot
        ->delete();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CronHotspotsWorker::$hotspotsStorage protected property The image hotspots storage.
CronHotspotsWorker::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
CronHotspotsWorker::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
CronHotspotsWorker::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.