use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||||
use Symfony\Component\HttpKernel\KernelInterface; | |||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
use Symfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices; | use Symfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices; | ||||
ComponentContainer::class => ComponentContainer::class, | ComponentContainer::class => ComponentContainer::class, | ||||
EntityRepository::class => EntityRepository::class, | EntityRepository::class => EntityRepository::class, | ||||
FileComponent::class => FileComponent::class, | FileComponent::class => FileComponent::class, | ||||
KernelInterface::class => KernelInterface::class | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
return $this->get(AdminUrlGenerator::class); | return $this->get(AdminUrlGenerator::class); | ||||
} | } | ||||
public function getKernel(): KernelInterface | |||||
{ | |||||
return $this->get(KernelInterface::class); | |||||
} | |||||
public function getSettingSolver(): SettingSolver | public function getSettingSolver(): SettingSolver | ||||
{ | { | ||||
return $this->get(SettingSolver::class); | return $this->get(SettingSolver::class); |
<?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); | |||||
} | |||||
} |
flash_message: | flash_message: | ||||
passwordUpdated: Votre mot de passe a bien été modifié | passwordUpdated: Votre mot de passe a bien été modifié | ||||
updated: L'élément a bien été mis à jour | updated: L'élément a bien été mis à jour | ||||
command: | |||||
cacheClear: Le cache a bien été supprimé | |||||
form: | form: | ||||
account_profile: | account_profile: |