定制 heimrichhannot/contao-versions 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

heimrichhannot/contao-versions

最新稳定版本:2.4.2

Composer 安装命令:

composer require heimrichhannot/contao-versions

包简介

Create versions within contao with ease and prevent entities from being purged by fromTable name. Also usable in frontend.

README 文档

README

This bundle enhances the contao version entity with persistent tables options and helper methods.

Features

  • Add fromTable names to huh_versions.persistent_tables that should persist within tl_version forever or a custom time frame.
  • Use the VersionModel to find tl_version models

Register persistent tables

To make your entities from a given fromTable persist add the table name to the huh_versions.persistent_tables within your project configuration (typical config/config.yml).

# config/config.yml
huh_versions:
  persistent_tables:
    - tl_my_custom_entity
    - tl_keep_forever

Create a new version entry

Instead of using the versions class direct, you can use the VersionControl service instead.

use Contao\FrontendUser;
use Contao\Versions;
use HeimrichHannot\VersionsBundle\Version\VersionControl;

class MyCustomEntity 
{
    /** @var VersionControl */
    private $versionControl;

    protected function createVersion(int $id, FrontendUser $member): void
    {
        // Simple call
        $this->versionControl->createVersion('tl_my_custom_entity', $id);
        
        // Pass additional options
        $this->versionControl->createVersion('tl_my_custom_entity', $id, [
            'hideUser' => false,
            'additionalData' => [
                'memberid' => $member->id,
                'memberusername' => $member->username,
                'username' => 'FrontendUser',
                'userid' => 0,
            ],
            'instance' => new Versions('tl_my_custom_entity', $id),
        ]);
    }
}

VersionControl::createVersion options:

  • hideUser: (bool) Don't add user to version log entry. Default false
  • additionalData: (array|null) Pass data that should be stored within the log entry. The array keys must be existing database column names. Default null
  • instance: (Version|null)Pass a custom Versions instance instead of the default one. Default null

Configuration reference

# Default configuration for extension with alias: "huh_versions"
huh_versions:

  # Set table names that should be persist within tl_versions.
  persistent_tables:

    # Examples:
    - tl_content
    - tl_my_custom_entity

  # Set the time period persistent table versions should be kept in version table. Set to 0 for forever.
  persistent_version_period: ~ # Example: 7776000

统计信息

  • 总下载量: 6.7k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2016-08-24