Browse Source

Merge branch 'master' into develop

develop
Guillaume Bourgeois 2 years ago
parent
commit
1e85b00fab
3 changed files with 59 additions and 0 deletions
  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 View File

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);

+ 50
- 0
Controller/Dashboard/CommandAdminController.php View File

<?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 View File

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:

Loading…
Cancel
Save