Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 1.13 KB

create.md

File metadata and controls

38 lines (29 loc) · 1.13 KB

Creating a new event

To create and publish an event to the activity app, a new IEvent should be fetched from the activity manager and afterwards be passed to the publish() method:

// The activity manager should be automatically injected
// by the type hint OCP\Activity\IManager, when inside a class.
// When you have a plain file without a class, you can use
// \OC::$server->getActivityManager() instead.

$event = $this->activityManager->createEvent();
...
$this->activityManager->->publish($event);

The following values must be set before publishing an event:

  • setApp()
  • setType() - this must match an ISetting::getIdentifier()
  • setAffectedUser()
  • setAuthor()
  • setTimestamp()
  • setSubject()
  • setObject()

Additionally these values can be set:

  • setMessage()
  • setLink() - should be done in IProvider::parse()
  • setIcon() - should be done in IProvider::parse()

The following values should not be set on publishing (are not saved), instead they should be set in IProvider::parse():

  • setParsedSubject()
  • setRichSubject()
  • setParsedMessage()
  • setRichMessage()
  • setChildEvent()