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;
}
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"); } }