if(!className.endsWith("Controller")) {
return null;
}
SymfonyBundleUtil symfonyBundleUtil = new SymfonyBundleUtil(PhpIndex.getInstance(method.getProject()));
SymfonyBundle symfonyBundle = symfonyBundleUtil.getContainingBundle(phpClass);
if(symfonyBundle == null) {
return null;
}
// find the bundle name of file
PhpClass BundleClass = symfonyBundle.getPhpClass();
if(null == BundleClass) {
return null;
}
// check if files is in <Bundle>/Controller/*
if(!phpClass.getNamespaceName().startsWith(BundleClass.getNamespaceName() + "Controller\\")) {
return null;
}
// strip the controller folder name
String templateFolderName = phpClass.getNamespaceName().substring(BundleClass.getNamespaceName().length() + 11);
// HomeBundle:default:indexes
// HomeBundle:default/Test:indexes
templateFolderName = templateFolderName.replace("\\", "/");
String shortcutName = symfonyBundle.getName() + ":" + templateFolderName + className.substring(0, className.lastIndexOf("Controller")) + ":" + methodName.substring(0, methodName.lastIndexOf("Action"));
// we should support types later on
// HomeBundle:default:indexes.html.twig
return shortcutName + ".html.twig";
}