77use Illuminate \Console \OutputStyle ;
88use Symfony \Component \Console \Input \StringInput ;
99use Symfony \Component \Console \Output \StreamOutput ;
10-
10+ use \ App \ Events \ GedComProgressSent ;
1111class GedcomParser
1212{
1313 /**
@@ -18,29 +18,35 @@ class GedcomParser
1818 */
1919 protected $ persons_id = [];
2020
21- public function parse (string $ filename , bool $ progressBar = false )
21+ public function parse (string $ filename , string $ slug , bool $ progressBar = false )
2222 {
2323 $ parser = new \PhpGedcom \Parser ();
2424 $ gedcom = @$ parser ->parse ($ filename );
2525
2626 $ individuals = $ gedcom ->getIndi ();
2727 $ families = $ gedcom ->getFam ();
28-
28+ $ total = count ($ individuals ) + count ($ families );
29+ $ complete = 0 ;
2930 if ($ progressBar === true ) {
3031 $ bar = $ this ->getProgressBar (count ($ individuals ) + count ($ families ));
32+ event (new GedComProgressSent ($ slug , $ total , $ complete ));
3133 }
3234
3335 foreach ($ individuals as $ individual ) {
3436 $ this ->getPerson ($ individual );
3537 if ($ progressBar === true ) {
3638 $ bar ->advance ();
39+ $ complete ++;
40+ event (new GedComProgressSent ($ slug , $ total , $ complete ));
3741 }
3842 }
3943
4044 foreach ($ families as $ family ) {
4145 $ this ->getFamily ($ family );
4246 if ($ progressBar === true ) {
4347 $ bar ->advance ();
48+ $ complete ++;
49+ event (new GedComProgressSent ($ slug , $ total , $ complete ));
4450 }
4551 }
4652
0 commit comments