Skip to content

Commit

Permalink
0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nourmasrieh committed Mar 16, 2021
1 parent 0923fbb commit 44b8593
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions src/DataObjects/JobCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,34 @@ public function getCMSFields()
* Event handler called before writing to the database.
*/
public function onBeforeWrite()
{
parent::onBeforeWrite();
$this->TagSortTitle = $this->Title;
$this->extend("updateOnBeforeWrite");
}
{
parent::onBeforeWrite();
if($this->URLSegment == "")
{
$this->URLSegment = $this->constructURLSegment();
}
$this->TagSortTitle = $this->Title;
$this->extend("updateOnBeforeWrite");
}

private function constructURLSegment()
{
return $this->cleanLink(strtolower(str_replace(" ", "-", $this->Title)));
}

private function cleanLink($string)
{
$string = str_replace("ä", "ae", $string);
$string = str_replace("ü", "ue", $string);
$string = str_replace("ö", "oe", $string);
$string = str_replace("Ä", "Ae", $string);
$string = str_replace("Ü", "Ue", $string);
$string = str_replace("Ö", "Oe", $string);
$string = str_replace("ß", "ss", $string);
$string = str_replace(["´", ",", ":", ";"], "", $string);
$string = str_replace(["´", ",", ":", ";"], "", $string);
$string = str_replace(["/", "(", ")"], "_", $string);
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);
return $string;
}
}

0 comments on commit 44b8593

Please sign in to comment.