public function __construct() { if (defined('PHPFOX_NO_APPS')) { return; } $base = PHPFOX_DIR_SITE . 'Apps/'; foreach (scandir($base) as $app) { if ($app == '.' || $app == '..') { continue; } $path = $base . $app . '/'; if (!file_exists($path . 'app.lock')) { continue; } $data = json_decode(file_get_contents($path . 'app.json')); $data->path = $path; if (isset($data->routes)) { self::$routes = array_merge(self::$routes, (array) $data->routes); } $this->_apps[$data->id] = $data; \Core\Route\Controller::$active = $data->path; \Core\Route\Controller::$activeId = $data->id; $vendor = $data->path . 'vendor/autoload.php'; if (file_exists($vendor)) { require_once $vendor; } if (file_exists($data->path . 'start.php')) { require_once $data->path . 'start.php'; } } // d($this->_apps); exit; }
public function __construct() { if (defined('PHPFOX_NO_APPS')) { return; } $base = PHPFOX_DIR_SITE . 'Apps/'; if (!is_dir($base)) { return; } foreach (scandir($base) as $app) { if ($app == '.' || $app == '..') { continue; } $path = $base . $app . '/'; if (!file_exists($path . 'app.lock')) { continue; } $data = json_decode(file_get_contents($path . 'app.json')); $data->path = $path; if (isset($data->routes)) { self::$routes = array_merge(self::$routes, (array) $data->routes); } $this->_apps[$data->id] = $data; \Core\Route\Controller::$active = $data->path; \Core\Route\Controller::$activeId = $data->id; $vendor = $data->path . 'vendor/autoload.php'; if (file_exists($vendor)) { require_once $vendor; } if (file_exists($data->path . 'start.php')) { $callback = (require_once $data->path . 'start.php'); if (is_callable($callback)) { $View = new \Core\View(); $View->loader()->addPath($data->path . 'views/', $data->id); call_user_func($callback, $this->get($data->id), $View->env()); } } } // d($this->_apps); exit; }