@@ -4,12 +4,9 @@ |
||
4 | 4 | namespace FlightLog\Http\Web\Controller; |
5 | 5 | |
6 | 6 | |
7 | -use FlightLog\Application\Damage\Command\CreateDamageCommand; |
|
8 | -use FlightLog\Application\Damage\Command\CreateDamageCommandHandler; |
|
9 | 7 | use FlightLog\Application\Pilot\Command\CreateUpdatePilotInformationCommand; |
10 | 8 | use FlightLog\Application\Pilot\Command\CreateUpdatePilotInformationCommandHandler; |
11 | 9 | use FlightLog\Domain\Pilot\ValueObject\PilotId; |
12 | -use FlightLog\Http\Web\Form\DamageCreationForm; |
|
13 | 10 | use FlightLog\Http\Web\Form\PilotForm; |
14 | 11 | use FlightLog\Infrastructure\Pilot\Repository\PilotRepository; |
15 | 12 |
@@ -16,17 +16,17 @@ discard block |
||
16 | 16 | final class PilotEditController extends WebController |
17 | 17 | { |
18 | 18 | |
19 | - public function index(){ |
|
19 | + public function index() { |
|
20 | 20 | $id = $this->request->getParam('id'); |
21 | 21 | |
22 | - if($id === null){ |
|
22 | + if ($id === null) { |
|
23 | 23 | $this->renderHtml('<p>Paramètre ID non fournis.</p>'); |
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | 27 | $command = new CreateUpdatePilotInformationCommand($id); |
28 | 28 | |
29 | - if($this->getPilotRepository()->exist(PilotId::create($id))){ |
|
29 | + if ($this->getPilotRepository()->exist(PilotId::create($id))) { |
|
30 | 30 | $command->fromPilot($this->getPilotRepository()->getById(PilotId::create($id))); |
31 | 31 | } |
32 | 32 | |
@@ -36,24 +36,24 @@ discard block |
||
36 | 36 | $user = new \User($this->db); |
37 | 37 | $user->fetch($id); |
38 | 38 | |
39 | - if($this->request->isPost()){ |
|
39 | + if ($this->request->isPost()) { |
|
40 | 40 | $form->setData($this->request->getPostParameters()); |
41 | 41 | |
42 | - if(!$form->validate()){ |
|
42 | + if (!$form->validate()) { |
|
43 | 43 | return $this->render('pilot/edit.phtml', [ |
44 | 44 | 'form' => $form, |
45 | 45 | ]); |
46 | 46 | } |
47 | 47 | |
48 | - try{ |
|
48 | + try { |
|
49 | 49 | $this->handle($form->getObject()); |
50 | - }catch(\Exception $e){ |
|
50 | + } catch (\Exception $e) { |
|
51 | 51 | print $e->getMessage(); |
52 | 52 | dol_syslog($e->getMessage(), LOG_ERR); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - return $this->redirect($_SERVER["PHP_SELF"].'?id='.$id.'&r=edit_pilot'); |
|
56 | + return $this->redirect($_SERVER["PHP_SELF"] . '?id=' . $id . '&r=edit_pilot'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return $this->render('pilot/edit.phtml', [ |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | /** |
76 | 76 | * @return CreateUpdatePilotInformationCommandHandler() |
77 | 77 | */ |
78 | - private function getHandler(){ |
|
78 | + private function getHandler() { |
|
79 | 79 | return new CreateUpdatePilotInformationCommandHandler($this->getPilotRepository()); |
80 | 80 | } |
81 | 81 |
@@ -48,7 +48,7 @@ |
||
48 | 48 | |
49 | 49 | try{ |
50 | 50 | $this->handle($form->getObject()); |
51 | - }catch(\Exception $e){ |
|
51 | + } catch(\Exception $e){ |
|
52 | 52 | print $e->getMessage(); |
53 | 53 | dol_syslog($e->getMessage(), LOG_ERR); |
54 | 54 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | - * @return CreateUpdatePilotInformationCommand|\stdClass|null |
|
78 | + * @return CreateUpdatePilotInformationCommand |
|
79 | 79 | */ |
80 | 80 | public function getObject() |
81 | 81 | { |
@@ -4,7 +4,6 @@ discard block |
||
4 | 4 | namespace FlightLog\Http\Web\Form; |
5 | 5 | |
6 | 6 | |
7 | -use FlightLog\Application\Damage\Command\CreateDamageCommand; |
|
8 | 7 | use FlightLog\Application\Pilot\Command\CreateUpdatePilotInformationCommand; |
9 | 8 | use flightlog\form\Csrf; |
10 | 9 | use flightlog\form\Form; |
@@ -13,8 +12,6 @@ discard block |
||
13 | 12 | use flightlog\form\Input; |
14 | 13 | use flightlog\form\InputCheckBox; |
15 | 14 | use flightlog\form\InputDate; |
16 | -use flightlog\form\Number; |
|
17 | -use flightlog\form\UserSelect; |
|
18 | 15 | |
19 | 16 | final class PilotForm extends Form |
20 | 17 | { |
@@ -14,7 +14,7 @@ |
||
14 | 14 | final class PilotListController extends WebController |
15 | 15 | { |
16 | 16 | |
17 | - public function index(){ |
|
17 | + public function index() { |
|
18 | 18 | |
19 | 19 | $members = $this->getPilotRepository()->query(); |
20 | 20 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * |
25 | 25 | * @return Id|static |
26 | 26 | */ |
27 | - public static function create($id){ |
|
27 | + public static function create($id) { |
|
28 | 28 | return new self($id); |
29 | 29 | } |
30 | 30 |
@@ -526,7 +526,7 @@ |
||
526 | 526 | |
527 | 527 | public function attributeRadioLicenceDate(RadioLicenceDate $value) |
528 | 528 | { |
529 | - $this->radioLicenceDate = $value; |
|
529 | + $this->radioLicenceDate = $value; |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | public function attributeLastTrainingFirstHelpDate(LastTrainingDate $value) |
@@ -23,7 +23,7 @@ |
||
23 | 23 | return self::no(); |
24 | 24 | } |
25 | 25 | |
26 | - if (is_numeric($value) || is_int($value) || (int)$value == $value) { |
|
26 | + if (is_numeric($value) || is_int($value) || (int) $value == $value) { |
|
27 | 27 | return new self($value == 1); |
28 | 28 | } |
29 | 29 |
@@ -172,13 +172,13 @@ |
||
172 | 172 | continue; |
173 | 173 | } |
174 | 174 | |
175 | - if($match == ".." || $match == "." || substr($match, 0,1) === '.'){ |
|
175 | + if ($match == ".." || $match == "." || substr($match, 0, 1) === '.') { |
|
176 | 176 | continue; |
177 | 177 | } |
178 | 178 | |
179 | 179 | $element = $root . DIRECTORY_SEPARATOR . $match; |
180 | 180 | |
181 | - if(substr_count($element, '/', 3) >= 1){ |
|
181 | + if (substr_count($element, '/', 3) >= 1) { |
|
182 | 182 | scan($element); |
183 | 183 | } |
184 | 184 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | parent::__construct($name, FormElementInterface::TYPE_CHECKBOX, $options); |
17 | 17 | } |
18 | 18 | |
19 | - public function checkedValue(){ |
|
19 | + public function checkedValue() { |
|
20 | 20 | return 1; |
21 | 21 | } |
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function __construct(\DoliDB $db, $tableName) |
24 | 24 | { |
25 | 25 | $this->db = $db; |
26 | - $this->tableName = strpos($tableName, MAIN_DB_PREFIX) === 0 ? $tableName : MAIN_DB_PREFIX.$tableName; |
|
26 | + $this->tableName = strpos($tableName, MAIN_DB_PREFIX) === 0 ? $tableName : MAIN_DB_PREFIX . $tableName; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @throws \Exception |
35 | 35 | */ |
36 | - protected function write(array $elements){ |
|
36 | + protected function write(array $elements) { |
|
37 | 37 | $columns = join(',', array_keys($elements)); |
38 | 38 | $values = join(',', array_map([$this, 'escape'], array_values($elements))); |
39 | 39 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $lasterror = $this->db->lasterror(); |
45 | 45 | dol_syslog(__METHOD__ . ' ' . $lasterror, LOG_ERR); |
46 | 46 | $this->db->rollback(); |
47 | - throw new \Exception("Repository error - ".$lasterror); |
|
47 | + throw new \Exception("Repository error - " . $lasterror); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $id = $this->db->last_insert_id($this->tableName); |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return int|string|null |
59 | 59 | */ |
60 | - private function escape($value){ |
|
61 | - if(is_null($value)){ |
|
60 | + private function escape($value) { |
|
61 | + if (is_null($value)) { |
|
62 | 62 | return 'NULL'; |
63 | 63 | } |
64 | 64 | |
65 | - if(is_bool($value)){ |
|
66 | - return (int)$value; |
|
65 | + if (is_bool($value)) { |
|
66 | + return (int) $value; |
|
67 | 67 | } |
68 | 68 | |
69 | - return is_string($value) ? "'".$this->db->escape($value)."'" : $value ; |
|
69 | + return is_string($value) ? "'" . $this->db->escape($value) . "'" : $value; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -79,18 +79,18 @@ discard block |
||
79 | 79 | { |
80 | 80 | $sqlModifications = []; |
81 | 81 | |
82 | - foreach($elements as $field => $value){ |
|
82 | + foreach ($elements as $field => $value) { |
|
83 | 83 | $sqlModifications[] = sprintf('%s=%s', $field, $this->escape($value)); |
84 | 84 | } |
85 | 85 | |
86 | 86 | $this->db->begin(); |
87 | - $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE '.$idCol.' = %s ', $this->tableName, join(',',$sqlModifications), $id)); |
|
87 | + $resql = $this->db->query(sprintf('UPDATE %s SET %s WHERE ' . $idCol . ' = %s ', $this->tableName, join(',', $sqlModifications), $id)); |
|
88 | 88 | |
89 | 89 | if (!$resql) { |
90 | 90 | $lasterror = $this->db->lasterror(); |
91 | 91 | dol_syslog(__METHOD__ . ' ' . $lasterror, LOG_ERR); |
92 | 92 | $this->db->rollback(); |
93 | - throw new \Exception("Repository error - ".$lasterror); |
|
93 | + throw new \Exception("Repository error - " . $lasterror); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $this->db->commit(); |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return array|null |
106 | 106 | */ |
107 | - protected function get($id, $idCol = 'rowid'){ |
|
108 | - $sql = sprintf('SELECT * FROM %s WHERE '.$idCol.' = %s', $this->tableName, $id ); |
|
107 | + protected function get($id, $idCol = 'rowid') { |
|
108 | + $sql = sprintf('SELECT * FROM %s WHERE ' . $idCol . ' = %s', $this->tableName, $id); |
|
109 | 109 | |
110 | 110 | $resql = $this->db->query($sql); |
111 | 111 | if (!$resql) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | return null; |
118 | 118 | } |
119 | 119 | |
120 | - for($i = 0; $i < $num ; $i++) { |
|
120 | + for ($i = 0; $i < $num; $i++) { |
|
121 | 121 | return $this->db->fetch_array($resql); |
122 | 122 | } |
123 | 123 |