PHP code example of gorriecoe / silverstripe-embed

1. Go to this page and download the library: Download gorriecoe/silverstripe-embed library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gorriecoe / silverstripe-embed example snippets


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  string
     */
    private static $embed_tab = 'Main';
}