/**
  * Record a slug history from a given object in a standard way
  * 
  * @param DataObject $object
  * @param string $slug
  * @return int
  */
 public static function recordFromObject(DataObject $object, $slug)
 {
     if (!$object->ID) {
         return;
     }
     $history = new SlugHistory();
     $history->RecordID = $object->ID;
     $history->ObjectClass = $object->ClassName;
     $history->Slug = $slug;
     return $history->write();
 }
 /**
  * Get a record by its slug
  *
  * @param string $class
  * @param string $slug
  * @param int $excludeID Exclude this ID from searched slugs
  * @param bool $checkHistory
  * @return DataObject
  */
 public static function getBySlug($class, $slug, $excludeID = null, $checkHistory = true)
 {
     /* @var $datalist DataList */
     $datalist = $class::get()->filter('Slug', $slug);
     if ($excludeID) {
         $datalist = $datalist->exclude('ID', $excludeID);
     }
     $record = $datalist->first();
     if ((!$record || !$record->exists()) && $checkHistory) {
         $historyRecord = SlugHistory::getRecordByClass($class, $slug, $excludeID);
         if ($historyRecord) {
             $record = $historyRecord;
         }
     }
     return $record;
 }