You are here

class WishlistItemDelete in Commerce Wishlist 8.3

Deletes queued wishlist items.

Plugin annotation


@QueueWorker(
  id = "commerce_wishlist_item_delete",
  title = @Translation("Wishlist item delete"),
  cron = {"time" = 10}
)

Hierarchy

Expanded class hierarchy of WishlistItemDelete

File

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

Namespace

Drupal\commerce_wishlist\Plugin\QueueWorker
View source
class WishlistItemDelete extends QueueWorkerBase implements ContainerFactoryPluginInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Creates a new WishlistItemDelete object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->entityTypeManager = $entity_type_manager;
  }

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

  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    $storage = $this->entityTypeManager
      ->getStorage('commerce_wishlist_item');
    $wishlist_items = $storage
      ->loadMultiple($data['ids']);
    if ($wishlist_items) {
      $storage
        ->delete($wishlist_items);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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.
WishlistItemDelete::$entityTypeManager protected property The entity type manager.
WishlistItemDelete::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
WishlistItemDelete::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
WishlistItemDelete::__construct public function Creates a new WishlistItemDelete object. Overrides PluginBase::__construct