Skip to content

Commit e1887a7

Browse files
author
Alex Westergaard
committed
Add default event parameters to Event Facade/Abstraction
1 parent fd9b2fe commit e1887a7

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/Facade/Type/Event.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@ interface Event extends IO
3636
* @return string snake_case
3737
*/
3838
public function getName(): string;
39+
40+
public function setLanguage(string $lang);
41+
public function setPageLocation(string $url);
42+
public function setPageReferrer(string $url);
43+
public function setPageTitle(string $title);
44+
public function setScreenResolution(string $wxh);
3945
}

src/Helper/AbstractEvent.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,42 @@
77

88
abstract class AbstractEvent extends AbstractIO implements Event
99
{
10+
protected null|string $language;
11+
protected null|string $page_location;
12+
protected null|string $page_referrer;
13+
protected null|string $page_title;
14+
protected null|string $screen_resolution;
15+
16+
public function setLanguage(string $lang)
17+
{
18+
$this->language = $lang;
19+
return $this;
20+
}
21+
22+
public function setPageLocation(string $url)
23+
{
24+
$this->page_location = $url;
25+
return $this;
26+
}
27+
28+
public function setPageReferrer(string $url)
29+
{
30+
$this->page_referrer = $url;
31+
return $this;
32+
}
33+
34+
public function setPageTitle(string $title)
35+
{
36+
$this->page_title = $title;
37+
return $this;
38+
}
39+
40+
public function setScreenResolution(string $wxh)
41+
{
42+
$this->screen_resolution = $wxh;
43+
return $this;
44+
}
45+
1046
public function toArray(): array
1147
{
1248
$return = [];
@@ -34,6 +70,21 @@ public function toArray(): array
3470
return $return;
3571
}
3672

73+
public function getAllParams(): array
74+
{
75+
return array_unique(array_merge(
76+
[
77+
'language',
78+
'page_location',
79+
'page_referrer',
80+
'page_title',
81+
'screen_resolution',
82+
],
83+
$this->getParams(),
84+
$this->getRequiredParams()
85+
));
86+
}
87+
3788
public static function new(): static
3889
{
3990
return new static();

0 commit comments

Comments
 (0)