Source of file CO_Gallery_Image.php
Size: 0,804 Bytes - Last Modified: 2021-12-23T10:19:55+00:00
/var/www/docs.ssmods.com/process/src/src/CO_Gallery_Image.php
123456789101112131415161718192021222324252627282930313233343536373839 | <?php namespace Schrattenholz\ContentObject; use Silverstripe\ORM\DataObject; use Silverstripe\Assets\Image; class CO_Gallery_Image extends DataObject{ private static $table_name="CO_Gallery_Image"; private static $db=[ 'Title'=>'Varchar(255)', 'SortID'=>'Int', 'Adult'=>'Boolean' ]; private static $has_one=[ "Image"=>Image::class, "Gallery"=>CO_Gallery::class ]; public function onBeforeWrite(){ parent::onBeforeWrite(); if($this->Title==""){ $this->Title=$this->Image()->Title; } } public function onAfterWrite(){ parent::onAfterWrite(); if ($this->Image()->exists() && !$this->Image()->isPublished()){ $this->Image()->doPublish(); } } public function getThumbnail(){ return $this->Image()->CMSThumbnail(); } private static $owner=[ 'Image' ]; } |