2017-11-05 22:34:11 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PHPCensor\Controller;
|
|
|
|
|
2018-03-04 08:30:34 +01:00
|
|
|
use PHPCensor\Store\Factory;
|
2018-02-16 14:18:04 +01:00
|
|
|
use PHPCensor\View;
|
2018-03-04 11:22:14 +01:00
|
|
|
use PHPCensor\Http\Response;
|
2017-11-05 22:34:11 +01:00
|
|
|
use PHPCensor\BuildFactory;
|
|
|
|
use PHPCensor\Controller;
|
2017-11-09 14:51:07 +01:00
|
|
|
use PHPCensor\Store\BuildStore;
|
2017-11-05 22:34:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Widget Last Builds Controller
|
|
|
|
*/
|
|
|
|
class WidgetLastBuildsController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
2017-11-09 14:51:07 +01:00
|
|
|
* @var BuildStore
|
2017-11-05 22:34:11 +01:00
|
|
|
*/
|
|
|
|
protected $buildStore;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise the controller, set up stores and services.
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
2017-11-09 14:51:07 +01:00
|
|
|
$this->buildStore = Factory::getStore('Build');
|
2017-11-05 22:34:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-11-09 14:51:07 +01:00
|
|
|
* Display dashboard.
|
2017-11-05 22:34:11 +01:00
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$builds = $this->buildStore->getLatestBuilds(null, 10);
|
|
|
|
|
|
|
|
foreach ($builds as &$build) {
|
|
|
|
$build = BuildFactory::getBuild($build);
|
|
|
|
}
|
|
|
|
|
2017-11-09 14:51:07 +01:00
|
|
|
$view = new View('WidgetLastBuilds/update');
|
2017-11-05 22:34:11 +01:00
|
|
|
|
2017-11-09 14:51:07 +01:00
|
|
|
$view->builds = $builds;
|
2017-11-05 22:34:11 +01:00
|
|
|
$this->view->timeline = $view->render();
|
|
|
|
|
|
|
|
$this->response->disableLayout();
|
|
|
|
$this->response->setContent($this->view->render());
|
|
|
|
|
|
|
|
return $this->response;
|
|
|
|
}
|
|
|
|
|
2017-11-09 14:51:07 +01:00
|
|
|
/**
|
|
|
|
* @return Response
|
|
|
|
*/
|
2017-11-05 22:34:11 +01:00
|
|
|
public function update()
|
|
|
|
{
|
|
|
|
$builds = $this->buildStore->getLatestBuilds(null, 10);
|
|
|
|
|
|
|
|
foreach ($builds as &$build) {
|
|
|
|
$build = BuildFactory::getBuild($build);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->view->builds = $builds;
|
|
|
|
|
|
|
|
$this->response->disableLayout();
|
|
|
|
$this->response->setContent($this->view->render());
|
|
|
|
|
|
|
|
return $this->response;
|
|
|
|
}
|
|
|
|
}
|