Source of file YouTubeVideoManager.php
Size: 1,868 Bytes - Last Modified: 2021-12-23T10:05:44+00:00
/var/www/docs.ssmods.com/process/src/code/extensions/YouTubeVideoManager.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | <?php /** * Class YouTubeVideoManager * * @method Videos[]|ManyManyList $Videos */ class YouTubeVideoManager extends DataExtension { /** * @var array */ private static $many_many = [ 'Videos' => 'SilverStripeYouTubeVideo', ]; /** * @var array */ private static $many_many_extraFields = [ 'Videos' => [ 'Sort' => 'Int', ], ]; /** * @var array */ private static $summary_fields = [ 'Videos.Count' => 'Videos in playlist', ]; /** * @var */ private $videos; /** * Update cms fields for the owner object to include video management fields * * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { if (!$this->owner->ID) { $fields->removeByName('Videos'); } else { $config = GridFieldConfig_RelationEditor::create(); $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); $config->addComponent(new GridFieldAddExistingSearchButton()); $config->addComponent(new GridFieldOrderableRows()); $grid = GridField::create('Videos', 'Videos', $this->owner->Videos()->sort('Sort'), $config); if ($fields->dataFieldByName('Videos')) { $fields->replaceField('Videos', $grid); } else { $fields->addFieldToTab('Root.Videos', $grid); } } } /** * @return $this */ public function setVideosList() { $this->videos = $this->owner->Videos()->sort('Sort'); return $this; } /** * @return mixed */ public function getVideosList() { if (!$this->videos) { $this->setVideosList(); } return $this->videos; } } |