Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
digitalascetic/notifications / Entity / NotificationObject.php
Size: Mime:
<?php


namespace DigitalAscetic\NotificationsBundle\Entity;


use DigitalAscetic\BaseEntityBundle\Entity\BaseEntity;
use DigitalAscetic\BaseEntityBundle\Entity\CreatedTrait;
use DigitalAscetic\BaseEntityBundle\Entity\UpdatedTrait;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * Class NotificationObject
 *
 * This class represents de object related to the notification.
 *
 * @package DigitalAscetic\NotificationsBundle\Entity
 *
 * @ORM\Table(name="notification_object",
 *   indexes={
 *   @ORM\Index(name="not_obj_actor", columns={"actorId"}),
 *   @ORM\Index(name="not_obj_entity", columns={"entityType", "entityTypeId"}),
 *   @ORM\Index(name="not_obj_entity_topic", columns={"entityType", "entityTypeId", "topic"})
 * })
 * @ORM\Entity()
 */
#[ORM\Table(name: "notification_object")]
#[ORM\Index(columns: ["actorId"], name: "not_obj_actor")]
#[ORM\Index(columns: ["entityType", "entityTypeId"], name: "not_obj_entity")]
#[ORM\Index(columns: ["entityType", "entityTypeId", "topic"], name: "not_obj_entity_topic")]
#[ORM\Entity]
class NotificationObject extends BaseEntity
{
    use CreatedTrait;
    use UpdatedTrait;

    const ALIAS = 'notObj';

    const VIEW_COMPLETE = 'complete';

    const VIEW_DEFAULT = 'default';

    public static function getSerializationGroups($viewName)
    {
        switch ($viewName) {
            case 'default':
                $result = [
                    'ascetic.notification_obj.default'
                ];
                break;
            case 'complete':
                $result = [
                    'ascetic.notification_obj.default'
                ];
                break;
            default:
                $result = [
                    'ascetic.notification_obj.default'
                ];
                break;
        }

        return $result;
    }

    /**
     * @var int
     *
     * Who creates (and triggers) the notification
     *
     * @ORM\Column(name="actorId", type="integer", nullable=false)
     * @Groups({"ascetic.notification_obj.default"})
     */
    #[ORM\Column(name: "actorId", type: "integer", nullable: false)]
    #[Groups("ascetic.notification_obj.default")]
    private int $actor;

    /**
     * @var string
     *
     * Topic
     *
     * @ORM\Column(name="topic", type="string", nullable=false)
     * @Groups({"ascetic.notification_obj.default"})
     */
    #[ORM\Column(name: "topic", type: "string", nullable: false)]
    #[Groups("ascetic.notification_obj.default")]
    private string $topic;

    /**
     * @var string|null
     *
     * EntityType will help us to know what the notification is about.
     * For example, a notification can be about a group or a post or a comment etc.
     *
     * @ORM\Column(name="entityType", type="string", nullable=true)
     * @Groups({"ascetic.notification_obj.default"})
     */
    #[ORM\Column(name: "entityType", type: "string", nullable: true)]
    #[Groups("ascetic.notification_obj.default")]
    private ?string $entityType = null;

    /**
     * @var int|null
     *
     * The id of the entity related to the notification.
     *
     * @ORM\Column(name="entityTypeId", type="integer", nullable=true)
     * @Groups({"ascetic.notification_obj.default"})
     */
    #[ORM\Column(name: "entityTypeId", type: "integer", nullable: true)]
    #[Groups("ascetic.notification_obj.default")]
    private ?int $entityTypeId = null;

    /**
     * @var string
     *
     * @ORM\Column(name="message", type="text", nullable=false)
     * @Groups({"ascetic.notification_obj.default"})
     */
    #[ORM\Column(name: "message", type: "text", nullable: false)]
    #[Groups("ascetic.notification_obj.default")]
    private string $message;

    /**
     * NotificationObject constructor.
     * @param int $actor
     * @param string $message
     * @param int $topic
     */
    public function __construct(int $actor, string $message, int $topic)
    {
        $this->actor = $actor;
        $this->message = $message;
        $this->topic = $topic;
    }

    /**
     * @return int
     */
    public function getActor(): int
    {
        return $this->actor;
    }

    /**
     * @return string
     */
    public function getMessage(): string
    {
        return $this->message;
    }

    /**
     * @return string|null
     */
    public function getEntityType(): ?string
    {
        return $this->entityType;
    }

    /**
     * @param string|null $entityType
     */
    public function setEntityType(?string $entityType): void
    {
        $this->entityType = $entityType;
    }

    /**
     * @return int|null
     */
    public function getEntityTypeId(): ?int
    {
        return $this->entityTypeId;
    }

    /**
     * @param int|null $entityTypeId
     */
    public function setEntityTypeId(?int $entityTypeId): void
    {
        $this->entityTypeId = $entityTypeId;
    }

    /**
     * @return string
     */
    public function getTopic(): string
    {
        return $this->topic;
    }

    /**
     * @param string $topic
     */
    public function setTopic(string $topic): void
    {
        $this->topic = $topic;
    }
}