Skip to content

Commit 3153a35

Browse files
committed
Converting all code to PSR-12
1 parent 4bb9e2b commit 3153a35

File tree

267 files changed

+27666
-28854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+27666
-28854
lines changed

src/App/Activity/ActivityApp.php

+37-38
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Part of the Joomla Tracker's Activity Application
45
*
@@ -19,45 +20,43 @@
1920
*/
2021
class ActivityApp implements AppInterface
2122
{
22-
/**
23-
* Loads services for the component into the application's DI Container
24-
*
25-
* @param Container $container DI Container to load services into
26-
*
27-
* @return void
28-
*
29-
* @since 1.0
30-
* @throws \RuntimeException
31-
*/
32-
public function loadServices(Container $container)
33-
{
34-
$this->registerRoutes($container->get('router'));
35-
}
23+
/**
24+
* Loads services for the component into the application's DI Container
25+
*
26+
* @param Container $container DI Container to load services into
27+
*
28+
* @return void
29+
*
30+
* @since 1.0
31+
* @throws \RuntimeException
32+
*/
33+
public function loadServices(Container $container)
34+
{
35+
$this->registerRoutes($container->get('router'));
36+
}
3637

37-
/**
38-
* Registers the routes for the app
39-
*
40-
* @param Router $router The application router
41-
*
42-
* @return void
43-
*
44-
* @since 1.0
45-
* @throws \RuntimeException
46-
*/
47-
private function registerRoutes(Router $router)
48-
{
49-
// Register the component routes
50-
$maps = json_decode(file_get_contents(__DIR__ . '/routes.json'), true);
38+
/**
39+
* Registers the routes for the app
40+
*
41+
* @param Router $router The application router
42+
*
43+
* @return void
44+
*
45+
* @since 1.0
46+
* @throws \RuntimeException
47+
*/
48+
private function registerRoutes(Router $router)
49+
{
50+
// Register the component routes
51+
$maps = json_decode(file_get_contents(__DIR__ . '/routes.json'), true);
5152

52-
if (!$maps)
53-
{
54-
throw new \RuntimeException('Invalid router file for the Activity app: ' . __DIR__ . '/routes.json', 500);
55-
}
53+
if (!$maps) {
54+
throw new \RuntimeException('Invalid router file for the Activity app: ' . __DIR__ . '/routes.json', 500);
55+
}
5656

57-
foreach ($maps as $patttern => $controller)
58-
{
59-
// TODO - Routes should be identified for proper methods
60-
$router->all($patttern, $controller);
61-
}
62-
}
57+
foreach ($maps as $patttern => $controller) {
58+
// TODO - Routes should be identified for proper methods
59+
$router->all($patttern, $controller);
60+
}
61+
}
6362
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Part of the Joomla Tracker's Activity Application
45
*
@@ -18,33 +19,33 @@
1819
*/
1920
abstract class AbstractBaseController extends AbstractTrackerController
2021
{
21-
/**
22-
* View object
23-
*
24-
* @var DefaultHtmlView
25-
* @since 1.0
26-
*/
27-
protected $view;
28-
29-
/**
30-
* Initialize the controller.
31-
*
32-
* @return $this Method supports chaining
33-
*
34-
* @since 1.0
35-
*/
36-
public function initialize()
37-
{
38-
parent::initialize();
39-
40-
/** @var \JTracker\Application\Application $application */
41-
$application = $this->getContainer()->get('app');
42-
43-
$application->getUser()->authorize('view');
44-
45-
$this->model->setProject($application->getProject());
46-
$this->view->setProject($application->getProject());
47-
48-
return $this;
49-
}
22+
/**
23+
* View object
24+
*
25+
* @var DefaultHtmlView
26+
* @since 1.0
27+
*/
28+
protected $view;
29+
30+
/**
31+
* Initialize the controller.
32+
*
33+
* @return $this Method supports chaining
34+
*
35+
* @since 1.0
36+
*/
37+
public function initialize()
38+
{
39+
parent::initialize();
40+
41+
/** @var \JTracker\Application\Application $application */
42+
$application = $this->getContainer()->get('app');
43+
44+
$application->getUser()->authorize('view');
45+
46+
$this->model->setProject($application->getProject());
47+
$this->view->setProject($application->getProject());
48+
49+
return $this;
50+
}
5051
}

src/App/Activity/Controller/ActivitySnapshotController.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Part of the Joomla Tracker's Activity Application
45
*
@@ -15,11 +16,11 @@
1516
*/
1617
class ActivitySnapshotController extends AbstractBaseController
1718
{
18-
/**
19-
* The default view for the app
20-
*
21-
* @var string
22-
* @since 1.0
23-
*/
24-
protected $defaultView = 'snapshot';
19+
/**
20+
* The default view for the app
21+
*
22+
* @var string
23+
* @since 1.0
24+
*/
25+
protected $defaultView = 'snapshot';
2526
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Part of the Joomla Tracker's Activity Application
45
*
@@ -9,7 +10,6 @@
910
namespace App\Activity\Controller\Ajax;
1011

1112
use App\Activity\Model\SnapshotModel;
12-
1313
use JTracker\Controller\AbstractAjaxController;
1414

1515
/**
@@ -21,86 +21,81 @@
2121
*/
2222
class ActivitySnapshot extends AbstractAjaxController
2323
{
24-
/**
25-
* Initialize the controller.
26-
*
27-
* This will set up default model and view classes.
28-
*
29-
* @return $this Method allows chiaining
30-
*
31-
* @since 1.0
32-
*/
33-
public function initialize()
34-
{
35-
$application = $this->getContainer()->get('app');
36-
37-
// Setup the model to query our data
38-
$this->model = new SnapshotModel($this->getContainer()->get('db'));
39-
$this->model->setProject($application->getProject());
40-
41-
return $this;
42-
}
43-
44-
/**
45-
* Prepare the response.
46-
*
47-
* @return void
48-
*
49-
* @since 1.0
50-
*/
51-
protected function prepareResponse()
52-
{
53-
$statusLabels = [
54-
1 => 'New',
55-
2 => 'Confirmed',
56-
3 => 'Pending',
57-
4 => 'Ready To Commit',
58-
6 => 'Needs Review',
59-
7 => 'Information Required',
60-
14 => 'Discussion',
61-
];
62-
63-
$iterator = $this->model->getOpenIssues();
64-
$counts = [];
65-
66-
foreach ($iterator as $item)
67-
{
68-
// Create the status' container if it hasn't already been
69-
if (!isset($counts[$statusLabels[$item->status]]))
70-
{
71-
$counts[$statusLabels[$item->status]] = [0];
72-
}
73-
74-
$counts[$statusLabels[$item->status]][0]++;
75-
}
76-
77-
$dataByStatus = array_values($counts);
78-
$ticks = array_keys($counts);
79-
$labels = [];
80-
81-
foreach ($ticks as $type)
82-
{
83-
$object = new \stdClass;
84-
$object->label = $type;
85-
$labels[] = $object;
86-
}
87-
88-
$data = [];
89-
$internalData = [];
90-
91-
for ($i = 0; $i < \count($counts); $i++)
92-
{
93-
$internalData[] = 0;
94-
}
95-
96-
foreach ($dataByStatus as $key => $dataForOneStatus)
97-
{
98-
$row = $internalData;
99-
$row[$key] = $dataForOneStatus[0];
100-
$data[] = $row;
101-
}
102-
103-
// Setup the response data
104-
$this->response->data = [$data, $ticks, $labels];
105-
}
24+
/**
25+
* Initialize the controller.
26+
*
27+
* This will set up default model and view classes.
28+
*
29+
* @return $this Method allows chiaining
30+
*
31+
* @since 1.0
32+
*/
33+
public function initialize()
34+
{
35+
$application = $this->getContainer()->get('app');
36+
37+
// Setup the model to query our data
38+
$this->model = new SnapshotModel($this->getContainer()->get('db'));
39+
$this->model->setProject($application->getProject());
40+
41+
return $this;
42+
}
43+
44+
/**
45+
* Prepare the response.
46+
*
47+
* @return void
48+
*
49+
* @since 1.0
50+
*/
51+
protected function prepareResponse()
52+
{
53+
$statusLabels = [
54+
1 => 'New',
55+
2 => 'Confirmed',
56+
3 => 'Pending',
57+
4 => 'Ready To Commit',
58+
6 => 'Needs Review',
59+
7 => 'Information Required',
60+
14 => 'Discussion',
61+
];
62+
63+
$iterator = $this->model->getOpenIssues();
64+
$counts = [];
65+
66+
foreach ($iterator as $item) {
67+
// Create the status' container if it hasn't already been
68+
if (!isset($counts[$statusLabels[$item->status]])) {
69+
$counts[$statusLabels[$item->status]] = [0];
70+
}
71+
72+
$counts[$statusLabels[$item->status]][0]++;
73+
}
74+
75+
$dataByStatus = array_values($counts);
76+
$ticks = array_keys($counts);
77+
$labels = [];
78+
79+
foreach ($ticks as $type) {
80+
$object = new \stdClass();
81+
$object->label = $type;
82+
$labels[] = $object;
83+
}
84+
85+
$data = [];
86+
$internalData = [];
87+
88+
for ($i = 0; $i < \count($counts); $i++) {
89+
$internalData[] = 0;
90+
}
91+
92+
foreach ($dataByStatus as $key => $dataForOneStatus) {
93+
$row = $internalData;
94+
$row[$key] = $dataForOneStatus[0];
95+
$data[] = $row;
96+
}
97+
98+
// Setup the response data
99+
$this->response->data = [$data, $ticks, $labels];
100+
}
106101
}

0 commit comments

Comments
 (0)