edit single system config section in modal (#1490)

This commit is contained in:
Kevin Papst
2020-02-22 18:53:03 +01:00
committed by GitHub
parent 886fc8d74e
commit 6c7477f1a9
3 changed files with 53 additions and 14 deletions

View File

@@ -29,6 +29,7 @@ use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Constraints\DateTime;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
@@ -41,26 +42,21 @@ use Symfony\Component\Validator\Constraints\Regex;
* @Route(path="/admin/system-config")
* @Security("is_granted('system_configuration')")
*/
class SystemConfigurationController extends AbstractController
final class SystemConfigurationController extends AbstractController
{
/**
* @var EventDispatcherInterface
*/
protected $eventDispatcher;
private $eventDispatcher;
/**
* @var SystemConfiguration
*/
protected $configurations;
private $configurations;
/**
* @var ConfigurationRepository
*/
protected $repository;
private $repository;
/**
* @param EventDispatcherInterface $dispatcher
* @param ConfigurationRepository $repository
* @param SystemConfiguration $config
*/
public function __construct(EventDispatcherInterface $dispatcher, ConfigurationRepository $repository, SystemConfiguration $config)
{
$this->eventDispatcher = $dispatcher;
@@ -70,10 +66,8 @@ class SystemConfigurationController extends AbstractController
/**
* @Route(path="/", name="system_configuration", methods={"GET"})
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function indexAction()
public function indexAction(): Response
{
$configSettings = $this->getInitializedConfigurations();
@@ -90,6 +84,30 @@ class SystemConfigurationController extends AbstractController
]);
}
/**
* @Route(path="/edit/{section}", name="system_configuration_section", methods={"GET"})
*/
public function sectionAction(string $section): Response
{
$configSettings = $this->getInitializedConfigurations();
$configurations = [];
foreach ($configSettings as $configModel) {
if ($configModel->getSection() !== $section) {
continue;
}
$configurations[] = [
'model' => $configModel,
'form' => $this->createConfigurationsForm($configModel)->createView(),
];
}
return $this->render('system-configuration/index.html.twig', [
'sections' => $configurations,
]);
}
/**
* @Route(path="/update/{section}", name="system_configuration_update", methods={"POST"})
*