Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DependencyInjection] New Dependency Injection component #269

Merged
merged 19 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cf7d3a2
[DependencyInjection] New Dependency Injection component
mpoiriert May 20, 2024
f400a55
[AwsToolKit] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
689a71d
[Application] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
102e0cc
[Console] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
675df58
[CronJob] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
c95f8cb
[DoctrineExtra] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
0caa014
[EntityMigrator] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
8f88484
[Mailer] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
a18bd87
[Messenger] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
deecc49
[OpenApi] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
e4f30ae
[Process] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
a1fadce
[Security] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
8ba2c2e
[Tester] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
7c589ed
[Validator] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
a8a1985
[Workflow] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
fb68907
[Log] Use new draw/dependency-injection component
mpoiriert Jun 28, 2024
d05e2a4
[Application] base service feature class
mpoiriert Jun 28, 2024
f2e4d58
[All] DependencyInjection new ContainerBuilderIntegrationInterface
mpoiriert Jun 28, 2024
54bf22d
[All] fix split test
mpoiriert Jun 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/after_splitting_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- console
- core
- cron-job
- dependency-injection
- doctrine-extra
- entity-migrator
- fixer
Expand All @@ -39,6 +40,7 @@ jobs:
- validator
- workflow


name: After Split Testing of ${{ matrix.package_name }}

steps:
Expand Down
9 changes: 7 additions & 2 deletions app/src/Feature/DemoFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

namespace App\Feature;

use Draw\Bundle\FrameworkExtraBundle\Feature\ServiceFeature;
use Draw\Component\Application\Feature\Attribute\Config;
use Draw\Component\Application\Feature\FeatureInitializer;
use Draw\Component\Application\Feature\SelfInitializeFeatureInterface;

class DemoFeature extends ServiceFeature implements SelfInitializeFeatureInterface
class DemoFeature implements SelfInitializeFeatureInterface
{
#[Config]
private bool $enabled = true;

private ?int $limit = null;

public function __construct(FeatureInitializer $featureInitializer)
{
$featureInitializer->initialize($this);
}

public function getName(): string
{
return 'acme_demo';
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"draw/contracts": "self.version",
"draw/core": "self.version",
"draw/cron-job": "self.version",
"draw/dependency-injection": "self.version",
"draw/doctrine-extra": "self.version",
"draw/entity-migrator": "self.version",
"draw/fixer": "self.version",
Expand Down Expand Up @@ -180,6 +181,7 @@
"Draw\\Component\\Console\\": "packages/console/",
"Draw\\Component\\Core\\": "packages/core/",
"Draw\\Component\\CronJob\\": "packages/cron-job/",
"Draw\\Component\\DependencyInjection\\": "packages/dependency-injection/",
"Draw\\Component\\EntityMigrator\\": "packages/entity-migrator/",
"Draw\\Component\\Log\\": "packages/log/",
"Draw\\Component\\Mailer\\": "packages/mailer/",
Expand Down Expand Up @@ -294,4 +296,4 @@
"vendor/bin/phpstan analyse --generate-baseline"
]
}
}
}
4 changes: 1 addition & 3 deletions config/packages/draw_framework_extra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ draw_framework_extra:
feature: ~

log:
enable_all_processors: true

logger:
slow_request:
default_duration: 5000
request_matchers:
- path: '^/api'
enable_all_processors: true

mailer:
css_inliner: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration;
namespace Draw\Component\Application\DependencyInjection;

use Draw\Component\Application\Configuration\DoctrineConfigurationRegistry;
use Draw\Component\Application\Configuration\Entity\Config;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\IntegrationTrait;
use Draw\Component\DependencyInjection\Integration\PrependIntegrationInterface;
use Draw\Contracts\Application\ConfigurationRegistryInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration;
namespace Draw\Component\Application\DependencyInjection;

use Draw\Component\Application\Cron\CronManager;
use Draw\Component\Application\Cron\Job;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\IntegrationTrait;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration;
namespace Draw\Component\Application\DependencyInjection;

use Draw\Component\Application\Feature\FeatureInitializer;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\IntegrationTrait;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration;
namespace Draw\Component\Application\DependencyInjection;

use Doctrine\Persistence\ConnectionRegistry;
use Draw\Component\Application\SystemMonitoring\Bridge\Doctrine\ConnectionStatusProviderInterface;
Expand All @@ -10,6 +10,9 @@
use Draw\Component\Application\SystemMonitoring\Bridge\Symfony\Messenger\MessengerStatusProvider;
use Draw\Component\Application\SystemMonitoring\MonitoredService;
use Draw\Component\Application\SystemMonitoring\System;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\IntegrationTrait;
use Draw\Component\DependencyInjection\Integration\PrependIntegrationInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration;
namespace Draw\Component\Application\DependencyInjection;

