-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathWidgetLastBuildsController.php
More file actions
79 lines (60 loc) · 1.86 KB
/
WidgetLastBuildsController.php
File metadata and controls
79 lines (60 loc) · 1.86 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
declare(strict_types=1);
namespace PHPCensor\Controller;
use PHPCensor\BuildFactory;
use Symfony\Component\HttpFoundation\Response;
use PHPCensor\Store\BuildStore;
use PHPCensor\View;
use PHPCensor\WebController;
/**
* @package PHP Censor
* @subpackage Application
*
* @author Dmitry Khomutov <[email protected]>
*/
class WidgetLastBuildsController extends WebController
{
protected BuildStore $buildStore;
protected BuildFactory $buildFactory;
/**
* Initialise the controller, set up stores and services.
*/
public function init(): void
{
parent::init();
$this->buildStore = $this->storeRegistry->get('Build');
$this->buildFactory = new BuildFactory(
$this->configuration,
$this->storeRegistry
);
}
/**
* Display dashboard.
*/
public function index(): Response
{
$builds = $this->buildStore->getLatestBuilds(null, 10);
foreach ($builds as &$build) {
$build = $this->buildFactory->getBuild($build);
}
$view = new View('WidgetLastBuilds/update');
$view->builds = $builds;
$view->environmentStore = $this->storeRegistry->get('Environment');
$this->view->timeline = $view->render();
$response = new Response();
$response->setContent($this->view->render());
return $response;
}
public function update(): Response
{
$builds = $this->buildStore->getLatestBuilds(null, 10);
foreach ($builds as &$build) {
$build = $this->buildFactory->getBuild($build);
}
$this->view->builds = $builds;
$this->view->environmentStore = $this->storeRegistry->get('Environment');
$response = new Response();
$response->setContent($this->view->render());
return $response;
}
}