ruspanzer/loggable-bundle

Doctrine 简单可记录实体

安装: 15

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 1

公开问题: 0

类型:symfony-bundle

1.3.0 2019-10-25 13:14 UTC

This package is auto-updated.

Last update: 2024-09-26 01:06:08 UTC


README

简单实体可记录包

如何使用
  1. 安装包 composer require ruspanzer/loggable-bundle
  2. 为您的实体实现 Ruspanzer\LoggableBundle\Entity\Interfaces\LoggableInterface
  3. 如果您需要在两个可记录实体之间设置关系,请在相关实体中使用 getRelatedLogEntities。此方法必须返回一个 LoggableInterface 实体数组。这将允许在搜索主实体时搜索相关日志
  4. 使用仓库方法 getByObject() 查找日志。或者您也可以编写带有分页和其他酷炫功能的搜索实现
示例
class Place implements LoggableInterface
{
    /**
    * @ORM\Id()
    */
    private $id;

    /**
    * @ORM\OneToOne(targetEntity="Address")
    */
    private $address;
    
    public function getId() 
    {
        return $this->id;
    }
    
    public function getRelatedLogEntities() 
    {
        return [];
    }
}

class Address implements LoggableInterface
{
    /**
    * @ORM\Id()
    */
    private $id;

    /**
    * @ORM\OneToOne(targetEntity="Place")
    * @ORM\JoinColumn(name="place_id")
    */
    private $place;
    
    public function getId() 
    {
        return $this->id;
    }

    public function getPlace() 
    {
        return $this->place;
    }
    
    public function getRelatedLogEntities() 
    {
        return [
            $this->getPlace();
        ];
    }
}

如果您将通过位置搜索日志,则将返回地址日志

此包也支持 StofDoctrineExtensions Softdeleteable