2021-08-24 20:29:26 +01:00
|
|
|
<?php
|
|
|
|
|
2021-10-10 09:26:18 +01:00
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2021-10-04 17:00:58 +01:00
|
|
|
namespace Plugin\ActivityPub\Util\Model\EntityToType;
|
2021-08-24 20:29:26 +01:00
|
|
|
|
2021-09-06 23:47:28 +01:00
|
|
|
use App\Core\Entity;
|
2021-10-10 09:26:18 +01:00
|
|
|
use Exception;
|
2021-10-04 17:00:58 +01:00
|
|
|
use Plugin\ActivityPub\Util\Type;
|
2021-08-24 20:29:26 +01:00
|
|
|
|
|
|
|
abstract class EntityToType
|
|
|
|
{
|
|
|
|
/**
|
2021-10-10 09:26:18 +01:00
|
|
|
* @throws Exception
|
2021-08-24 20:29:26 +01:00
|
|
|
*/
|
2021-10-10 09:26:18 +01:00
|
|
|
public static function translate(Entity $entity): Type
|
2021-08-24 20:29:26 +01:00
|
|
|
{
|
|
|
|
switch ($entity::class) {
|
|
|
|
case 'Note':
|
|
|
|
return NoteToType::translate($entity);
|
|
|
|
default:
|
|
|
|
$map = [
|
|
|
|
'type' => 'Object',
|
|
|
|
];
|
|
|
|
return Type::create($map);
|
|
|
|
}
|
|
|
|
}
|
2021-09-06 23:47:28 +01:00
|
|
|
}
|