You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
807 B
36 lines
807 B
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Data\TacticInfo;
|
|
use App\Gateway\TacticInfoGateway;
|
|
|
|
class EditorController {
|
|
|
|
const TACTIC_DEFAULT_NAME = "Nouvelle tactique";
|
|
|
|
private TacticInfoGateway $tactics;
|
|
|
|
/**
|
|
* @param TacticInfoGateway $tactics
|
|
*/
|
|
public function __construct(TacticInfoGateway $tactics) {
|
|
$this->tactics = $tactics;
|
|
}
|
|
|
|
private function openEditor(TacticInfo $tactic) {
|
|
send_react_front("views/Editor.tsx", ["name" => $tactic->getName(), "id" => $tactic->getId()]);
|
|
}
|
|
|
|
public function makeNew() {
|
|
$info = $this->tactics->insert(self::TACTIC_DEFAULT_NAME);
|
|
$this->openEditor($info);
|
|
}
|
|
|
|
public function edit(int $id) {
|
|
$tactic = $this->tactics->get($id);
|
|
|
|
$this->openEditor($tactic);
|
|
}
|
|
|
|
} |