软弹簧/通知包

用户通知包


README

Latest Stable Latest Unstable License PHP Version Downloads CI Coverage

安装

配置包

如果你使用flex,你可能不需要这样做。但如果你不使用或出现问题,你必须将包包含在config/bundles.php文件中

<?php

return [
    ...
    Softspring\NotificationBundle\SfsNotificationBundle::class => ['all' => true],
];

配置ORM

创建你的通知实体

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Softspring\Component\DoctrineTemplates\Entity\Traits\AutoId;
use Softspring\NotificationBundle\Model\Notification as SfsNotification;

/**
 * @ORM\Entity()
 * @ORM\Table(name="notification")
 */
class Notification extends SfsNotification
{
    use AutoId;
    
    /**
     * @var User|null
     * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="notifications")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
     */
    protected $user;
    
    /**
     * @inheritdoc
     */
    public function getUser(): ?UserInterface
    {
        return $this->user;
    }

    /**
     * @inheritdoc
     */
    public function setUser(UserInterface $user): void
    {
        $this->user = $user;
    }
}

创建config/packages/sfs_notification.yaml文件,并配置你的实体

sfs_notification:
    notification_class: App\Entity\Notification