Просмотр исходного кода

Merge branch 'master' into develop

develop
Guillaume Bourgeois 2 лет назад
Родитель
Сommit
1e85b00fab
3 измененных файлов: 59 добавлений и 0 удалений
  1. +7
    -0
      Controller/ControllerTrait.php
  2. +50
    -0
      Controller/Dashboard/CommandAdminController.php
  3. +2
    -0
      Resources/translations/admin.fr.yaml

+ 7
- 0
Controller/ControllerTrait.php Просмотреть файл

@@ -32,6 +32,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices;
@@ -80,6 +81,7 @@ trait ControllerTrait
ComponentContainer::class => ComponentContainer::class,
EntityRepository::class => EntityRepository::class,
FileComponent::class => FileComponent::class,
KernelInterface::class => KernelInterface::class
]
);
}
@@ -217,6 +219,11 @@ trait ControllerTrait
return $this->get(AdminUrlGenerator::class);
}

public function getKernel(): KernelInterface
{
return $this->get(KernelInterface::class);
}

public function getSettingSolver(): SettingSolver
{
return $this->get(SettingSolver::class);

+ 50
- 0
Controller/Dashboard/CommandAdminController.php Просмотреть файл

@@ -0,0 +1,50 @@
<?php

namespace Lc\SovBundle\Controller\Dashboard;

use Lc\SovBundle\Controller\ControllerTrait;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class CommandAdminController extends AbstractController
{
use ControllerTrait;

/**
* @Route("/admin/command/cache/clear", name="admin_command_cache_clear")
*/
public function cacheClear(Request $request)
{
$this->doCommand('cache:clear');

$this->addFlashTranslator('success', 'command.cacheClear');

return $this->redirect($request->headers->get('referer'));
}

private function doCommand($command)
{
$kernel = $this->getKernel();
$env = $kernel->getEnvironment();

$application = new Application($kernel);
$application->setAutoExit(false);

$input = new ArrayInput(array(
'command' => $command,
'--env' => $env
));

$output = new BufferedOutput();
$application->run($input, $output);

$content = $output->fetch();

//return new Response($content);
}
}

+ 2
- 0
Resources/translations/admin.fr.yaml Просмотреть файл

@@ -183,6 +183,8 @@ entity:
flash_message:
passwordUpdated: Votre mot de passe a bien été modifié
updated: L'élément a bien été mis à jour
command:
cacheClear: Le cache a bien été supprimé

form:
account_profile:

Загрузка…
Отмена
Сохранить