Skip to content

Commit 5494ed8

Browse files
Rom1-Bstonebuzz
andauthored
feature/glpi-11.0 (#125)
* feature/glpi-11.0 * Update public/js/gantt-helper.js Co-authored-by: Stanislas <[email protected]> * beta1 * fix path * fix npm warning * beta2 * Clean composer.json * psalm * rector * release GLPI 11.0 * fix psalm --------- Co-authored-by: Stanislas <[email protected]>
1 parent 1955fae commit 5494ed8

25 files changed

+538
-2582
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: "Generate CI matrix"
2121
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
2222
with:
23-
glpi-version: "10.0.x"
23+
glpi-version: "11.0.x"
2424
ci:
2525
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
2626
needs: "generate-ci-matrix"

.twig_cs.dist.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
declare(strict_types=1);
44

5-
use FriendsOfTwig\Twigcs;
5+
use FriendsOfTwig\Twigcs\Finder\TemplateFinder;
6+
use FriendsOfTwig\Twigcs\Config\Config;
7+
use Glpi\Tools\GlpiTwigRuleset;
68

7-
$finder = Twigcs\Finder\TemplateFinder::create()
9+
$finder = TemplateFinder::create()
810
->in(__DIR__ . '/templates')
911
->name('*.html.twig')
1012
->ignoreVCSIgnored(true);
1113

12-
return Twigcs\Config\Config::create()
14+
return Config::create()
1315
->setFinder($finder)
14-
->setRuleSet(\Glpi\Tools\GlpiTwigRuleset::class)
16+
->setRuleSet(GlpiTwigRuleset::class)
1517
;

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9-
## [Unreleased]
9+
## [1.2.0] - 2025-09-30
10+
11+
### Added
12+
13+
- GLPI 11 compatibility
1014

1115
## [1.1.2] - 2025-09-30
1216

ajax/gantt.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@
2727
* @link https://github.com/pluginsGLPI/gantt
2828
* -------------------------------------------------------------------------
2929
*/
30+
use GlpiPlugin\Gantt\DataFactory;
31+
use GlpiPlugin\Gantt\Item;
32+
use GlpiPlugin\Gantt\ProjectDAO;
33+
use GlpiPlugin\Gantt\TaskDAO;
3034

31-
include('../../../inc/includes.php');
35+
use function Safe\json_encode;
3236

3337
/** @var array $CFG_GLPI */
3438
global $CFG_GLPI;
@@ -46,7 +50,7 @@
4650

4751
if (isset($_REQUEST['getData'])) {
4852
$itemArray = [];
49-
$factory = new \GlpiPlugin\Gantt\DataFactory();
53+
$factory = new DataFactory();
5054
$factory->getItemsForProject($itemArray, $id);
5155
$links = $factory->getProjectTaskLinks($itemArray);
5256

@@ -63,19 +67,19 @@
6367
echo json_encode($result);
6468
} elseif (isset($_POST['addTask'])) {
6569
try {
66-
$item = new \GlpiPlugin\Gantt\Item();
70+
$item = new Item();
6771
$task = $_POST['task'];
6872
$item->populateFrom($task);
69-
$taskDAO = new \GlpiPlugin\Gantt\TaskDAO();
73+
$taskDAO = new TaskDAO();
7074
$newTask = $taskDAO->addTask($item);
71-
$factory = new \GlpiPlugin\Gantt\DataFactory();
75+
$factory = new DataFactory();
7276
$ganttItem = $factory->populateGanttItem($newTask->fields, 'task');
7377

7478
$result = [
7579
'ok' => true,
7680
'item' => $ganttItem,
7781
];
78-
} catch (\Exception $ex) {
82+
} catch (Exception $ex) {
7983
$result = [
8084
'ok' => false,
8185
'error' => $ex->getMessage(),
@@ -85,15 +89,15 @@
8589
} elseif (isset($_POST['updateTask'])) {
8690
try {
8791
$updated = false;
88-
$item = new \GlpiPlugin\Gantt\Item();
92+
$item = new Item();
8993
$task = $_POST['task'];
9094
$item->populateFrom($task);
91-
$taskDAO = new \GlpiPlugin\Gantt\TaskDAO();
95+
$taskDAO = new TaskDAO();
9296
$updated = $taskDAO->updateTask($item);
9397
$result = [
9498
'ok' => $updated,
9599
];
96-
} catch (\Exception $ex) {
100+
} catch (Exception $ex) {
97101
$result = [
98102
'ok' => false,
99103
'error' => $ex->getMessage(),
@@ -106,26 +110,22 @@
106110
$p_target = $_POST['target'];
107111

108112
if ($p_item['type'] == 'project' && $p_target['type'] != 'project') {
109-
throw new \Exception(__('Target item must be of project type', 'gantt'));
113+
throw new Exception(__s('Target item must be of project type', 'gantt'));
110114
}
111115

112-
$item = new \GlpiPlugin\Gantt\Item();
116+
$item = new Item();
113117
$item->populateFrom($p_item);
114-
$target = new \GlpiPlugin\Gantt\Item();
118+
$target = new Item();
115119
$target->populateFrom($p_target);
116120

117121
$item->parent = $target->id;
118-
if ($p_item['type'] == 'project') {
119-
$dao = new \GlpiPlugin\Gantt\ProjectDAO();
120-
} else {
121-
$dao = new \GlpiPlugin\Gantt\TaskDAO();
122-
}
122+
$dao = $p_item['type'] == 'project' ? new ProjectDAO() : new TaskDAO();
123123
$dao->updateParent($item);
124124

125125
$result = [
126126
'ok' => true,
127127
];
128-
} catch (\Exception $ex) {
128+
} catch (Exception $ex) {
129129
$result = [
130130
'ok' => false,
131131
'error' => $ex->getMessage(),
@@ -138,18 +138,18 @@
138138

139139
// double check for safety..
140140
if ($p_item['type'] != 'project') {
141-
throw new \Exception(__('Item must be of project type', 'gantt'));
141+
throw new Exception(__s('Item must be of project type', 'gantt'));
142142
}
143143

144-
$item = new \GlpiPlugin\Gantt\Item();
144+
$item = new Item();
145145
$item->populateFrom($p_item);
146-
$dao = new \GlpiPlugin\Gantt\ProjectDAO();
146+
$dao = new ProjectDAO();
147147
$dao->updateParent($item);
148148

149149
$result = [
150150
'ok' => true,
151151
];
152-
} catch (\Exception $ex) {
152+
} catch (Exception $ex) {
153153
$result = [
154154
'ok' => false,
155155
'error' => $ex->getMessage(),
@@ -158,19 +158,19 @@
158158
echo json_encode($result);
159159
} elseif (isset($_POST['addProject'])) {
160160
try {
161-
$item = new \GlpiPlugin\Gantt\Item();
161+
$item = new Item();
162162
$project = $_POST['project'];
163163
$item->populateFrom($project);
164-
$dao = new \GlpiPlugin\Gantt\ProjectDAO();
164+
$dao = new ProjectDAO();
165165
$newProj = $dao->addProject($item);
166-
$factory = new \GlpiPlugin\Gantt\DataFactory();
166+
$factory = new DataFactory();
167167
$ganttItem = $factory->populateGanttItem($newProj->fields, 'project');
168168

169169
$result = [
170170
'ok' => true,
171171
'item' => $ganttItem,
172172
];
173-
} catch (\Exception $ex) {
173+
} catch (Exception $ex) {
174174
$result = [
175175
'ok' => false,
176176
'error' => $ex->getMessage(),
@@ -180,15 +180,15 @@
180180
} elseif (isset($_POST['updateProject'])) {
181181
try {
182182
$updated = false;
183-
$item = new \GlpiPlugin\Gantt\Item();
183+
$item = new Item();
184184
$project = $_POST['project'];
185185
$item->populateFrom($project);
186-
$projectDAO = new \GlpiPlugin\Gantt\ProjectDAO();
186+
$projectDAO = new ProjectDAO();
187187
$updated = $projectDAO->updateProject($item);
188188
$result = [
189189
'ok' => $updated,
190190
];
191-
} catch (\Exception $ex) {
191+
} catch (Exception $ex) {
192192
$result = [
193193
'ok' => false,
194194
'error' => $ex->getMessage(),
@@ -197,18 +197,18 @@
197197
echo json_encode($result);
198198
} elseif (isset($_POST['addTaskLink'])) {
199199
try {
200-
$taskLink = new \ProjectTaskLink();
200+
$taskLink = new ProjectTaskLink();
201201

202202
if ($taskLink->checkIfExist($_POST['taskLink'])) {
203-
throw new \Exception(__('Link already exist!', 'gantt'));
203+
throw new Exception(__s('Link already exist!', 'gantt'));
204204
}
205205

206206
$id = $taskLink->add($_POST['taskLink']);
207207
$result = [
208208
'ok' => true,
209209
'id' => $id,
210210
];
211-
} catch (\Exception $ex) {
211+
} catch (Exception $ex) {
212212
$result = [
213213
'ok' => false,
214214
'error' => $ex->getMessage(),
@@ -217,12 +217,12 @@
217217
echo json_encode($result);
218218
} elseif (isset($_POST['updateTaskLink'])) {
219219
try {
220-
$taskLink = new \ProjectTaskLink();
220+
$taskLink = new ProjectTaskLink();
221221
$taskLink->update($_POST['taskLink']);
222222
$result = [
223223
'ok' => true,
224224
];
225-
} catch (\Exception $ex) {
225+
} catch (Exception $ex) {
226226
$result = [
227227
'ok' => false,
228228
'error' => $ex->getMessage(),
@@ -231,12 +231,12 @@
231231
echo json_encode($result);
232232
} elseif (isset($_POST['deleteTaskLink'])) {
233233
try {
234-
$taskLink = new \ProjectTaskLink();
234+
$taskLink = new ProjectTaskLink();
235235
$taskLink->delete($_POST);
236236
$result = [
237237
'ok' => true,
238238
];
239-
} catch (\Exception $ex) {
239+
} catch (Exception $ex) {
240240
$result = [
241241
'ok' => false,
242242
'error' => $ex->getMessage(),

composer.json

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
{
22
"require": {
3-
"php": ">=7.4"
3+
"php": ">=8.2"
44
},
55
"require-dev": {
6-
"friendsofphp/php-cs-fixer": "^3.86",
7-
"friendsoftwig/twigcs": "^6.1",
8-
"glpi-project/tools": "^0.8.0",
9-
"php-parallel-lint/php-parallel-lint": "^1.4",
10-
"phpstan/extension-installer": "^1.4",
11-
"phpstan/phpstan": "^2.1",
12-
"phpstan/phpstan-deprecation-rules": "^2.0"
6+
"glpi-project/tools": "^0.8"
137
},
148
"config": {
159
"optimize-autoloader": true,
1610
"platform": {
17-
"php": "7.4.0"
11+
"php": "8.2.99"
1812
},
19-
"sort-packages": true,
20-
"allow-plugins": {
21-
"phpstan/extension-installer": true
22-
}
13+
"sort-packages": true
2314
},
2415
"autoload-dev": {
2516
"psr-4": {

0 commit comments

Comments
 (0)