This if is not needed. 

if (is_file($template->directory.'/params.ini')) also checks if the directory exists.