/**
  * @see sfValidatorBase
  */
 protected function doClean($value)
 {
     $clean = (string) parent::doClean($value);
     $clean = aTools::strtolower($clean);
     $slugified = aTools::slugify($clean, $this->getOption('allow_slashes'));
     if ($this->getOption('strict')) {
         if ($slugified !== $clean) {
             throw new sfValidatorError($this, 'invalid', array('value' => $value));
         }
     } else {
         $clean = $slugified;
     }
     return $clean;
 }
 public static function slugify($path, $allowSlashes = false)
 {
     // This is the inverse of the method above
     if (function_exists('mb_strtolower')) {
         // UTF-8 capable replacement for \W. Works fine for English and also for Greek, etc.
         $alnum = '\\p{L}\\p{N}_';
         $modifier = 'u';
     } else {
         $alnum = '\\w';
         $modifier = '';
     }
     if ($allowSlashes) {
         $alnum .= '\\/';
     }
     $regexp = "/[^{$alnum}\\-]+/{$modifier}";
     $path = aTools::strtolower(preg_replace("/[^{$alnum}\\-]+/{$modifier}", '-', $path));
     if ($allowSlashes) {
         // No multiple consecutive /
         $path = preg_replace("/\\/+/{$modifier}", "/", $path);
         // No trailing /
         $path = preg_replace("/\\/\$/{$modifier}", '', $path);
     }
     // No consecutive dashes
     $path = preg_replace("/-+/{$modifier}", '-', $path);
     // Leading and trailing dashes are silly. This has the effect of trim()
     // among other sensible things
     $path = preg_replace("/^-*(.*?)-*\$/{$modifier}", '$1', $path);
     return $path;
 }