/** * Ejecuta un componente incluyendo el archivo .php * Primero asegura que este exista, si no existe le pide a la API que lo traiga del servidor * @param string $name * @param array $valores */ public function component($name, $valores) { $nameComponent = $this->api->project . '_' . $name; if (!file_exists($this->api->pathComponent . $nameComponent . '.php')) { try { $code = $this->api->createComponent($name); $file = fopen($this->api->pathComponent . $nameComponent . '.php', 'x'); fwrite($file, $code); fclose($file); } catch (\Exception $e) { echo 'Error loading component: ' . $name; return; } } //Lo incluyo y se ejecuta solo include $this->api->pathComponent . $nameComponent . '.php'; }