appwrite/src/Appwrite/Event/Migration.php

83 lines
1.6 KiB
PHP
Raw Normal View History

2023-08-04 16:21:41 +00:00
<?php
namespace Appwrite\Event;
use Utopia\Database\Document;
2025-01-29 14:13:58 +00:00
use Utopia\Queue\Publisher;
2023-08-04 16:21:41 +00:00
class Migration extends Event
{
protected string $type = '';
protected ?Document $migration = null;
2025-01-29 14:13:58 +00:00
public function __construct(protected Publisher $publisher)
2023-08-04 16:21:41 +00:00
{
2025-01-29 14:13:58 +00:00
parent::__construct($publisher);
2023-10-01 17:39:26 +00:00
$this
->setQueue(Event::MIGRATIONS_QUEUE_NAME)
->setClass(Event::MIGRATIONS_CLASS_NAME);
2023-08-04 16:21:41 +00:00
}
/**
* Sets migration document for the migration event.
*
* @param Document $migration
* @return self
*/
public function setMigration(Document $migration): self
{
$this->migration = $migration;
return $this;
}
/**
* Returns set migration document for the function event.
*
* @return null|Document
*/
public function getMigration(): ?Document
{
return $this->migration;
}
/**
* Sets migration type for the migration event.
*
* @param string $type
*
* @return self
*/
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* Returns set migration type for the migration event.
*
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
2025-01-17 05:08:39 +00:00
* Prepare the payload for the migration event.
2023-08-04 16:21:41 +00:00
*
2025-01-17 05:08:39 +00:00
* @return array
2023-08-04 16:21:41 +00:00
*/
2025-01-17 05:08:39 +00:00
protected function preparePayload(): array
2023-08-04 16:21:41 +00:00
{
2025-01-17 05:08:39 +00:00
return [
2023-08-04 16:21:41 +00:00
'project' => $this->project,
'user' => $this->user,
2024-05-23 15:14:00 +00:00
'migration' => $this->migration,
2025-01-17 05:08:39 +00:00
];
2023-08-04 16:21:41 +00:00
}
}