Source of file CodeTabRequestParameter.php
Size: 1,808 Bytes - Last Modified: 2021-12-23T10:57:24+00:00
/var/www/docs.ssmods.com/process/src/src/Models/CodeTabRequestParameter.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | <?php namespace Vulcan\UserDocs\Models; use SilverStripe\ORM\DataObject; use SilverStripe\View\Parsers\ShortcodeParser; /** * Class CodeTabRequestParameter * @package Vulcan\UserDocs\Models * * @property string Parameter * @property string Explanation * * @property int TabID * * @method CodeTab Tab */ class CodeTabRequestParameter extends DataObject { private static $table_name = 'CodeTabRequestParameter'; private static $singular_name = 'Request Parameter'; private static $plural_name = 'Request Parameters'; private static $db = [ 'Parameter' => 'Varchar(50)', 'Explanation' => 'HTMLText', 'Sort' => 'Int' ]; private static $has_one = [ 'Tab' => CodeTab::class ]; private static $summary_fields = [ 'Parameter' => 'Parameter', 'Explanation.FirstParagraph' => 'Explanation' ]; public function validate() { $result = parent::validate(); if (!$this->Parameter) { $result->addFieldError('Parameter', 'You must provide the name of this parameter'); } if (!$this->Explanation) { $result->addFieldError('Explanation', 'You must describe the purpose of this parameter'); } return $result; } public function onBeforeWrite() { parent::onBeforeWrite(); $this->Parameter = trim($this->Parameter); } public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName(['Sort']); return $fields; } public function getTitle() { return $this->Parameter; } public function getParsedExplanation() { return ShortcodeParser::get_active()->parse($this->Explanation); } } |