use Draw\Component\Application\Versioning\EventListener\FetchRunningVersionListener;
use Draw\Component\Application\Versioning\VersionManager;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\IntegrationTrait;
use Draw\Contracts\Application\VersionVerificationInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Draw\Component\Application\Feature;

interface SelfInitializeFeatureInterface
interface SelfInitializeFeatureInterface extends FeatureInterface
{
public function initialize(array $configuration): void;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\Integration;
namespace Draw\Component\Application\Tests\DependencyInjection;

use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\ConfigurationIntegration;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\Application\Configuration\DoctrineConfigurationRegistry;
use Draw\Component\Application\Configuration\Entity\Config;
use Draw\Component\Application\DependencyInjection\ConfigurationIntegration;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\Test\IntegrationTestCase;
use Draw\Component\DependencyInjection\Integration\Test\ServiceConfiguration;
use Draw\Contracts\Application\ConfigurationRegistryInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -47,7 +48,7 @@ public function testPrependNoDoctrineExtension(): void
public function testPrepend(): void
{
$containerBuilder = new ContainerBuilder();
$containerBuilder->registerExtension(new DoctrineExtension());
$containerBuilder->registerExtension($this->mockExtension('doctrine'));

$this->integration->prepend(
$containerBuilder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\Integration;
namespace Draw\Component\Application\Tests\DependencyInjection;

use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\CronIntegration;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\Application\Cron\Command\CronDumpToFileCommand;
use Draw\Component\Application\Cron\CronManager;
use Draw\Component\Application\DependencyInjection\CronIntegration;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\Test\IntegrationTestCase;
use Draw\Component\DependencyInjection\Integration\Test\ServiceConfiguration;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Component\DependencyInjection\Definition;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\Integration;
namespace Draw\Component\Application\Tests\DependencyInjection;

use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\ConfigurationIntegration;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\FeatureIntegration;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\Application\DependencyInjection\ConfigurationIntegration;
use Draw\Component\Application\DependencyInjection\FeatureIntegration;
use Draw\Component\Application\Feature\FeatureInitializer;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\Test\IntegrationTestCase;
use Draw\Component\DependencyInjection\Integration\Test\ServiceConfiguration;
use PHPUnit\Framework\Attributes\CoversClass;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\Integration;
namespace Draw\Component\Application\Tests\DependencyInjection;

use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\DrawFrameworkExtraExtension;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\IntegrationInterface;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\SystemMonitoringIntegration;
use Draw\Component\Application\DependencyInjection\SystemMonitoringIntegration;
use Draw\Component\Application\SystemMonitoring\Action\PingAction;
use Draw\Component\Application\SystemMonitoring\Bridge\Doctrine\DBALConnectionStatusProvider;
use Draw\Component\Application\SystemMonitoring\Bridge\Doctrine\DBALPrimaryReadReplicaConnectionStatusProvider;
use Draw\Component\Application\SystemMonitoring\Bridge\Doctrine\DoctrineConnectionServiceStatusProvider;
use Draw\Component\Application\SystemMonitoring\Bridge\Symfony\Messenger\MessengerStatusProvider;
use Draw\Component\Application\SystemMonitoring\Command\SystemStatusesCommand;
use Draw\Component\Application\SystemMonitoring\System;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\Test\IntegrationTestCase;
use Draw\Component\DependencyInjection\Integration\Test\ServiceConfiguration;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand Down Expand Up @@ -43,7 +44,7 @@ public function getDefaultConfiguration(): array
public function testPrepend(): void
{
$containerBuilder = new ContainerBuilder();
$containerBuilder->registerExtension(new DrawFrameworkExtraExtension());
$containerBuilder->registerExtension($this->mockExtension('draw_framework_extra'));

$this->integration->prepend(
$containerBuilder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\Integration;
namespace Draw\Component\Application\Tests\DependencyInjection;

use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\IntegrationInterface;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\VersioningIntegration;
use Draw\Component\Application\DependencyInjection\VersioningIntegration;
use Draw\Component\Application\Versioning\Command\UpdateDeployedVersionCommand;
use Draw\Component\Application\Versioning\EventListener\FetchRunningVersionListener;
use Draw\Component\Application\Versioning\VersionManager;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\Test\IntegrationTestCase;
use Draw\Component\DependencyInjection\Integration\Test\ServiceConfiguration;
use Draw\Contracts\Application\VersionVerificationInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Component\DependencyInjection\Definition;
Expand Down
4 changes: 3 additions & 1 deletion packages/application/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
},
"require-dev": {
"phpunit/phpunit": "^9.0 || ^10.0",
"draw/dependency-injection": "^0.11",
"draw/tester": "^0.11",
"symfony/cache": "^6.4.0",
"symfony/console": "^6.4.0"
"symfony/console": "^6.4.0",
"symfony/messenger": "^6.4.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration;
namespace Draw\Component\AwsToolKit\DependencyInjection;

use Draw\Component\AwsToolKit\DependencyInjection\Compiler\AddNewestInstanceRoleCommandOptionPass;
use Draw\Component\AwsToolKit\EventListener\NewestInstanceRoleCheckListener;
use Draw\Component\AwsToolKit\Imds\ImdsClientInterface;
use Draw\Component\AwsToolKit\Imds\ImdsClientV1;
use Draw\Component\AwsToolKit\Imds\ImdsClientV2;
use Draw\Component\DependencyInjection\Integration\ContainerBuilderIntegrationInterface;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\IntegrationTrait;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;

class AwsToolKitIntegration implements IntegrationInterface
class AwsToolKitIntegration implements IntegrationInterface, ContainerBuilderIntegrationInterface
{
use IntegrationTrait;

Expand All @@ -19,6 +23,11 @@ public function getConfigSectionName(): string
return 'aws_tool_kit';
}

public function buildContainer(ContainerBuilder $container): void
{
$container->addCompilerPass(new AddNewestInstanceRoleCommandOptionPass());
}

public function load(array $config, PhpFileLoader $loader, ContainerBuilder $container): void
{
$this->registerClasses(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Draw\Component\AwsToolKit\DependencyInjection\Compiler;

use Draw\Component\AwsToolKit\EventListener\NewestInstanceRoleCheckListener;
use Draw\Component\DependencyInjection\Container\DefinitionFinder;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;

class AddNewestInstanceRoleCommandOptionPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
try {
$container->findDefinition(NewestInstanceRoleCheckListener::class);
} catch (ServiceNotFoundException) {
return;
}

foreach (DefinitionFinder::findConsoleCommandDefinitions($container) as $definition) {
$definition
->addMethodCall(
'addOption',
[
NewestInstanceRoleCheckListener::OPTION_AWS_NEWEST_INSTANCE_ROLE,
null,
InputOption::VALUE_REQUIRED,
'The instance role the server must be the newest of to run the command.',
]
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\Integration;
namespace Draw\Component\AwsToolKit\Tests\DependencyInjection;

use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\AwsToolKitIntegration;
use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\AwsToolKit\Command\CloudWatchLogsDownloadCommand;
use Draw\Component\AwsToolKit\DependencyInjection\AwsToolKitIntegration;
use Draw\Component\AwsToolKit\EventListener\NewestInstanceRoleCheckListener;
use Draw\Component\AwsToolKit\Imds\ImdsClientInterface;
use Draw\Component\AwsToolKit\Imds\ImdsClientV1;
use Draw\Component\AwsToolKit\Imds\ImdsClientV2;
use Draw\Component\DependencyInjection\Integration\IntegrationInterface;
use Draw\Component\DependencyInjection\Integration\Test\IntegrationTestCase;
use Draw\Component\DependencyInjection\Integration\Test\ServiceConfiguration;
use PHPUnit\Framework\Attributes\CoversClass;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Draw\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\Compiler;
namespace Draw\Component\AwsToolKit\Tests\DependencyInjection\Compiler;

use Draw\Bundle\FrameworkExtraBundle\DependencyInjection\Compiler\AddNewestInstanceRoleCommandOptionPass;
use Draw\Component\AwsToolKit\DependencyInjection\Compiler\AddNewestInstanceRoleCommandOptionPass;
use Draw\Component\AwsToolKit\EventListener\NewestInstanceRoleCheckListener;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
Expand Down
1 change: 1 addition & 0 deletions packages/aws-tool-kit/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"require-dev": {
"draw/core": "^0.11",
"draw/dependency-injection": "^0.11",
"draw/tester": "^0.11",
"phpunit/phpunit": "^9.0 || ^10.0",
"symfony/cache": "^6.4.0",
Expand Down
Loading
Loading