elements = $this->instanceElements(); } /** * Instantiate all the elements that will build the dashboard * * @return array */ public function instanceElements():array { global $config; $dir = $config['homedir'].'/include/lib/TacticalView/elements/'; $handle = opendir($dir); if ($handle === false) { return []; } $ignores = [ '.', '..', ]; $elements = []; while (false !== ($file = readdir($handle))) { try { if (in_array($file, $ignores) === true) { continue; } $filepath = realpath($dir.'/'.$file); if (is_readable($filepath) === false || is_dir($filepath) === true || preg_match('/.*\.php$/', $filepath) === false ) { continue; } $className = preg_replace('/.php/', '', $file); include_once $filepath; if (class_exists($className) === true) { $instance = new $className(); $elements[$className] = $instance; } } catch (Exception $e) { } } return $elements; } /** * Render funcion for print the html. * * @return void */ public function render():void { View::render( 'tacticalView/view', $this->elements ); } }