Hello,
I have situation where Im importing some data from XML in my database... Now I have to make slugs also for few tables. So I have added slug colmun in few tables and now I have to import slugs also when importing data from XML. Basicly Im making slugs from titles and names .. so I just use this metod to transfrom names and titles in slugs :
public static function cleanString($str) {
setlocale(LC_ALL, 'en_US.UTF8');
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = preg_replace("/[^a-zA-Z0-9\/_| -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_| -]+/", "-", $clean);
return $clean;
}
And when im using this method in my Models like this:
public function setSlug($slug)
{
$this->slug = StringUtili::cleanString($slug);
}
Im getting this error:
PHP Fatal error: Class 'Commons\StringUtility' not found in /var/www/myproject/app/Models/Cars.php on line 221
I have "use Commons\StringUtility" at top of my model so thats is not the problem. Also this method works on every other place in my code ..Controlers, Transformer. Actualy even in my Models work but when I use this method for clean string in getters like this:
public function getSlug()
{
return StringUtili::cleanString($this->slug);
}