1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69:
<?php
namespace Donut;
use CzProject\Logger;
use Ramsey\Uuid\Uuid;
class Manager
{
private $adapter;
private $currentTimeFactory;
private $logger;
public function __construct(IAdapter $adapter, ICurrentTimeFactory $currentTimeFactory, Logger\ILogger $logger)
{
$this->adapter = $adapter;
$this->currentTimeFactory = $currentTimeFactory;
$this->logger = $logger;
}
public function log($subject, $text = NULL, Message $message = NULL)
{
$this->adapter->log($subject, $text, $message, $this->currentTimeFactory->createTime());
}
public function createMessage($queue, array $data, Time $date = NULL)
{
$id = Uuid::uuid4();
$this->logger->log('Created new message ' . $id->toString() . " in queue '$queue'");
$created = $this->currentTimeFactory->createTime();
$message = new Message($id, $queue, $data, $date ? $date : $created, $created, Message::STATUS_NEW);
$this->adapter->createMessage($message);
}
public function existsItem($group, $itemId)
{
return $this->adapter->existsItem($group, $itemId);
}
public function saveItem($group, $itemId)
{
$this->adapter->saveItem($group, $itemId);
}
}