<?php

namespace Drupal\swapi\Plugin\QueueWorker;

use Drupal\Core\Queue\QueueWorkerBase;

/**
 * QueueueWorker
 *
 * @QueueWorker (
 *  id = "swapi",
 *  title = "Queue swapi",
 *  cron = {"time" = 60}
 * )
 */
class QueueSwapi extends QueueWorkerBase {

  public function processItem($data) {

    /**
     * @var Drupal\swapi\Service\swapi
     */
    $swapi = \Drupal::service('swapi.service_swapi');

    $node = $swapi->getNodeFromUrl($data['url']);
    $swapi->update($data, $node);
  }
}
