浏览代码

Merge branch 'develop'

develop
Fabien Normand 3 年前
父节点
当前提交
07a254db5a
共有 3 个文件被更改,包括 34 次插入5 次删除
  1. +2
    -1
      Component/EntityComponent.php
  2. +29
    -3
      Controller/ErrorController.php
  3. +3
    -1
      Resources/config/services.yaml

+ 2
- 1
Component/EntityComponent.php 查看文件

@@ -68,8 +68,9 @@ class EntityComponent
$newEntity->setCreatedAt(new \DateTime());
}

$this->entityManager->create($newEntity);
$this->eventDispatcher->dispatch(new EntityComponentEvent($newEntity), EntityComponentEvent::DUPLICATE_EVENT);
//Ne pas utiliser create ici! Sinon pour certaine entité comme ProductFamily on réajoute un orginProduct
$this->entityManager->persist($newEntity);

return $newEntity;
}

+ 29
- 3
Controller/ErrorController.php 查看文件

@@ -2,22 +2,48 @@

namespace Lc\SovBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Mailer\MailerInterface;
use Throwable;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\Mime\Email;

class ErrorController extends AbstractController
{

public function show(Throwable $exception, DebugLoggerInterface $logger = null)
public function show($exception, DebugLoggerInterface $logger = null, MailerInterface $mailer)
{
//Si != de 404 on envoit un mail de debug
if ($exception->getStatusCode() != 404) {
$mailDebug = $this->getParameter('app.mail_debug');
if ($mailDebug) {
$message = "Code : " . $exception->getStatusCode() . "<br>";
$message .= "Message : " . $exception->getMessage() . "<br>";
$message .= "File : " . $exception->getFile() . "<br>";
$message .= "Line : " . $exception->getLine() . "<br><br>";
$message .= "Trace : <br>" . str_replace("\n", "<br>", $exception->getTraceAsString());
$siteName = $this->getParameter('app.site_name');
$email = (new Email())
->from('nepasrepondre@laclic.fr')
->to($mailDebug)
->subject(
'[' . $siteName . '] [ERREUR ' . $exception->getStatusCode() . '] ' . $exception->getMessage(
) . ''
)
->text(strip_tags($message))
->html($message);

$mailer->send($email);
}
}
if (str_contains($this->getRequestStack()->getCurrentRequest(), "/admin")) {
return $this->render('@LcSov/exception/error.html.twig', [
"code" => $exception->getCode(),
"code" => $exception->getStatusCode(),
"message" => $exception->getMessage()
]);
} else {
return $this->render('bundles/TwigBundle/Exception/error.html.twig', [
"code" => $exception->getCode(),
"code" => $exception->getStatusCode(),
"message" => $exception->getMessage()
]);
}

+ 3
- 1
Resources/config/services.yaml 查看文件

@@ -41,4 +41,6 @@ services:
- { name: kernel.event_listener, event: kernel.exception }

parameters:
app.admin.logo: 'laclic.png'
app.admin.logo: 'laclic.png'
app.site_name: 'laclic-sov'
app.mail_debug: ''

正在加载...
取消
保存