Helper to extract the preferred locale value from MultiLocaleString
https://docs.microsoft.com/en-us/linkedin/shared/references/v2/object-types#multilocalestring.

@param $path

@return mixed
11381
protected function getPreferredLocaleValue($path)
    {
        $multiLocaleString = $this->getValueForPath($path);

        $locale = '';
        if (isset($multiLocaleString['preferredLocale'])) {
            $locale = $multiLocaleString['preferredLocale']['language'];
            if (!empty($multiLocaleString['preferredLocale']['country'])) {
                $locale .= '_'.$multiLocaleString['preferredLocale']['country'];
            }
        }

        if (isset($multiLocaleString['localized'][$locale])) {
            return $multiLocaleString['localized'][$locale];
        }

        $fallbackLocale = array_keys($multiLocaleString['localized'])[0];

        return $multiLocaleString['localized'][$fallbackLocale];
    }
52079
private function detectFromPath($path)
    {
        if (!$this->usePath) {
            return null;
        }

        $first = \explode('/', \ltrim($path, '/'), 2)[0];
        $first = \strtolower($first);

        if (!empty($first) && \in_array($first, $this->languages, true)) {
            return $first;
        }

        return null;
    }
1154902
protected function _relativizePath($path)
    {
        $plugins = Plugin::loaded();
        $index = array_search('AssetCompress', $plugins);
        unset($plugins[$index]);

        foreach ($plugins as $plugin) {
            $pluginPath = Plugin::path($plugin) . 'webroot';
            if (strpos($path, $pluginPath) === 0) {
                return str_replace($pluginPath, '/' . Inflector::underscore($plugin), $path);
            }
        }
        $path = str_replace(WWW_ROOT, '/', $path);

        return str_replace(DS, '/', $path);
    }
546989
protected function parsePath($path)
    {
        $uriParams = array();
        $uriParamsCount = preg_match_all("/(:[^\/]*)/", $path, $uriParams);
        $translateParams = array();

        foreach ($uriParams[0] as $rawParam) {
            $param = str_replace(':', '', $rawParam);
            $this->addParameter($param, 'uri', true);

            $translateParams[$rawParam] = '{'.$param.'}';
        }

        $this->uri = strtr($path, $translateParams);
    }
595783
protected function getLocalUrl($path)
    {
        $prop = $this->property();
        if ($prop instanceof FileProperty) {
            if ($prop->publicAccess() === false) {
                $query = http_build_query([
                    'disk' => $prop->filesystem(),
                    'path' => $path,
                ]);
                return $this->adminUrl('filesystem/download')->withQuery($query);
            }
        }

        return $this->baseUrl($path);
    }
314915
public function find($path, array $locales, $translationDirectory = null)
    {
        $finder = new Finder();
        $translationDirectory = $translationDirectory ?? $this->defaultTranslationFolder;

        $exploreDir = $path . '/' . $translationDirectory;

        if (is_dir($exploreDir)) {
            $finder->files()
                ->name(sprintf('/(.*(%s)\.(%s))/', implode('|', $locales), implode('|', $this->fileFormats)))
                ->in($exploreDir);

            return $finder;
        }

        throw new TranslationsNotFoundException('Directory `' . $exploreDir . '` does not exist, translations could not be found.');
    }
275781
public function getUrl($path): string
    {
        \assert('is_string($path)');
        if (strpos($path, ':') === 0) {
            $key = substr($path, 0, strpos($path, '/') ?: \strlen($path));
            $path = $key === $path ? '' : (string)substr($path, \strlen($key));
        } else {
            $key = ':dist';
        }
        if (!isset($this->map[$key])) {
            throw new \InvalidArgumentException(sprintf('No path "%s" for subpackage "%s".', $path, $key));
        }
        return parent::getUrl(substr($key, 1) . $path);
    }
1160430
private function parsePath($path)
    {
        if (empty($path)) {
            $path = Map::DEFAULT_URL_DELIMITER;
        }

        // get the clean path
        return $this->urlParser->parse($path);
    }
268943
private function rooted($path)
	{
		if (substr($path, 0, strlen(PATH_ROOT)) == PATH_ROOT)
		{
			$path = 'ROOT' . substr($path, strlen(PATH_ROOT));
		}
		return $path;
	}
575289
public function getConfigValueFromPath($path)
    {
        /** @var Configuration $node */
        $node = $this->configuration;

        foreach (explode('/', $path) as $nodeName) {
            if (!is_object($node)) {
                return null;
            }

            $node = $node->{'get' . ucfirst($nodeName)}();
        }

        return $node;
    }
1311104
protected function getLocalUrl($path)
    {
        $config = $this->driver->getConfig();

        // If an explicit base URL has been set on the disk configuration then we will use
        // it as the base URL instead of the default path. This allows the developer to
        // have full control over the base path for this filesystem's generated URLs.
        if ($config->has('url')) {
            return rtrim($config->get('url'), '/').'/'.ltrim($path, '/');
        }

        $path = '/storage/'.$path;

        // If the path contains "storage/public", it probably means the developer is using
        // the default disk to generate the path instead of the "public" disk like they
        // are really supposed to use. We will remove the public from this path here.
        if (Str::contains($path, '/storage/public/')) {
            return Str::replaceFirst('/public/', '/', $path);
        } else {
            return $path;
        }
    }
751515
protected function getLocalPath($path)
	{
		$path = $this->doc_root . '/' . $this->config['s3']['localThumbsPath'] . '/' . $path;
		return $this->cleanPath($path);
	}
560456
protected function getLocalFilesystemPath($path)
	{
		if(!isset(static::$pointer_tree[$path]))
			static::$pointer_tree[$path] = tmpfile();
		
		if($metadata = stream_get_meta_data(static::$pointer_tree[$path]))
			return $metadata["uri"];
		
		return null;
	}
46322
public function findTranslatedRouteByPath($path, $locale)
    {
        // check if this url is a translated url
        foreach ($this->translatedRoutes as $route) {
            if ($this->translate($route, $locale) == rawurldecode($path))
                return $route;
        }

        return false;
    }
828079
public function getConfigValue($path)
    {
        $chunks = explode('/', $path);

        if (!$chunks[0]) {
            array_shift($chunks);
        }

        return $this->scanTo($chunks, $this->data);
    }
1043881
protected function findText($path)
    {
        foreach ($this->localeSequence() as $locale) {
            $arrayKey = "$locale.$path";
            if (isset($this->data[$arrayKey])) {
                return $this->data[$arrayKey];
            }
        }
        return $path;
    }
474588
public function getSource($path)
    {
        try {
            // The "loaded_by_puli" tag makes it possible to recognize node
            // trees of templates loaded through this loader. In this way, we
            // can turn relative Puli paths into absolute ones in those
            // templates. The "loaded_by_puli" tag is removed early on by the
            // PuliDirTagger visitor and does not appear in the final
            // output.
            return '{% loaded_by_puli %}'.$this->getResource($path)->getBody();
        } catch (ResourceNotFoundException $e) {
            throw new Twig_Error_Loader($e->getMessage(), -1, null, $e);
        } catch (InvalidArgumentException $e) {
            throw new Twig_Error_Loader($e->getMessage(), -1, null, $e);
        }
    }