FOF30\Factory\Scaffolding\Model\Builder::make PHP Méthode

make() public méthode

Make a new scaffolding document
public make ( string $requestedClass, string $viewName ) : 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
Résultat boolean True on success, false otherwise
    public function make($requestedClass, $viewName)
    {
        // Class already exists? Stop here
        if (class_exists($requestedClass)) {
            return true;
        }
        // I have to magically create the model class
        $magic = new ModelFactory($this->container);
        $magic->setSection($this->getSection());
        $fofModel = $magic->make($viewName);
        /** @var ErectorInterface $erector */
        $erector = new ModelErector($this, $fofModel, $viewName);
        $erector->setSection($this->getSection());
        $erector->build();
        if (!class_exists($requestedClass)) {
            return false;
        }
        return true;
    }

Usage Example

Exemple #1
0
 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) . 'Model\\' . ucfirst($view);
     $scaffolding = new ModelBuilder($container);
     $scaffolding->setSection($section);
     if (!$scaffolding->make($classname, $view)) {
         throw new \RuntimeException("An error occurred while creating the Model class");
     }
 }
All Usage Examples Of FOF30\Factory\Scaffolding\Model\Builder::make