Banner.php
984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace AC\Admin;
use AC\Integration;
use AC\IntegrationRepository;
use AC\Integrations;
use AC\Promo;
use AC\PromoCollection;
use AC\View;
class Banner {
/**
* @var IntegrationRepository
*/
private $integrations;
public function __construct() {
$this->integrations = new IntegrationRepository();
}
private function get_active_promotion(): ?Promo {
return ( new PromoCollection() )->find_active();
}
private function get_missing_integrations(): Integrations {
return $this->integrations->find_all( [
'filter' => [
new Integration\Filter\IsPluginActive(),
],
] );
}
/**
* @return string
*/
public function render() {
$banner = new View( [
'promo' => $this->get_active_promotion(),
'integrations' => $this->get_missing_integrations()->all(),
'discount' => 10,
] );
$banner->set_template( 'admin/side-banner' );
return $banner->render();
}
public function __toString() {
return $this->render();
}
}