1
0
Fork 0
mirror of synced 2024-06-03 11:24:48 +12:00
appwrite/src/Appwrite/Event/Delete.php

124 lines
2.5 KiB
PHP
Raw Normal View History

<?php
namespace Appwrite\Event;
use Resque;
use Utopia\Database\Document;
class Delete extends Event
{
protected string $type = '';
2022-04-20 01:13:55 +12:00
protected ?int $timestamp = null;
protected ?int $timestamp1d = null;
protected ?int $timestamp30m = null;
protected ?Document $document = null;
public function __construct()
{
parent::__construct(Event::DELETE_QUEUE_NAME, Event::DELETE_CLASS_NAME);
}
2022-04-19 04:21:45 +12:00
/**
* Sets the type for the delete event (use the constants starting with DELETE_TYPE_*).
*
* @param string $type
* @return self
*/
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
2022-04-19 04:21:45 +12:00
/**
* Returns the set type for the delete event.
*
* @return string
*/
public function getType(): string
{
return $this->type;
}
2022-05-11 00:33:31 +12:00
/**
* Set timestamp.
*
* @param int $timestamp
* @return self
*/
2022-04-20 01:13:55 +12:00
public function setTimestamp(int $timestamp): self
{
$this->timestamp = $timestamp;
return $this;
}
2022-05-11 00:33:31 +12:00
/**
* Set timestamp for 1 day interval.
*
* @param int $timestamp
* @return self
*/
2022-04-20 01:13:55 +12:00
public function setTimestamp1d(int $timestamp): self
{
$this->timestamp1d = $timestamp;
return $this;
}
2022-05-11 00:33:31 +12:00
/**
* Sets timestamp for 30m interval.
*
* @param int $timestamp
* @return self
*/
2022-04-20 01:13:55 +12:00
public function setTimestamp30m(int $timestamp): self
{
$this->timestamp30m = $timestamp;
return $this;
}
2022-04-19 04:21:45 +12:00
/**
* Sets the document for the delete event.
*
2022-05-11 00:31:20 +12:00
* @param Document $document
2022-04-19 04:21:45 +12:00
* @return self
*/
public function setDocument(Document $document): self
{
$this->document = $document;
return $this;
}
2022-04-19 04:21:45 +12:00
/**
* Returns the set document for the delete event.
*
2022-05-11 00:31:20 +12:00
* @return null|Document
2022-04-19 04:21:45 +12:00
*/
public function getDocument(): ?Document
{
return $this->document;
}
2022-04-19 04:21:45 +12:00
/**
* Executes this event and sends it to the deletes worker.
*
* @return string|bool
* @throws \InvalidArgumentException
*/
public function trigger(): string|bool
{
return Resque::enqueue($this->queue, $this->class, [
'project' => $this->project,
'type' => $this->type,
'document' => $this->document,
2022-04-20 01:13:55 +12:00
'timestamp' => $this->timestamp,
'timestamp1d' => $this->timestamp1d,
'timestamp30m' => $this->timestamp30m
]);
}
2022-04-19 04:21:45 +12:00
}