Heya,
So here's the code that is further down on EventSession.php.
----- CODE STARTS HERE -----
public function onBeforeWrite(){
// If there is no URLSegment set, generate one from Title
if((!$this->URLSegment || $this->URLSegment == 'new-event') && $this->Title != 'New Event'){
$Event = Event::get()->byId($this->EventID);
$this->URLSegment = $this->generateURLSegment($Event->Title);
} else if($this->isChanged('URLSegment')) {
// Make sure the URLSegment is valid for use in a URL
$segment = preg_replace('/[^A-Za-z0-9]+/','-',$this->URLSegment);
$segment = preg_replace('/-+/','-',$segment);
// If after sanitising there is no URLSegment, give it a reasonable default
if(!$segment) {
$segment = "event-$this->ID";
}
$this->URLSegment = $segment;
}
// Ensure that this object has a non-conflicting URLSegment value.
$count = 2;
while($this->LookForExistingURLSegment($this->URLSegment)) {
$this->URLSegment = preg_replace('/-[0-9]+$/', null, $this->URLSegment) . '-' . $count;
$count++;
}
parent::onBeforeWrite();
}
----- CODE ENDS HERE -----
How would I go about with doing a "task"? I've never had experience with utlising them but aware of them like the available /dev/tasks :)
Cheers!