From 64eba6f500709daffcb5c05686693879c1111b07 Mon Sep 17 00:00:00 2001 From: lgromero Date: Fri, 13 Sep 2024 13:42:11 +0200 Subject: [PATCH] refs #734 Renemas oggitservice --- .../Service/CurlRequestService.php | 60 ------------------- src/OgGitBundle/Service/OgGitService.php | 54 +++++++++++++++++ 2 files changed, 54 insertions(+), 60 deletions(-) delete mode 100644 src/OgGitBundle/Service/CurlRequestService.php create mode 100644 src/OgGitBundle/Service/OgGitService.php diff --git a/src/OgGitBundle/Service/CurlRequestService.php b/src/OgGitBundle/Service/CurlRequestService.php deleted file mode 100644 index 76e8faa..0000000 --- a/src/OgGitBundle/Service/CurlRequestService.php +++ /dev/null @@ -1,60 +0,0 @@ -ogGitUrl = $params->get('OGGIT_URL'); + $this->client = new Client(); + } + public function convertMaskToCIDR($mask) + { + $bits = 0; + $mask = explode(".", $mask); + + foreach ($mask as $octect) + $bits += strlen(str_replace("0", "", decbin($octect))); + + return $bits; + } + + public function isValidBranchName($name) { + $output = null; + $return_var = null; + exec("git check-ref-format --branch " . escapeshellarg($name), $output, $return_var); + # $output = exec("python3 ./gitlib.py " . escapeshellarg($name), $output, $return_var); + return $return_var === 0; + } + + public function makeRequest(string $method, string $endpoint, array $params = []) + { + $url = $this->ogGitUrl . $endpoint; + + try { + $response = $this->client->request($method, $url, $params); + $body = $response->getBody(); + return json_decode($body, true); + } catch (\Exception $e) { + return ['error' => 'No se pudo conectar con el servicio Python: ' . $e->getMessage()]; + } + } + + + +}