FOF30\Factory\Scaffolding\View\Builder::make PHP Method

make() public method

Make a new scaffolding document
public make ( string $requestedClass, string $viewName, string $viewType ) : boolean
$requestedClass string The requested class, with full qualifier ie Myapp\Site\Controller\Foobar
$viewName string The name of the view linked to this controller
$viewType string The type of the view linked to this controller
return boolean True on success, false otherwise
    public function make($requestedClass, $viewName, $viewType)
    {
        // Class already exists? Stop here
        if (class_exists($requestedClass)) {
            return true;
        }
        // I have to magically create the controller class
        $magic = new ViewFactory($this->container);
        $magic->setSection($this->getSection());
        $fofView = $magic->make($viewName, $viewType);
        /** @var ErectorInterface $erector */
        $erector = new ViewErector($this, $fofView, $viewName, $viewType);
        $erector->setSection($this->getSection());
        $erector->build();
        if (!class_exists($requestedClass)) {
            return false;
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
Arquivo: View.php Projeto: akeeba/fof
 public function execute()
 {
     // Backend or frontend?
     $section = $this->input->get('frontend', false) ? 'site' : 'admin';
     $view = $this->getViewName($this->input);
     // Let's force the use of the Magic Factory
     $container = Container::getInstance($this->component, array('factoryClass' => 'FOF30\\Factory\\MagicFactory'));
     $container->factory->setSaveScaffolding(true);
     $view = $container->inflector->pluralize($view);
     $classname = $container->getNamespacePrefix($section) . 'View\\' . ucfirst($view) . '\\Html';
     $scaffolding = new ViewBuilder($container);
     $scaffolding->setSection($section);
     ini_set('error_reporting', E_ALL);
     ini_set('display_errors', 1);
     if (!$scaffolding->make($classname, $view, 'html')) {
         throw new \RuntimeException("An error occurred while creating the Model class");
     }
 }
All Usage Examples Of FOF30\Factory\Scaffolding\View\Builder::make