46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
use SvedenParser\Color;
|
|
use SvedenParser\PriemParser\PriemManager;
|
|
use SvedenParser\PriemParser\PriemRepository;
|
|
use SvedenParser\Printer;
|
|
use SvedenParser\Repository;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
|
|
define('SVEDEN_PARSER', '/home/developer/sveden_parser');
|
|
|
|
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
|
|
|
$manager = new PriemManager();
|
|
$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
|
|
. " не обнаружен. Дозапись в базу не требуется"
|
|
);
|
|
}
|
|
|
|
$priem = Yaml::parse(
|
|
file_get_contents(SVEDEN_PARSER . '/' . Repository::FILE_ADD_RECORDING)
|
|
);
|
|
$databaseFacade = new PriemRepository();
|
|
$databaseFacade->insert($priem);
|
|
|
|
Printer::println("Дозапись выполнена!", Color::BLUE);
|
|
} catch (\Exception $e) {
|
|
Printer::println($e->getMessage(), Color::RED);
|
|
exit(0);
|
|
} |