og-8.x-1.x-dev/src/Plugin/QueueWorker/DeleteOrphan.php

src/Plugin/QueueWorker/DeleteOrphan.php
<?php

declare(strict_types=1);

namespace Drupal\og\Plugin\QueueWorker;

use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Queue\Attribute\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\og\OgDeleteOrphansPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Deletes orphaned group content.
 */
#[QueueWorker(
  id: 'og_orphaned_group_content_cron',
  title: new TranslatableMarkup('Delete orphaned group content'),
  cron: ['time' => 60],
)]
class DeleteOrphan extends QueueWorkerBase implements ContainerFactoryPluginInterface {

  public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
    protected readonly OgDeleteOrphansPluginManager $ogDeleteOrphansPluginManager,
  ) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('plugin.manager.og.delete_orphans')
    );
  }

  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    $this->ogDeleteOrphansPluginManager->createInstance('cron', [])->processItem($data);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc