1
0
Fork 0
mirror of synced 2024-09-29 08:51:28 +13:00
appwrite/src/Appwrite/Event/Delete.php

148 lines
3 KiB
PHP
Raw Normal View History

<?php
namespace Appwrite\Event;
use Resque;
use Utopia\Database\Document;
class Delete extends Event
{
protected string $type = '';
protected ?Document $document = null;
2022-08-15 21:05:41 +12:00
protected ?string $resource = null;
2022-07-12 03:12:41 +12:00
protected ?string $datetime = null;
protected ?string $dateTime30m = null;
protected ?string $dateTime1d = 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.
*
2022-05-24 02:54:50 +12:00
* @return string
2022-04-19 04:21:45 +12:00
*/
public function getType(): string
{
return $this->type;
}
2022-05-11 00:33:31 +12:00
/**
2022-07-12 03:12:41 +12:00
* set Datetime.
2022-05-11 00:33:31 +12:00
*
2022-07-12 03:12:41 +12:00
* @param string $datetime
2022-05-11 00:33:31 +12:00
* @return self
*/
2022-07-12 03:12:41 +12:00
public function setDatetime(string $datetime): self
2022-04-20 01:13:55 +12:00
{
2022-07-12 03:12:41 +12:00
$this->datetime = $datetime;
2022-04-20 01:13:55 +12:00
return $this;
}
2022-05-11 00:33:31 +12:00
/**
2022-07-12 03:12:41 +12:00
* Set datetime for 1 day interval.
2022-05-11 00:33:31 +12:00
*
2022-07-12 03:12:41 +12:00
* @param string $datetime
2022-05-11 00:33:31 +12:00
* @return self
*/
public function setDateTime1d(string $datetime): self
2022-04-20 01:13:55 +12:00
{
$this->dateTime1d = $datetime;
2022-04-20 01:13:55 +12:00
return $this;
}
2022-05-11 00:33:31 +12:00
/**
2022-07-12 03:12:41 +12:00
* Sets datetime for 30m interval.
2022-05-11 00:33:31 +12:00
*
2022-07-12 03:12:41 +12:00
* @param string $datetime
2022-05-11 00:33:31 +12:00
* @return self
*/
public function setDateTime30m(string $datetime): self
2022-04-20 01:13:55 +12:00
{
$this->dateTime30m = $datetime;
2022-04-20 01:13:55 +12:00
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-08-15 21:05:41 +12:00
/**
* Returns the resource for the delete event.
*
* @return string
*/
public function getResource(): string
{
return $this->resource;
}
/**
* Sets the resource for the delete event.
*
* @param string $resource
* @return self
*/
public function setResource(string $resource): self
{
$this->resource = $resource;
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-08-15 21:05:41 +12:00
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-08-15 21:05:41 +12:00
'resource' => $this->resource,
2022-07-12 03:12:41 +12:00
'datetime' => $this->datetime,
'dateTime1d' => $this->dateTime1d,
'dateTime30m' => $this->dateTime30m,
]);
}
2022-04-19 04:21:45 +12:00
}