Skip to content

Commit 496759b

Browse files
Fix DependencyInjection using service name instead of class FQCN & remove last autowire annotation
1 parent f0e5220 commit 496759b

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

config/services/controller.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ services:
1010
$messageBus: '@messenger.default_bus'
1111
$uploadDirectory: '%upload_directory%'
1212
$context: '@EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext'
13+
$logDirectory: '%kernel.logs_dir%'
1314
tags:
1415
- { name: 'controller.service_arguments' }

src/Controller/Admin/Process/LaunchAction.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use EasyCorp\Bundle\EasyAdminBundle\Config\Asset;
2222
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
2323
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
24-
use Symfony\Component\DependencyInjection\Attribute\Autowire;
2524
use Symfony\Component\Filesystem\Filesystem;
2625
use Symfony\Component\Form\Extension\Core\Type\TextType;
2726
use Symfony\Component\HttpFoundation\File\UploadedFile;

src/Controller/Admin/ProcessExecutionCrudController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
2626
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
2727
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
28-
use Symfony\Component\DependencyInjection\Attribute\Autowire;
2928
use Symfony\Component\HttpFoundation\RedirectResponse;
3029
use Symfony\Component\HttpFoundation\Response;
3130
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -116,11 +115,11 @@ public function showLogs(AdminContext $adminContext): RedirectResponse
116115

117116
public function downloadLogFile(
118117
AdminContext $context,
119-
#[Autowire(param: 'kernel.logs_dir')] string $directory,
118+
string $logDirectory,
120119
): Response {
121120
/** @var ProcessExecution $processExecution */
122121
$processExecution = $context->getEntity()->getInstance();
123-
$filepath = $directory.\DIRECTORY_SEPARATOR.$processExecution->code.\DIRECTORY_SEPARATOR
122+
$filepath = $logDirectory.\DIRECTORY_SEPARATOR.$processExecution->code.\DIRECTORY_SEPARATOR
124123
.$processExecution->logFilename;
125124
$basename = basename($filepath);
126125
$content = file_get_contents($filepath);

src/DependencyInjection/CleverAgeProcessUiExtension.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
use CleverAge\ProcessUiBundle\Controller\Admin\UserCrudController;
1818
use CleverAge\ProcessUiBundle\Entity\User;
1919
use CleverAge\ProcessUiBundle\Message\ProcessExecuteMessage;
20-
use CleverAge\ProcessUiBundle\Monolog\Handler\DoctrineProcessHandler;
21-
use CleverAge\ProcessUiBundle\Monolog\Handler\ProcessHandler;
2220
use Monolog\Level;
2321
use Symfony\Component\Config\FileLocator;
2422
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -37,7 +35,7 @@ public function load(array $configs, ContainerBuilder $container): void
3735
$config = $this->processConfiguration($configuration, $configs);
3836
$container->getDefinition(UserCrudController::class)
3937
->setArgument('$roles', array_combine($config['security']['roles'], $config['security']['roles']));
40-
$container->getDefinition(ProcessHandler::class)
38+
$container->getDefinition('cleverage_ui_process.monolog_handler.process')
4139
->addMethodCall('setReportIncrementLevel', [$config['logs']['report_increment_level']]);
4240
$container->getDefinition(ProcessDashboardController::class)
4341
->setArgument('$logoPath', $config['design']['logo_path']);
@@ -55,11 +53,11 @@ public function prepend(ContainerBuilder $container): void
5553
'handlers' => [
5654
'pb_ui_file' => [
5755
'type' => 'service',
58-
'id' => ProcessHandler::class,
56+
'id' => 'cleverage_ui_process.monolog_handler.process',
5957
],
6058
'pb_ui_orm' => [
6159
'type' => 'service',
62-
'id' => DoctrineProcessHandler::class,
60+
'id' => 'cleverage_ui_process.monolog_handler.doctrine_process',
6361
],
6462
],
6563
]

src/Monolog/Handler/DoctrineProcessHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DoctrineProcessHandler extends AbstractProcessingHandler
2525
{
2626
/** @var ArrayCollection<int, LogRecord> */
2727
private ArrayCollection $records;
28-
private ?ProcessExecutionManager $processExecutionManager;
28+
private ?ProcessExecutionManager $processExecutionManager = null;
2929
private ?EntityManagerInterface $em = null;
3030

3131
public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true)

src/Monolog/Handler/ProcessHandler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public function __construct(
2929
parent::__construct($this->directory);
3030
}
3131

32+
/**
33+
* @param 'ALERT'|'Alert'|'alert'|'CRITICAL'|'Critical'|'critical'|'DEBUG'|'Debug'|'debug'|'EMERGENCY'|'Emergency'|'emergency'|'ERROR'|'Error'|'error'|'INFO'|'Info'|'info'|'NOTICE'|'Notice'|'notice'|'WARNING'|'Warning'|'warning' $level
34+
*/
35+
public function setReportIncrementLevel(string $level): void
36+
{
37+
$this->reportIncrementLevel = Level::fromName($level);
38+
}
39+
3240
public function hasFilename(): bool
3341
{
3442
return $this->directory !== $this->url;
@@ -57,12 +65,4 @@ public function write(LogRecord $record): void
5765
$this->processExecutionManager->increment($record->level->name);
5866
}
5967
}
60-
61-
/**
62-
* @param 'ALERT'|'Alert'|'alert'|'CRITICAL'|'Critical'|'critical'|'DEBUG'|'Debug'|'debug'|'EMERGENCY'|'Emergency'|'emergency'|'ERROR'|'Error'|'error'|'INFO'|'Info'|'info'|'NOTICE'|'Notice'|'notice'|'WARNING'|'Warning'|'warning' $level
63-
*/
64-
public function setReportIncrementLevel(string $level): void
65-
{
66-
$this->reportIncrementLevel = Level::fromName($level);
67-
}
6868
}

0 commit comments

Comments
 (0)