public function view($viewName, $viewType = 'html', array $config = array())
{
$container = $this->container;
$prefix = $this->container->getNamespacePrefix($this->getSection());
$viewClass = $prefix . 'View\\' . ucfirst($viewName) . '\\' . ucfirst($viewType);
try {
return $this->createView($viewClass, $config);
} catch (ViewNotFound $e) {
}
$viewClass = $prefix . 'View\\' . ucfirst($container->inflector->singularize($viewName)) . '\\' . ucfirst($viewType);
try {
$view = $this->createView($viewClass, $config);
} catch (ViewNotFound $e) {
// Do I have to create and save the class file? If not, let's rethrow the exception. Note: I can only create HTML views
if (!$this->saveViewScaffolding) {
throw $e;
}
// By default view classes are plural
$viewClass = $prefix . 'View\\' . ucfirst($container->inflector->pluralize($viewName)) . '\\' . ucfirst($viewType);
$scaffolding = new ViewBuilder($this->container);
// Was the scaffolding successful? If so let's call ourself again, otherwise throw a not found exception
if ($scaffolding->make($viewClass, $viewName, $viewType)) {
$view = $this->view($viewName, $viewType, $config);
} else {
throw $e;
}
}
return $view;
}