Minor refactoring

This commit is contained in:
Meritoo
2019-06-20 19:25:34 +02:00
parent 5678b5b22a
commit 1ac1a221ec

View File

@@ -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);
} }
/** /**