Skip to content

Commit 0404c5c

Browse files
committed
Used Autowire trait
1 parent c58ec55 commit 0404c5c

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

modules/os2forms_digital_post/src/Drush/Commands/DigitalPostTestCommands.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\os2forms_digital_post\Drush\Commands;
44

55
use Drupal\Component\Serialization\Yaml;
6+
use Drupal\Core\DependencyInjection\AutowireTrait;
67
use Drupal\Core\Utility\Token;
78
use Drupal\entity_print\Plugin\EntityPrintPluginManagerInterface;
89
use Drupal\os2forms_digital_post\Helper\DigitalPostHelper;
@@ -12,37 +13,27 @@
1213
use ItkDev\Serviceplatformen\Service\SF1601\SF1601;
1314
use Symfony\Component\Console\Exception\InvalidArgumentException;
1415
use Symfony\Component\Console\Style\SymfonyStyle;
15-
use Symfony\Component\DependencyInjection\ContainerInterface;
16+
use Symfony\Component\DependencyInjection\Attribute\Autowire;
1617
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
1718

1819
/**
1920
* Test commands for digital post.
2021
*/
2122
final class DigitalPostTestCommands extends DrushCommands {
23+
use AutowireTrait;
2224

2325
/**
2426
* Constructor.
2527
*/
2628
public function __construct(
2729
private readonly DigitalPostHelper $digitalPostHelper,
2830
private readonly Token $token,
31+
#[Autowire(service: 'plugin.manager.entity_print.print_engine')]
2932
private readonly EntityPrintPluginManagerInterface $entityPrintPluginManager,
3033
private readonly Settings $digitalPostSettings,
3134
) {
3235
}
3336

34-
/**
35-
* {@inheritdoc}
36-
*/
37-
public static function create(ContainerInterface $container): self {
38-
return new static(
39-
$container->get(DigitalPostHelper::class),
40-
$container->get('token'),
41-
$container->get('plugin.manager.entity_print.print_engine'),
42-
$container->get(Settings::class),
43-
);
44-
}
45-
4637
/**
4738
* Send digital post.
4839
*

modules/os2forms_fasit/src/Drush/Commands/FasitTestCommand.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Drupal\os2forms_fasit\Drush\Commands;
44

5+
use Drupal\Core\DependencyInjection\AutowireTrait;
56
use Drupal\os2forms_fasit\Helper\FasitHelper;
67
use Drush\Commands\DrushCommands;
7-
use Symfony\Component\DependencyInjection\ContainerInterface;
88

99
/**
1010
* A Drush commandfile.
1111
*/
1212
final class FasitTestCommand extends DrushCommands {
13+
use AutowireTrait;
1314

1415
/**
1516
* Constructs a FasitTestCommand object.
@@ -20,15 +21,6 @@ public function __construct(
2021
parent::__construct();
2122
}
2223

23-
/**
24-
* {@inheritdoc}
25-
*/
26-
public static function create(ContainerInterface $container) {
27-
return new static(
28-
$container->get(FasitHelper::class),
29-
);
30-
}
31-
3224
/**
3325
* Test API access.
3426
*

0 commit comments

Comments
 (0)