Drupal modules for browsing and managing Fedora-based digital repositories.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

<?php
namespace Drupal\islandora\EventGenerator;
use Drupal\Core\Entity\EntityInterface;
use Drupal\user\UserInterface;
/**
* The default EventGenerator implementation.
*
* Provides Activity Stream 2.0 serialized events.
*/
class EventGenerator implements EventGeneratorInterface {
/**
* {@inheritdoc}
*/
public function generateCreateEvent(EntityInterface $entity, UserInterface $user) {
return json_encode([
"@context" => "https://www.w3.org/ns/activitystreams",
"type" => "Create",
"actor" => [
"type" => "Person",
"id" => $user->toUrl()->setAbsolute()->toString(),
],
"object" => $entity->toUrl()->setAbsolute()->toString(),
]);
8 years ago
}
/**
* {@inheritdoc}
*/
public function generateUpdateEvent(EntityInterface $entity, UserInterface $user) {
return json_encode([
"@context" => "https://www.w3.org/ns/activitystreams",
"type" => "Update",
"actor" => [
"type" => "Person",
"id" => $user->toUrl()->setAbsolute()->toString(),
],
"object" => $entity->toUrl()->setAbsolute()->toString(),
]);
}
/**
* {@inheritdoc}
*/
public function generateDeleteEvent(EntityInterface $entity, UserInterface $user) {
return json_encode([
"@context" => "https://www.w3.org/ns/activitystreams",
"type" => "Delete",
"actor" => [
"type" => "Person",
"id" => $user->toUrl()->setAbsolute()->toString(),
],
"object" => $entity->toUrl()->setAbsolute()->toString(),
]);
}
}