common\Uri::getUrl PHP Method

getUrl() public static method

Prepares a string so that it can be used in urls.
public static getUrl ( string $value ) : string
$value string The value that should be urlised.
return string The urlised string.
    public static function getUrl($value)
    {
        // convert cyrlic, greek or other caracters to ASCII characters
        $value = Transliterator::transliterate($value);
        // make a clean url out of it
        return Transliterator::urlize($value);
    }

Usage Example

示例#1
0
 /**
  * Generate an url, using the predefined callback.
  *
  * @param string $url The base-url to start from.
  * @param string $class The Fully Qualified Class Name or service name
  * @param string $method The method that needs to be called
  * @param array $parameters The parameters for the callback
  *
  * @throws Exception When the function does not exist
  *
  * @return string
  */
 public function generateURL($url, $class, $method, array $parameters = [])
 {
     // check if the class is a service
     if (Model::getContainer()->has($class)) {
         $class = Model::getContainer()->get($class);
     }
     // validate (check if the function exists)
     if (!is_callable([$class, $method])) {
         throw new Exception('The callback-method doesn\'t exist.');
     }
     // when using ->getValue() in SpoonFormText fields the function is using htmlentities(),
     // so we must decode it again first!
     $url = SpoonFilter::htmlentitiesDecode($url);
     $actualParameters = [];
     // build parameters for use in the callback
     $actualParameters[] = Uri::getUrl($url);
     // add parameters set by user
     if (!empty($parameters)) {
         foreach ($parameters as $parameter) {
             $actualParameters[] = $parameter;
         }
     }
     // get the real url
     return call_user_func_array([$class, $method], $actualParameters);
 }
All Usage Examples Of common\Uri::getUrl