Mcamara\LaravelLocalization\LaravelLocalization::getRouteNameFromAPath PHP Метод

getRouteNameFromAPath() публичный Метод

Returns the translation key for a given path
public getRouteNameFromAPath ( string $path ) : string | false
$path string Path to get the key translated
Результат string | false Key for translation, false if not exist
    public function getRouteNameFromAPath($path)
    {
        $attributes = $this->extractAttributes($path);
        $path = str_replace(url('/'), "", $path);
        if ($path[0] !== '/') {
            $path = '/' . $path;
        }
        $path = str_replace('/' . $this->currentLocale . '/', '', $path);
        $path = trim($path, "/");
        foreach ($this->translatedRoutes as $route) {
            if ($this->substituteAttributesInRoute($attributes, $this->translator->trans($route)) === $path) {
                return $route;
            }
        }
        return false;
    }

Usage Example

Пример #1
0
 /**
  * Returns the translation key for a given path
  *
  * @param string $path Path to get the key translated
  * @return string|false Key for translation, false if not exist
  * @static 
  */
 public static function getRouteNameFromAPath($path)
 {
     return \Mcamara\LaravelLocalization\LaravelLocalization::getRouteNameFromAPath($path);
 }