1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace VideoGamesRecords\CoreBundle\Controller\Admin; |
6
|
|
|
|
7
|
|
|
use Sonata\AdminBundle\Controller\CRUDController; |
8
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
9
|
|
|
use VideoGamesRecords\CoreBundle\Manager\GameManager; |
10
|
|
|
use Yokai\SonataWorkflow\Controller\WorkflowControllerTrait; |
11
|
|
|
|
12
|
|
|
class GameAdminController extends CRUDController |
13
|
|
|
{ |
14
|
|
|
use WorkflowControllerTrait; |
15
|
|
|
|
16
|
|
|
private GameManager $gameManager; |
17
|
|
|
|
18
|
|
|
public function __construct(GameManager $gameManager) |
19
|
|
|
{ |
20
|
|
|
$this->gameManager = $gameManager; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param $id |
25
|
|
|
* @return RedirectResponse |
26
|
|
|
*/ |
27
|
|
|
public function copyAction($id): RedirectResponse |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
if ($this->admin->hasAccess('create')) { |
30
|
|
|
$game = $this->admin->getSubject(); |
31
|
|
|
|
32
|
|
|
$this->gameManager->copy($game); |
33
|
|
|
$this->addFlash('sonata_flash_success', 'Copied successfully'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
return new RedirectResponse($this->admin->generateUrl('list')); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param $id |
41
|
|
|
* @return RedirectResponse |
42
|
|
|
*/ |
43
|
|
|
public function majAction($id): RedirectResponse |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
$this->gameManager->maj($this->admin->getSubject()); |
46
|
|
|
$this->addFlash('sonata_flash_success', 'Game maj successfully'); |
47
|
|
|
return new RedirectResponse($this->admin->generateUrl('list')); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param $id |
52
|
|
|
* @return RedirectResponse |
53
|
|
|
*/ |
54
|
|
|
public function setProofVideoOnly($id): RedirectResponse |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
$this->gameManager->setProofVideoOnly($this->admin->getSubject()); |
57
|
|
|
$this->addFlash('sonata_flash_success', 'Game maj successfully'); |
58
|
|
|
return new RedirectResponse($this->admin->generateUrl('list')); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.