public make ( string $name = null, string $viewType = 'html', array $config = [] ) : FOF30\View\DataView\DataViewInterface | ||
$name | string | The name of the class we're making |
$viewType | string | The view type, default html, possible values html, form, raw, json, csv |
$config | array | The config parameters which override the fof.xml information |
리턴 | FOF30\View\DataView\DataViewInterface | A new TreeModel or DataModel object |
public function make($name = null, $viewType = 'html', array $config = array())
{
if (empty($name)) {
throw new ViewNotFound("[name : type] = [{$name} : {$viewType}]");
}
$appConfig = $this->container->appConfig;
$name = ucfirst($name);
$defaultConfig = array('name' => $name, 'template_path' => $appConfig->get("views.{$name}.config.template_path"), 'layout' => $appConfig->get("views.{$name}.config.layout"), 'viewEngineMap' => $appConfig->get("views.{$name}.config.viewEngineMap"));
$config = array_merge($defaultConfig, $config);
$className = $this->container->getNamespacePrefix($this->getSection()) . 'View\\DataView\\Default' . ucfirst($viewType);
if (!class_exists($className, true)) {
$className = '\\FOF30\\View\\DataView\\' . ucfirst($viewType);
}
if (!class_exists($className, true)) {
$className = $this->container->getNamespacePrefix($this->getSection()) . 'View\\DataView\\DefaultHtml';
}
if (!class_exists($className)) {
$className = '\\FOF30\\View\\DataView\\Html';
}
$view = new $className($this->container, $config);
return $view;
}
/** * Create a new View object * * @param string $viewName The name of the view we're getting a View object for. * @param string $viewType The type of the View object. By default it's "html". * @param array $config Optional MVC configuration values for the View object. * * @return View */ public function view($viewName, $viewType = 'html', array $config = array()) { try { return parent::view($viewName, $viewType, $config); } catch (ViewNotFound $e) { $magic = new Magic\ViewFactory($this->container); return $magic->make($viewName, $viewType, $config); } }