ContentModerationNotification.php in Content Moderation Notifications 8.2
Same filename and directory in other branches
File
src/Entity/ContentModerationNotification.phpView source
<?php
namespace Drupal\content_moderation_notifications\Entity;
use Drupal\content_moderation_notifications\ContentModerationNotificationInterface;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
/**
* Defines the content_moderation_notification entity.
*
* The lines below, starting with '@ConfigEntityType,' are a plugin annotation.
* These define the entity type to the entity type manager.
*
* The properties in the annotation are as follows:
* - id: The machine name of the entity type.
* - label: The human-readable label of the entity type. We pass this through
* the "@Translation" wrapper so that the multilingual system may
* translate it in the user interface.
* - handlers: An array of entity handler classes, keyed by handler type.
* - access: The class that is used for access checks.
* - list_builder: The class that provides listings of the entity.
* - form: An array of entity form classes keyed by their operation.
* - entity_keys: Specifies the class properties in which unique keys are
* stored for this entity type. Unique keys are properties which you know
* will be unique, and which the entity manager can use as unique in database
* queries.
* - links: entity URL definitions. These are mostly used for Field UI.
* Arbitrary keys can set here. For example, User sets cancel-form, while
* Node uses delete-form.
*
* @see http://previousnext.com.au/blog/understanding-drupal-8s-config-entities
* @see annotation
* @see Drupal\Core\Annotation\Translation
*
* @ingroup content_moderation_notifications
*
* @ConfigEntityType(
* id = "content_moderation_notification",
* label = @Translation("Notification"),
* admin_permission = "administer content moderation notifications",
* handlers = {
* "access" = "Drupal\content_moderation_notifications\ContentModerationNotificationsAccessController",
* "list_builder" = "Drupal\content_moderation_notifications\Controller\ContentModerationNotificationsListBuilder",
* "form" = {
* "add" = "Drupal\content_moderation_notifications\Form\ContentModerationNotificationsAddForm",
* "edit" = "Drupal\content_moderation_notifications\Form\ContentModerationNotificationsEditForm",
* "delete" = "Drupal\content_moderation_notifications\Form\ContentModerationNotificationsDeleteForm"
* }
* },
* entity_keys = {
* "id" = "id",
* "label" = "label"
* },
* links = {
* "add-form" = "/admin/config/workflow/notifications/add",
* "edit-form" = "/admin/config/workflow/notifications/manage/{content_moderation_notification}",
* "delete-form" = "/admin/config/workflow/notifications/manage/{content_moderation_notification}/delete",
* "collection" = "/admin/config/workflow/notifications"
* },
* config_export = {
* "id",
* "workflow",
* "transitions",
* "roles",
* "author",
* "emails",
* "subject",
* "body",
* "label",
* }
* )
*/
class ContentModerationNotification extends ConfigEntityBase implements ContentModerationNotificationInterface {
/**
* {@inheritdoc}
*/
public function getWorkflowId() {
return $this
->get('workflow');
}
/**
* {@inheritdoc}
*/
public function getRoleIds() {
return $this
->get('roles');
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
$this
->set('roles', array_filter($this
->get('roles')));
$this
->set('transitions', array_filter($this
->get('transitions')));
parent::preSave($storage);
}
/**
* {@inheritdoc}
*/
public function getTransitions() {
return $this
->get('transitions');
}
/**
* {@inheritdoc}
*/
public function getSubject() {
return $this
->get('subject');
}
/**
* {@inheritdoc}
*/
public function getMessage() {
return $this
->get('body')['value'];
}
/**
* {@inheritdoc}
*/
public function getMessageFormat() {
return $this
->get('body')['format'];
}
}
Classes
Name | Description |
---|---|
ContentModerationNotification | Defines the content_moderation_notification entity. |