Source of file Flow.php
Size: 1,764 Bytes - Last Modified: 2021-12-24T06:40:50+00:00
/var/www/docs.ssmods.com/process/src/src/Model/Flow.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 | <?php namespace CodeCraft\Pathfinder\Model; use SilverStripe\Forms\FieldList; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\HasManyList; /** * A flow to give structure to question sequencing in a Pathfinder * * @property string Title * @method Pathfinder|null Pathfinder() * @method HasManyList|Question[] Questions() */ class Flow extends DataObject { /** * @var string */ private static $table_name = 'PathfinderFlow'; /** * @var array */ private static $db = [ 'Title' => 'Varchar(255)', ]; /** * @var array */ private static $has_one = [ 'Pathfinder' => Pathfinder::class, ]; /** * @var array */ private static $has_many = [ 'Questions' => Question::class, ]; /** * {@inheritDoc} */ public function getCMSFields() { // Manipulate fields ahead of extension manipulations (such as Fluent) $this->beforeUpdateCMSFields(function (FieldList $fields) { $fields->removeByName([ 'PathfinderID', 'Questions', // Questions can be accessed from the Pathfinder CMS tabs ]); // Title field $titleField = $fields->dataFieldByName('Title'); if ($titleField) { $titleField->setDescription('Only shown in the CMS'); } }); return parent::getCMSFields(); } /** * {@inheritDoc} */ public function populateDefaults() { // Come up with a helpful title if ($this->Pathfinder()) { $this->Title = sprintf('Flow %s', $this->Pathfinder()->Flows()->count() + 1); } return parent::populateDefaults(); } } |