Source of file YouTubeVideoCode.php
Size: 1,271 Bytes - Last Modified: 2021-12-23T10:47:45+00:00
/var/www/docs.ssmods.com/process/src/src/Model/Fieldtypes/YouTubeVideoCode.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | <?php namespace Sunnysideup\YouTubeDatabaseField\Model\Fieldtypes; use EdgarIndustries\YouTubeField\YouTubeField; use SilverStripe\Forms\NullableField; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\ORM\FieldType\DBVarchar; class YouTubeVideoCode extends DBVarchar { private static $casting = [ 'Embed' => 'HTMLText', ]; /** * Obfuscate all matching youtubes. */ public function Embed(): DBHTMLText { return $this->Embed(); } /** * Obfuscate all matching youtubes. */ public function getEmbed(): DBHTMLText { $html = $this->renderWith(self::class . 'Embed'); /** @var DBHTMLText $var */ $var = DBHTMLText::create_field('HTMLText', $html); $var->RAW(); return $var; } /** * @see DBField::scaffoldFormField() * * @param string $title (optional) * @param array $params (optional) * * @return NullableField|YouTubeField */ public function scaffoldFormField($title = null, $params = null) { if (! $this->nullifyEmpty) { return NullableField::create(YouTubeField::create($this->name, $title)); } return YoutubeField::create($this->name, $title); } } |