1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00
appwrite/src/Appwrite/Event/Delete.php

134 lines
2.8 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;
2022-10-28 21:40:04 +13:00
protected ?string $hourlyUsageRetentionDatetime = 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-10-23 17:46:23 +13:00
* Sets datetime for 1h 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
*/
2022-10-28 22:54:56 +13:00
public function setUsageRetentionHourlyDateTime(string $datetime): self
2022-04-20 01:13:55 +12:00
{
2022-10-28 21:40:04 +13:00
$this->hourlyUsageRetentionDatetime = $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,
2022-10-28 21:40:04 +13:00
'hourlyUsageRetentionDatetime' => $this->hourlyUsageRetentionDatetime,
]);
}
2022-04-19 04:21:45 +12:00
}