gorriecoe/silverstripe-embed

添加嵌入和视频数据对象以及数据扩展,以便将嵌入应用到现有对象。

安装次数: 10,945

依赖者: 2

建议者: 0

安全性: 0

星标: 1

关注者: 2

分支: 12

公开问题: 5

类型:silverstripe-vendormodule

1.0.2 2018-07-10 03:54 UTC

This package is auto-updated.

Last update: 2024-09-20 19:45:27 UTC


README

ko-fi

添加嵌入和视频数据对象以及数据扩展,以便将嵌入应用到现有对象。

安装

Composer 是安装 SilverStripe 模块的推荐方式。

composer require gorriecoe/silverstripe-embed

要求

  • silverstripe/framework ^4.0

维护者

使用

与嵌入数据对象的关系

use gorriecoe\Embed\Models\Embed;

class ClassName extends DataObject
{
    private static $has_one = [
        'Embed' => Embed::class,
        'Video' => Video::class
    ];

    public function getCMSFields()
    {
        ...
        $fields->addFieldsToTab(
            'Main',
            [
                HasOneButtonField::create(
                    'Embed',
                    'Embed',
                    $this
                ),
                HasOneButtonField::create(
                    'Video',
                    'Video',
                    $this
                )
            ]
        );
        ...
    }
}

使用数据扩展更新当前数据对象以支持嵌入

use gorriecoe\Embed\Extensions\Embeddable;

class ClassName extends DataObject
{
    private static $extensions = [
        Embeddable::class,
    ];

    /**
     * List the allowed included embed types.  If null all are allowed.
     * @var array
     */
    private static $allowed_embed_types = [
        'video',
        'photo'
    ];

    /**
     * Defines tab to insert the embed fields into.
     * @var string
     */
    private static $embed_tab = 'Main';
}