/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Routing
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Routing/Asset.php (13309B)
1) {
$plugin = implode('/', [$plugin, Inflector::camelize($segments[1])]);
unset($segments[1]);
}
if (Plugin::isLoaded($plugin)) {
unset($segments[0]);
$pluginPath = Plugin::path($plugin)
. 'webroot'
. DIRECTORY_SEPARATOR
. implode(DIRECTORY_SEPARATOR, $segments);
if (file_exists($pluginPath)) {
return $path . '?' . filemtime($pluginPath);
}
}
}
return $path;
}
/**
* Checks if a file exists when theme is used, if no file is found default location is returned.
*
* ### Options:
*
* - `theme` Optional theme name
*
* @param string $file The file to create a webroot path to.
* @param array $options Options array.
* @return string Web accessible path to file.
*/
public static function webroot(string $file, array $options = []): string
{
$options += ['theme' => null];
$requestWebroot = static::requestWebroot();
$asset = explode('?', $file);
$asset[1] = isset($asset[1]) ? '?' . $asset[1] : '';
$webPath = $requestWebroot . $asset[0];
$file = $asset[0];
$themeName = $options['theme'];
if ($themeName) {
$file = trim($file, '/');
$theme = static::inflectString($themeName) . '/';
if (DIRECTORY_SEPARATOR === '\\') {
$file = str_replace('/', '\\', $file);
}
if (file_exists(Configure::read('App.wwwRoot') . $theme . $file)) {
$webPath = $requestWebroot . $theme . $asset[0];
} else {
$themePath = Plugin::path($themeName);
$path = $themePath . 'webroot/' . $file;
if (file_exists($path)) {
$webPath = $requestWebroot . $theme . $asset[0];
}
}
}
if (strpos($webPath, '//') !== false) {
return str_replace('//', '/', $webPath . $asset[1]);
}
return $webPath . $asset[1];
}
/**
* Inflect the theme/plugin name to type set using `Asset::setInflectionType()`.
*
* @param string $string String inflected.
* @return string Inflected name of the theme
*/
protected static function inflectString(string $string): string
{
return Inflector::{static::$inflectionType}($string);
}
/**
* Get webroot from request.
*
* @return string
*/
protected static function requestWebroot(): string
{
$request = Router::getRequest();
if ($request === null) {
return '/';
}
return $request->getAttribute('webroot');
}
/**
* Splits a dot syntax plugin name into its plugin and filename.
* If $name does not have a dot, then index 0 will be null.
* It checks if the plugin is loaded, else filename will stay unchanged for filenames containing dot.
*
* @param string $name The name you want to plugin split.
* @return array Array with 2 indexes. 0 => plugin name, 1 => filename.
* @psalm-return array{string|null, string}
*/
protected static function pluginSplit(string $name): array
{
$plugin = null;
[$first, $second] = pluginSplit($name);
if ($first && Plugin::isLoaded($first)) {
$name = $second;
$plugin = $first;
}
return [$plugin, $name];
}
}