mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Minor refactoring
This commit is contained in:
@@ -21,18 +21,18 @@ class Bundle
|
|||||||
/**
|
/**
|
||||||
* Returns path of given bundle to view / template with given extension
|
* Returns path of given bundle to view / template with given extension
|
||||||
*
|
*
|
||||||
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template"
|
* @param string $viewPath Path of the view / template, e.g. "MyDirectory/my-template". Extension is not required.
|
||||||
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
* @param string $bundleName Full name of the bundle, e.g. "MyExtraBundle"
|
||||||
* @param string $extension (optional) Extension of the view / template (default: "html.twig")
|
* @param string $extension (optional) Extension of the view / template (default: "html.twig")
|
||||||
* @throws IncorrectBundleNameException
|
* @throws IncorrectBundleNameException
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
public static function getBundleViewPath($viewPath, $bundleName, $extension = 'html.twig')
|
public static function getBundleViewPath(
|
||||||
{
|
string $viewPath,
|
||||||
/*
|
string $bundleName,
|
||||||
* Unknown path, extension of the view / template or name of the bundle?
|
string $extension = 'html.twig'
|
||||||
* Nothing to do
|
): ?string {
|
||||||
*/
|
// Nothing to do, because at least one unknown argument provided
|
||||||
if (empty($viewPath) || empty($bundleName) || empty($extension)) {
|
if (empty($viewPath) || empty($bundleName) || empty($extension)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -48,10 +48,10 @@ class Bundle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare short name of bundle and path of view / template with "/" (instead of ":")
|
// Prepare short name of bundle and path of view / template with "/" (instead of ":")
|
||||||
$shortBundleName = static::getShortBundleName($bundleName);
|
$shortName = static::getShortBundleName($bundleName);
|
||||||
$viewPath = str_replace(':', '/', $viewPath);
|
$path = str_replace(':', '/', $viewPath);
|
||||||
|
|
||||||
return sprintf('@%s/%s', $shortBundleName, $viewPath);
|
return sprintf('@%s/%s', $shortName, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user