1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00
appwrite/src/Appwrite/Event/Event.php

76 lines
1.2 KiB
PHP
Raw Normal View History

2019-05-09 18:54:39 +12:00
<?php
namespace Appwrite\Event;
2019-05-09 18:54:39 +12:00
use Resque;
class Event
{
/**
* @var string
*/
protected $queue = '';
/**
* @var string
*/
protected $class = '';
/**
* @var array
*/
protected $params = [];
/**
* Event constructor.
*
2019-05-09 18:54:39 +12:00
* @param string $queue
* @param string $class
*/
2020-07-05 01:06:23 +12:00
public function __construct(string $queue, string $class)
2019-05-09 18:54:39 +12:00
{
$this->queue = $queue;
$this->class = $class;
}
/**
* @param string $key
* @param mixed $value
*
2019-05-09 18:54:39 +12:00
* @return $this
*/
2020-07-05 01:06:23 +12:00
public function setParam(string $key, $value): self
2019-05-09 18:54:39 +12:00
{
$this->params[$key] = $value;
2019-05-09 18:54:39 +12:00
return $this;
}
/**
* @param string $key
*
2019-05-09 18:54:39 +12:00
* @return mixed|null
*/
2020-07-05 01:06:23 +12:00
public function getParam(string $key)
2019-05-09 18:54:39 +12:00
{
return (isset($this->params[$key])) ? $this->params[$key] : null;
}
/**
* Execute Event.
2019-05-09 18:54:39 +12:00
*/
2020-07-05 01:06:23 +12:00
public function trigger(): void
2019-05-09 18:54:39 +12:00
{
Resque::enqueue($this->queue, $this->class, $this->params);
2020-07-05 01:06:23 +12:00
$this->reset();
}
public function reset(): self
{
$this->params = [];
return $this;
2019-05-09 18:54:39 +12:00
}
}