Все переписано на фасады

This commit is contained in:
2024-09-03 15:41:45 +03:00
parent 74ba48620c
commit 48b4d6cccf
34 changed files with 1036 additions and 807 deletions

View File

@ -1,37 +0,0 @@
<?php
use App\Library\ContingentManager;
use App\Library\Database;
use App\Library\DatabaseConfig;
use Symfony\Component\Yaml\Yaml;
// При ошибке в запросе к БД. Распарсингованные данные
// сохраняются в yaml-файле. Скрипт парсит этот файл и заносит в БД
require_once "vendor/autoload.php";
function array_depth(array $array)
{
$max_depth = 1;
foreach ($array as $value) {
if (is_array($value)) {
$depth = array_depth($value) + 1;
if ($depth > $max_depth) {
$max_depth = $depth;
}
}
}
return $max_depth;
}
$data = Yaml::parse(file_get_contents(__DIR__ . '/not-recorded-in-db.yaml'));
$db = new Database(new DatabaseConfig('opendata'));
// $orgs = ContingentManager::getInstance()->getOrgs($dbOpendata);
if(array_depth($data) == 2){
ContingentManager::getInstance()->insertContingent($db, $data);
} else {
foreach ($data as $value) {
ContingentManager::getInstance()->insertContingent($db, $value);
}
}