/** * * * @param string $page The page we would like to load. * @param array $vars Optional. The values, the requested page requires. */ public static function prepare($page, array $vars = []) { $activeFolder = './Solutions/' . Projects::get()->active() . '/Views/'; self::loadHeader($activeFolder, $vars); self::loadContent($activeFolder, $page, $vars); self::$footer = file_get_contents($activeFolder . 'foot.master.php'); return self::$header . self::$content . self::$footer; }
/** * Instantiates a given class, with an optional array of parameters. * * @param string $className The name of the class to be instantiated. * @return Object */ private static function loadClass($className) { // We replace the "App" keyword in the namespace to the active // solution's name. $className = strtr($className, ['App' => Projects::get()->active()]); try { $reflector = new ReflectionClass($className); } catch (Exception $e) { echo $e->getMessage(); exit; } // We get the constructor. $constructor = $reflector->getConstructor(); // If the constructor is null, that means we have no dependencies // to resolve, and we can just instantiate the class. if (is_null($constructor)) { return $reflector->newInstance(); } // If there is constructor, we need to resolve all its // dependencies (if any). $args = self::resolveParameters($constructor->getParameters()); // Finally, instantiate the class. return $reflector->newInstanceArgs($args); }
/** * The constructor. */ public function __construct() { $this->name = Projects::get()->active(); $this->projectInfo = './Solutions/' . $this->name . '/project.info.php'; }
<?php $start = microtime(true); header('Content-Type: text/html; charset=utf-8'); include_once './System/Http/autoload.php'; use System\Config\Projects; include_once './Solutions/' . Projects::get()->active() . '/routes.php'; $end = microtime(true);