Exemple #1
0
 public function run(CollectionAbstract $filter, AbstractBuilder $builder)
 {
     $table = new Table('files/KLADR.DBF', null, 'CP866');
     $lookOnlyAbbr = false;
     $errors = 0;
     /** @var Scheme $row */
     while ($row = $table->nextRecord()) {
         if ($lookOnlyAbbr && $row->socr != $lookOnlyAbbr) {
             continue;
         }
         try {
             $abbr = new Abbreviation($row->socr);
             $code = new Code($row->code);
             $name = new Name($row->name, $abbr);
             if ($filter->isAllowed($name, $code)) {
                 $builder->buildPart($name, $code);
             }
         } catch (UnknownAbbrException $e) {
             $lookOnlyAbbr = $row->socr;
             $errors++;
             echo $row->code . ' ' . $row->socr . ' ' . $row->name . PHP_EOL;
         }
     }
     if ($errors) {
         echo 'Total items: ' . $errors . PHP_EOL;
     }
     echo $builder->getAsJson();
 }
Exemple #2
0
 public function getAsJson()
 {
     $this->merge();
     $this->sort();
     $this->data = $this->getImportTree($this->tree);
     return parent::getAsJson();
 }