Skip to content

Instantly share code, notes, and snippets.

@kaecyra
Created March 11, 2017 00:38
Show Gist options
  • Save kaecyra/64ccd1cacfe2e2212686654f8bdaada1 to your computer and use it in GitHub Desktop.
Save kaecyra/64ccd1cacfe2e2212686654f8bdaada1 to your computer and use it in GitHub Desktop.
<?php
/**
* @license Proprietary
* @copyright 2009-2016 Vanilla Forums Inc.
*/
namespace Vanilla\ProductQueue\Job;
use Vanilla\ProductQueue\Job\AbstractJob;
use Vanilla\ProductQueue\Addon\Vanilla\Customer\Site;
use Garden\Container\Container;
use Psr\Log\LogLevel;
/**
* Vanilla Test Job
*
* @author Tim Gunter <tim@vanillaforums.com>
* @package productqueue
* @version 1.0
*/
class TestJob extends AbstractJob {
/**
* Orchestration API client
* @var OrchestrationHttpClient
*/
protected $site;
/**
* Prepare job
*
* @param Container $di
* @param Customer $site
*/
public function __construct(Container $di, Site $site) {
parent::__construct($di);
$this->site = $site;
}
/**
* Run job
*
* @throws \Exception
*/
public function run() {
$this->log(LogLevel::WARNING, "Test job.");
if (!$this->site->isReady()) {
throw new \Exception("Site context is not ready.");
}
$this->log(LogLevel::WARNING, " querying site: {siteid}", [
'siteid' => $this->site->getSiteID()
]);
$site = $this->site->getSite();
$this->log(LogLevel::WARNING, " site: {name}", $site);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment