Skip to content

Commit 53bc21b

Browse files
Merge pull request #31 from familytree365/feature/event-channel-details
data event & channel settings
2 parents 85826d6 + 6de43dd commit 53bc21b

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

src/Events/GedComProgressSent.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class GedComProgressSent implements ShouldBroadcast
1717
public $slug;
1818
public $total;
1919
public $complete;
20+
public $channel;
2021

2122
/**
2223
* Create a new event instance.
@@ -25,12 +26,33 @@ class GedComProgressSent implements ShouldBroadcast
2526
* @param $total
2627
* @param $complete
2728
*/
28-
public function __construct($slug, $total, $complete)
29+
public function __construct(
30+
$slug,
31+
$total,
32+
$complete,
33+
$channel = ['name' => 'gedcom-progress', 'eventName' => 'newMessage']
34+
)
2935
{
3036
$this->slug = $slug;
3137
$this->total = $total;
3238
$this->complete = $complete;
3339
$this->queue = 'low';
40+
41+
$this->channel = $channel;
42+
}
43+
44+
/**
45+
* Get the data to broadcast.
46+
*
47+
* @return array
48+
*/
49+
public function broadcastWith()
50+
{
51+
return [
52+
'slug' => $this->slug,
53+
'total' => $this->total,
54+
'complete' => $this->complete,
55+
];
3456
}
3557

3658
/**
@@ -40,11 +62,11 @@ public function __construct($slug, $total, $complete)
4062
*/
4163
public function broadcastOn()
4264
{
43-
return new Channel('gedcom-progress');
65+
return new Channel($this->channel['name']);
4466
}
4567

4668
public function broadcastAs()
4769
{
48-
return 'newMessage';
70+
return $this->channel['eventName'];
4971
}
5072
}

src/Utils/GedcomParser.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ class GedcomParser
2929
protected $repo_ids = [];
3030
protected $conn = '';
3131

32-
public function parse($conn, string $filename, string $slug, bool $progressBar = false)
32+
public function parse(
33+
$conn,
34+
string $filename,
35+
string $slug,
36+
bool $progressBar = false,
37+
$channel = ['name' => 'gedcom-progress', 'eventName' => 'newMessage']
38+
)
3339
{
3440
$this->conn = $conn;
3541
error_log('PARSE LOG : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'.$conn);
@@ -46,14 +52,14 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
4652
$head = $gedcom->getHead();
4753
}
4854
**/
49-
55+
5056
$subn = [];
5157
$subm = [];
5258
$sour = [];
5359
$note = [];
5460
$repo = [];
5561
$obje = [];
56-
62+
5763
if ($gedcom->getSubn())
5864
{
5965
$subn = $gedcom->getSubn();
@@ -101,7 +107,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
101107
$complete = 0;
102108
if ($progressBar === true) {
103109
$bar = $this->getProgressBar(count($individuals) + count($families));
104-
event(new GedComProgressSent($slug, $total, $complete));
110+
event(new GedComProgressSent($slug, $total, $complete, $channel));
105111
}
106112
Log::info('Individual:'.count($individuals));
107113
Log::info('Families:'.count($families));
@@ -124,7 +130,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
124130
if ($progressBar === true) {
125131
$bar->advance();
126132
$complete++;
127-
event(new GedComProgressSent($slug, $total, $complete));
133+
event(new GedComProgressSent($slug, $total, $complete, $channel));
128134
}
129135
}
130136

@@ -139,7 +145,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
139145
if ($progressBar === true) {
140146
$bar->advance();
141147
$complete++;
142-
event(new GedComProgressSent($slug, $total, $complete));
148+
event(new GedComProgressSent($slug, $total, $complete, $channel));
143149
}
144150
}
145151

@@ -150,7 +156,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
150156
if ($progressBar === true) {
151157
$bar->advance();
152158
$complete++;
153-
event(new GedComProgressSent($slug, $total, $complete));
159+
event(new GedComProgressSent($slug, $total, $complete, $channel));
154160
}
155161
}
156162

@@ -166,7 +172,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
166172
if ($progressBar === true) {
167173
$bar->advance();
168174
$complete++;
169-
event(new GedComProgressSent($slug, $total, $complete));
175+
event(new GedComProgressSent($slug, $total, $complete, $channel));
170176
}
171177
}
172178

@@ -181,7 +187,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
181187
if ($progressBar === true) {
182188
$bar->advance();
183189
$complete++;
184-
event(new GedComProgressSent($slug, $total, $complete));
190+
event(new GedComProgressSent($slug, $total, $complete, $channel));
185191
}
186192
}
187193

@@ -199,7 +205,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
199205
if ($progressBar === true) {
200206
$bar->advance();
201207
$complete++;
202-
event(new GedComProgressSent($slug, $total, $complete));
208+
event(new GedComProgressSent($slug, $total, $complete, $channel));
203209
}
204210
}
205211

@@ -208,7 +214,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
208214
if ($progressBar === true) {
209215
$bar->advance();
210216
$complete++;
211-
event(new GedComProgressSent($slug, $total, $complete));
217+
event(new GedComProgressSent($slug, $total, $complete, $channel));
212218
}
213219
}
214220

@@ -242,7 +248,7 @@ public function parse($conn, string $filename, string $slug, bool $progressBar =
242248
if ($progressBar === true) {
243249
$bar->advance();
244250
$complete++;
245-
event(new GedComProgressSent($slug, $total, $complete));
251+
event(new GedComProgressSent($slug, $total, $complete, $channel));
246252
}
247253
}
248254

0 commit comments

Comments
 (0)