внёс первые изменения
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SvedenParser\Color;
|
||||
use SvedenParser\ContingentParser\ContingentManager;
|
||||
use SvedenParser\ContingentParser\ContingentRepository;
|
||||
use SvedenParser\Parser\ContingentManager;
|
||||
use SvedenParser\Parser\ContingentRepository;
|
||||
use SvedenParser\Printer;
|
||||
use SvedenParser\Repository;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
@ -11,37 +11,29 @@ define('SVEDEN_PARSER', '/home/developer/sveden_parser');
|
||||
|
||||
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
||||
|
||||
if (file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
Printer::println("Обнаружен файл " . Repository::FILE_ADD_RECORDING, Color::RED);
|
||||
Printer::print("Продолжить y/n? ", Color::BLUE);
|
||||
$action = trim(fgets(STDIN));
|
||||
if ($action !== 'y') {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$manager = new ContingentManager();
|
||||
// $sites = $manager->getSitesFromLog('sites-http.log');
|
||||
$sites = $manager->getSites();
|
||||
// $sites = Yaml::parse(file_get_contents(dirname(__FILE__) ."/sites.yaml"));
|
||||
|
||||
$start = 0; $end = count($sites);
|
||||
// $start = 0; $end = (int)(count($sites) / 2);
|
||||
// $start = (int)(count($sites) / 2); $end = count($sites);
|
||||
|
||||
for ($i = $start; $i < $end; $i++) {
|
||||
Printer::print(++$i . ". ", Color::GREEN);
|
||||
$manager->collectData($sites[--$i]);
|
||||
}
|
||||
Printer::println();
|
||||
|
||||
try {
|
||||
if (!file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
throw new Exception(
|
||||
"Файл " . Repository::FILE_ADD_RECORDING
|
||||
. " не обнаружен. Дозапись в базу не требуется"
|
||||
);
|
||||
}
|
||||
|
||||
$contingent = Yaml::parse(
|
||||
file_get_contents(SVEDEN_PARSER . '/' . Repository::FILE_ADD_RECORDING)
|
||||
);
|
||||
$databaseFacade = new ContingentRepository();
|
||||
$databaseFacade->insert($contingent);
|
||||
|
||||
Printer::println("Дозапись выполнена!", Color::BLUE);
|
||||
} catch (\Exception $e) {
|
||||
Printer::println($e->getMessage(), Color::RED);
|
||||
exit(0);
|
||||
}
|
||||
if (!file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
Printer::println("Файл " . Repository::FILE_ADD_RECORDING . " не обнаружен. Дозапись в базу не требуется");
|
||||
exit;
|
||||
}
|
||||
$contingent = Yaml::parse(file_get_contents(SVEDEN_PARSER . '/' . Repository::FILE_ADD_RECORDING));
|
||||
(new ContingentRepository())->insert($contingent);
|
||||
Printer::println("Дозапись выполнена!", Color::BLUE);
|
||||
|
Reference in New Issue
Block a user