Core/Framework/Amvc/App/AbstractApp.php
private function MVCFactory(string $name, string $type, $arguments = null)
    {
        // Here we make sure that CSS and JS will correctly and only once be initiated!
        if (!in_array($this->name, self::$init_done)) {

            // Init css and js only on non ajax requests
            if (!$this->core->router->isAjax()) {
                $this->initCss();
                $this->initJs();
            }

            // Store our apps name to be initiated
            self::$init_done[] = $this->name;
        }

        $string = new CamelCase($name);
        $name = $string->camelize($name);

        // Create classname of component to create
        $class = $this->getNamespace() . '\\' . $type . '\\' . $name . $type;

        // By default each MVC component constructor needs at least a name and this app object as argument
        $args = [
            $name,
            $this
        ];

        // Add additional arguments
        if (isset($arguments)) {
            if (!is_array($arguments)) {
                $arguments = (array) $arguments;
            }

            foreach ($arguments as $arg) {
                $args[] = $arg;
            }
        }

        $classfile = new Classfile($class);

        if (!$classfile->exists()) {
            return false;
        }

        $object = $this->core->di->instance($class, $args);

        switch ($type) {
            case 'Controller':
                $object->model = $this->getModel($name);
                break;
        }

        return $object;
    }
private function MVCFactory(string $name, string $type, $arguments = null)
    {
        // Here we make sure that CSS and JS will correctly and only once be initiated!
        if (!in_array($this->name, self::$init_done)) {

            // Init css and js only on non ajax requests
            if (!$this->core->router->isAjax()) {
                $this->initCss();
                $this->initJs();
            }

            // Store our apps name to be initiated
            self::$init_done[] = $this->name;
        }

        $string = new CamelCase($name);
        $name = $string->camelize($name);

        // Create classname of component to create
        $class = $this->getNamespace() . '\\' . $type . '\\' . $name . $type;

        // By default each MVC component constructor needs at least a name and this app object as argument
        $args = [
            $name,
            $this
        ];

        // Add additional arguments
        if (isset($arguments)) {
            if (!is_array($arguments)) {
                $arguments = (array) $arguments;
            }

            foreach ($arguments as $arg) {
                $args[] = $arg;
            }
        }

        $classfile = new Classfile($class);

        if (!$classfile->exists()) {
            return false;
        }

        $object = $this->core->di->instance($class, $args);

        switch ($type) {
            case 'Controller':
                $object->model = $this->getModel($name);
                break;
        }

        return $object;
    }
private function MVCFactory ( string $ name , string $ type , $ arguments = null ) { // Here we make sure that CSS and JS will correctly and only once be initiated! if ( ! in_array ( $ this -> name , self :: $ init_done ) ) { // Init css and js only on non ajax requests if ( ! $ this -> core -> router -> isAjax ( ) ) { $ this -> initCss ( ) ; $ this -> initJs ( ) ; } // Store our apps name to be initiated self :: $ init_done [ ] = $ this -> name ; } $ string = new CamelCase ( $ name ) ; $ name = $ string -> camelize ( $ name ) ; // Create classname of component to create $ class = $ this -> getNamespace ( ) . '\\' . $ type . '\\' . $ name . $ type ; // By default each MVC component constructor needs at least a name and this app object as argument $ args = [ $ name , $ this ] ; // Add additional arguments if ( isset ( $ arguments ) ) { if ( ! is_array ( $ arguments ) ) { $ arguments = ( array ) $ arguments ; } foreach ( $ arguments as $ arg ) { $ args [ ] = $ arg ; } } $ classfile = new Classfile ( $ class ) ; if ( ! $ classfile -> exists ( ) ) { return false ; } $ object = $ this -> core -> di -> instance ( $ class , $ args ) ; switch ( $ type ) { case 'Controller' : $ object -> model = $ this -> getModel ( $ name ) ; break ; } return $ object ; }
Hidden method to factory mvc components like models, views or controllers

@param string $name
Components name
@param string $type
Components type
@param mixed $arguments
Optional arguments to be passed into the object to create

@return Model|View|Controller
Hidden method to factory mvc components like models views or controllers