Source of file Tag.php
Size: 2,058 Bytes - Last Modified: 2021-12-24T06:40:39+00:00
/var/www/docs.ssmods.com/process/src/src/model/Tag.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 | <?php namespace Cita\eCommerce\Model; use SilverStripe\ORM\DataObject; use SilverStripe\Assets\Image; use Leochenftw\Extension\SlugifyExtension; use Leochenftw\Util; /** * Description * * @package silverstripe * @subpackage mysite */ class Tag extends DataObject { /** * Defines the database table name * @var string */ private static $table_name = 'Cita_eCommerce_Tag'; /** * Database fields * @var array */ private static $db = [ 'Title' => 'Varchar(128)', 'Content' => 'HTMLText' ]; /** * Defines extension names and parameters to be applied * to this object upon construction. * @var array */ private static $extensions = [ SlugifyExtension::class ]; /** * Belongs_many_many relationship * @var array */ private static $belongs_many_many = [ 'Products' => Product::class, 'Variants' => Variant::class ]; /** * Defines summary fields commonly used in table columns * as a quick overview of the data for this dataobject * @var array */ private static $summary_fields = [ 'Title' => 'Title', 'Content' => 'Content', 'Products.Count' => 'Number of Products' ]; /** * CMS Fields * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); return $fields; } public function getMiniData() { return [ 'title' => $this->Title, 'slug' => $this->Slug, 'url' => $this->Link() ]; } public function getData() { return array_merge($this->getMiniData(), [ 'content' => Util::preprocess_content($this->Content) ]); } private function Link() { if ($catalog = Catalog::get()->first()) { return $catalog->Link() . '?tag=' . $this->Slug; } return '?tag=' . $this->Slug; } } |