PHP code example of restruct / silverstripe-oembeddable

1. Go to this page and download the library: Download restruct/silverstripe-oembeddable 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/ */

    

restruct / silverstripe-oembeddable example snippets


use Restruct\Silverstripe\OEmbedable\OEmbeddable;
use Restruct\Silverstripe\OEmbedable\OEmbeddableField;

class Page extends SiteTree
{
	private static $has_one = [
		'EmbedVideo' => OEmbeddable::class,
	];

	public function getCMSFields()
	{
		$fields = parent::getCMSFields();

		$fields->addFieldToTab(
		    'Root.Main',
		    OEmbeddableField::create(
		        'EmbedVideo',
		        'Video from oEmbed URL',
		        $this->EmbedVideo()
		    )
		);

		return $fields;
	}
}