Source of file AttributeType.php
Size: 1,575 Bytes - Last Modified: 2021-12-23T10:02:45+00:00
/var/www/docs.ssmods.com/process/src/code/model/attributes/core/AttributeType.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | <?php class AttributeType extends DataObject { private static $singular_name = "Attribute"; private static $plural_name = "Attributes"; private static $field_labels = array( 'URLSegment' => 'URL' ); private static $default_sort = '"Sort" ASC'; private static $db = array( "Name" => "Varchar(255)", "URLSegment" => "Varchar(255)", "Sort" => "Int" ); private static $indexes = array( "URLSegment" => true, ); private static $summary_fields = array( 'Name' => 'Name', 'ClassName' => 'Type' ); public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName("Sort"); return $fields; } /** * Generarte URLSegment for Object */ public function onBeforeWrite() { parent::onBeforeWrite(); if($this->Title && !$this->URLSegment) { $title = $this->Title; $filter = URLSegmentFilter::create(); $t = $filter->filter($title); // Fallback to generic page name if path is empty (= no valid, convertable characters) if (!$t || $t == '-' || $t == '-1') $t = "attribute-$this->ID"; // Hook for extensions $this->extend('updateURLSegment', $t, $title); $this->URLSegment = $t; $generate = new GeneratorURLSegment($this,$this->URLSegment); $generate->UniqueURLSegment(); $this->URLSegment = $generate->getURLSegment(); } } } |