FOF30\Factory\BasicFactory::view PHP Метод

view() публичный Метод

Create a new View object
public view ( string $viewName, string $viewType = 'html', array $config = [] ) : View
$viewName string The name of the view we're getting a View object for.
$viewType string The type of the View object. By default it's "html".
$config array Optional MVC configuration values for the View object.
Результат FOF30\View\View
    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;
    }

Usage Example

Пример #1
0
 /**
  * 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);
     }
 }
All Usage Examples Of FOF30\Factory\BasicFactory::view