src/Sulu/Component/PHPCR/PathCleanup.php
public function cleanup($dirty, $languageCode = null)
    {
        $replacers = $this->replacers['default'];

        if (null !== $languageCode) {
            $replacers = array_merge(
                $replacers,
                (isset($this->replacers[$languageCode]) ? $this->replacers[$languageCode] : [])
            );
        }

        if (count($replacers) > 0) {
            foreach ($replacers as $key => $value) {
                $dirty = str_replace($key, $value, $dirty);
            }
        }

        $clean = strtolower($dirty);

        // Inspired by ZOOLU
        // delete problematic characters
        $clean = str_replace('%2F', '/', urlencode(preg_replace('/([^A-za-z0-9 -_\/])/', '', $clean)));

        // replace multiple dash with one
        $clean = preg_replace('/([-]+)/', '-', $clean);

        // remove dash after slash
        $clean = preg_replace('/\/[-]+/', '/', $clean);

        // delete dash at the beginning or end
        $clean = preg_replace('/^([-])/', '', $clean);
        $clean = preg_replace('/([-])$/', '', $clean);

        // remove double slashes
        $clean = str_replace('//', '/', $clean);

        return $clean;
    }
public function cleanup($dirty, $languageCode = null)
    {
        $replacers = $this->replacers['default'];

        if (null !== $languageCode) {
            $replacers = array_merge(
                $replacers,
                (isset($this->replacers[$languageCode]) ? $this->replacers[$languageCode] : [])
            );
        }

        if (count($replacers) > 0) {
            foreach ($replacers as $key => $value) {
                $dirty = str_replace($key, $value, $dirty);
            }
        }

        $clean = strtolower($dirty);

        // Inspired by ZOOLU
        // delete problematic characters
        $clean = str_replace('%2F', '/', urlencode(preg_replace('/([^A-za-z0-9 -_\/])/', '', $clean)));

        // replace multiple dash with one
        $clean = preg_replace('/([-]+)/', '-', $clean);

        // remove dash after slash
        $clean = preg_replace('/\/[-]+/', '/', $clean);

        // delete dash at the beginning or end
        $clean = preg_replace('/^([-])/', '', $clean);
        $clean = preg_replace('/([-])$/', '', $clean);

        // remove double slashes
        $clean = str_replace('//', '/', $clean);

        return $clean;
    }
public function cleanup ( $ dirty , $ languageCode = null ) { $ replacers = $ this -> replacers [ 'default' ] ; if ( null !== $ languageCode ) { $ replacers = array_merge ( $ replacers , ( isset ( $ this -> replacers [ $ languageCode ] ) ? $ this -> replacers [ $ languageCode ] : [ ] ) ) ; } if ( count ( $ replacers ) > 0 ) { foreach ( $ replacers as $ key => $ value ) { $ dirty = str_replace ( $ key , $ value , $ dirty ) ; } } $ clean = strtolower ( $ dirty ) ; // Inspired by ZOOLU // delete problematic characters $ clean = str_replace ( '%2F' , '/' , urlencode ( preg_replace ( '/([^A-za-z0-9 -_\/])/' , '' , $ clean ) ) ) ; // replace multiple dash with one $ clean = preg_replace ( '/([-]+)/' , '-' , $ clean ) ; // remove dash after slash $ clean = preg_replace ( '/\/[-]+/' , '/' , $ clean ) ; // delete dash at the beginning or end $ clean = preg_replace ( '/^([-])/' , '' , $ clean ) ; $ clean = preg_replace ( '/([-])$/' , '' , $ clean ) ; // remove double slashes $ clean = str_replace ( '//' , '/' , $ clean ) ; return $ clean ; }
returns a clean string.

@param string $dirty dirty string to cleanup
@param string $languageCode

@return string clean string
returns a clean string .