|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Zikula package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright Zikula Foundation - https://ziku.la/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Zikula\Bundle\CoreInstallerBundle\Controller; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
17
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
|
18
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
19
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
20
|
|
|
use Zikula\Component\Wizard\FormHandlerInterface; |
|
21
|
|
|
use Zikula\Component\Wizard\Wizard; |
|
22
|
|
|
use Zikula\Component\Wizard\WizardCompleteInterface; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class InstallerController |
|
26
|
|
|
*/ |
|
27
|
|
|
class InstallerController extends AbstractController |
|
28
|
|
|
{ |
|
29
|
|
|
public function __construct(ContainerInterface $container) |
|
30
|
|
|
{ |
|
31
|
|
|
parent::__construct($container); |
|
32
|
|
|
$this->router = $container->get('router'); |
|
33
|
|
|
$this->form = $this->container->get('form.factory'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function installAction(Request $request, string $stage): Response |
|
37
|
|
|
{ |
|
38
|
|
|
// already installed? |
|
39
|
|
|
if ('complete' !== $stage && true === $this->container->getParameter('installed')) { |
|
40
|
|
|
$stage = 'installed'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
// not installed but requesting installed stage? |
|
44
|
|
|
if ('installed' === $stage && false === $this->container->getParameter('installed')) { |
|
45
|
|
|
$stage = 'notinstalled'; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
// check php |
|
49
|
|
|
$ini_warnings = $this->controllerHelper->initPhp(); |
|
50
|
|
|
if (count($ini_warnings) > 0) { |
|
51
|
|
|
$request->getSession()->getFlashBag()->add('warning', implode('<hr>', $ini_warnings)); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$request->setLocale($this->container->getParameter('locale')); |
|
55
|
|
|
// begin the wizard |
|
56
|
|
|
$wizard = new Wizard($this->container, dirname(__DIR__) . '/Resources/config/install_stages.yml'); |
|
57
|
|
|
$currentStage = $wizard->getCurrentStage($stage); |
|
58
|
|
|
if ($currentStage instanceof WizardCompleteInterface) { |
|
59
|
|
|
return $currentStage->getResponse($request); |
|
60
|
|
|
} |
|
61
|
|
|
$templateParams = $this->controllerHelper->getTemplateGlobals($currentStage); |
|
62
|
|
|
$templateParams['headertemplate'] = '@ZikulaCoreInstaller/installheader.html.twig'; |
|
63
|
|
|
if ($wizard->isHalted()) { |
|
64
|
|
|
$request->getSession()->getFlashBag()->add('danger', $wizard->getWarning()); |
|
65
|
|
|
|
|
66
|
|
|
return $this->renderResponse('@ZikulaCoreInstaller/error.html.twig', $templateParams); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
// handle the form |
|
70
|
|
|
if ($currentStage instanceof FormHandlerInterface) { |
|
71
|
|
|
$form = $this->form->create($currentStage->getFormType(), null, $currentStage->getFormOptions()); |
|
|
|
|
|
|
72
|
|
|
$form->handleRequest($request); |
|
73
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
|
74
|
|
|
$currentStage->handleFormResult($form); |
|
75
|
|
|
$params = ['stage' => $wizard->getNextStage()->getName(), '_locale' => $this->container->getParameter('locale')]; |
|
76
|
|
|
$url = $this->router->generate('install', $params); |
|
77
|
|
|
|
|
78
|
|
|
return new RedirectResponse($url); |
|
79
|
|
|
} |
|
80
|
|
|
$templateParams['form'] = $form->createView(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return $this->renderResponse($currentStage->getTemplateName(), $templateParams); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.