Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ jobs:

strategy:
matrix:
php-versions: ['8.3']
php-versions: ['8.3', '8.4']
name: PHP ${{ matrix.php-versions }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Get composer cache directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
- uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down
29 changes: 15 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,32 @@
"minimum-stability": "stable",
"require": {
"php": "^8.3",
"hostnet/entity-tracker-component": "^2.3.0",
"hostnet/entity-tracker-component": "^3.0.0",
"psr/log": "^1.1.0||^2.0.0||^3.0.0",
"symfony/config": "^5.4||^6.0",
"symfony/dependency-injection": "^5.4||^6.0",
"symfony/http-kernel": "^5.4||^6.0",
"symfony/yaml": "^5.4||^6.0"
"symfony/config": "^6.4",
"symfony/dependency-injection": "^6.4",
"symfony/http-kernel": "^6.4",
"symfony/yaml": "^6.4"
},
"require-dev": {
"hostnet/entity-blamable-component": "^1.1.0",
"hostnet/entity-blamable-component": "^2.0.1",
"hostnet/phpcs-tool": "^9.1.0",
"phpspec/prophecy": "^1.19",
"phpspec/prophecy-phpunit": "^2.2",
"phpunit/phpunit": "^9.5.6",
"symfony/framework-bundle": "^5.4||^6.0",
"symfony/security-bundle": "^5.4||^6.0"
"symfony/framework-bundle": "^6.4",
"symfony/security-bundle": "^6.4"
},
"suggest": {
"hostnet/entity-blamable-component": "Provides the @Blamable annotation/attribute and listeners",
"hostnet/entity-mutation-component": "Provides the @Mutation annotation/attribute and listeners",
"hostnet/entity-revision-component": "Provides the @Revision annotation/attribute and listeners"
"hostnet/entity-blamable-component": "Provides the #[Blamable] attribute and listeners",
"hostnet/entity-mutation-component": "Provides the #[Mutation] attribute and listeners",
"hostnet/entity-revision-component": "Provides the #[Revision] attribute and listeners"
},
"conflict": {
"hostnet/entity-blamable-component": "<1.1.0",
"hostnet/entity-mutation-component": "<1.1.0",
"hostnet/entity-revision-component": "<1.2.0"
"hostnet/entity-blamable-component": "<2.0.1",
"hostnet/entity-mutation-component": "<2.0.0",
"hostnet/entity-revision-component": "<2.0.0",
"symfony/console": ">=8.0"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Configuration implements ConfigurationInterface

private const string CONFIG_ROOT = 'hostnet_entity_tracker';

#[\Override]
public function getConfigTreeBuilder(): TreeBuilder
{
$tree_builder = new TreeBuilder(self::CONFIG_ROOT);
Expand Down
13 changes: 4 additions & 9 deletions src/DependencyInjection/HostnetEntityTrackerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

class HostnetEntityTrackerExtension extends Extension
{
private const string BLAMABLE = 'Hostnet\Component\EntityBlamable\Blamable';
private const string MUTATION = 'Hostnet\Component\EntityMutation\Mutation';
private const string REVISION = 'Hostnet\Component\EntityRevision\Revision';
private const string BLAMABLE = 'Hostnet\Component\EntityBlamable\Attributes\Blamable';
private const string MUTATION = 'Hostnet\Component\EntityMutation\Attributes\Mutation';
private const string REVISION = 'Hostnet\Component\EntityRevision\Attributes\Revision';

#[\Override]
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
Expand Down Expand Up @@ -78,9 +79,6 @@ public function load(array $configs, ContainerBuilder $container): void
}

/**
* @param string $annotation_class
* @param string $config_name
*
* @throws \RuntimeException
*/
protected function validateComponent(string $annotation_class, string $config_name): void
Expand All @@ -97,9 +95,6 @@ protected function validateComponent(string $annotation_class, string $config_na
}

/**
* @param string $annotation_class
* @param string $config_name
*
* @throws \RuntimeException
*/
protected function validateClass(string $annotation_class, string $config_name): void
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/blamable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
entity_tracker.resolver.blamable:
class: Hostnet\Component\EntityBlamable\Resolver\BlamableResolver
arguments:
- "@entity_tracker.provider.annotation_metadata"
- "@entity_tracker.provider.entity_metadata"

entity_tracker.listener.blamable:
class: Hostnet\Component\EntityBlamable\Listener\BlamableListener
Expand All @@ -11,6 +11,6 @@ services:
- "" # provider id, (configurable)
- "" # cacheadapter id (configurable, entity_tracker.cache by default)
tags:
- { name: doctrine.event_listener, event: entityChanged, priority: 32, method: onEntityChanged }
- { name: doctrine.event_listener, event: entityChanged, priority: 32 }


2 changes: 1 addition & 1 deletion src/Resources/config/mutation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
entity_tracker.resolver.mutation:
class: Hostnet\Component\EntityMutation\Resolver\MutationResolver
arguments:
- "@entity_tracker.provider.annotation_metadata"
- "@entity_tracker.provider.entity_metadata"

entity_tracker.listener.mutation:
class: Hostnet\Component\EntityMutation\Listener\MutationListener
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/revision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
entity_tracker.resolver.revision:
class: Hostnet\Component\EntityRevision\Resolver\RevisionResolver
arguments:
- "@entity_tracker.provider.annotation_metadata"
- "@entity_tracker.provider.entity_metadata"

entity_tracker.listener.revision:
class: Hostnet\Component\EntityRevision\Listener\RevisionListener
Expand Down
10 changes: 3 additions & 7 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@ services:
entity_tracker.cache:
class: Symfony\Component\Cache\Adapter\ArrayAdapter

entity_tracker.provider.annotation_metadata:
class: Hostnet\Component\EntityTracker\Provider\EntityAnnotationMetadataProvider
arguments:
- "@annotation_reader"
entity_tracker.provider.entity_metadata:
class: Hostnet\Component\EntityTracker\Provider\EntityMetadataProvider

entity_tracker.provider.mutation_metadata:
class: Hostnet\Component\EntityTracker\Provider\EntityMutationMetadataProvider
arguments:
- "@annotation_reader"
- "@?logger"

entity_tracker.listener.entity_changed:
class: Hostnet\Component\EntityTracker\Listener\EntityChangedListener
arguments:
- "@entity_tracker.provider.annotation_metadata"
- "@entity_tracker.provider.entity_metadata"
- "@entity_tracker.provider.mutation_metadata"
- "@?logger"
- "" # cacheadapter id (configurable, entity_tracker.cache by default)
tags:
- { name: doctrine.event_listener, event: preFlush, priority: 15 }
- { name: doctrine.event_listener, event: prePersist, priority: 15 }
20 changes: 6 additions & 14 deletions src/Services/Blamable/DefaultBlamableProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,13 @@
*/
class DefaultBlamableProvider implements BlamableProviderInterface
{
/**
* @var TokenStorageInterface
*/
private $token_storage;

/**
* @var string
*/
private $username;

public function __construct(TokenStorageInterface $token_storage, string $username)
{
$this->token_storage = $token_storage;
$this->username = $username;
public function __construct(
private TokenStorageInterface $token_storage,
private string $username
) {
}

#[\Override]
public function getUpdatedBy(): string
{
if (($token = $this->token_storage->getToken()) instanceof TokenInterface) {
Expand All @@ -40,6 +31,7 @@ public function getUpdatedBy(): string
return $this->username;
}

#[\Override]
public function getChangedAt(): \DateTime
{
return new \DateTime();
Expand Down
16 changes: 7 additions & 9 deletions tests/DependencyInjection/HostnetEntityTrackerExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace Hostnet\Bundle\EntityTrackerBundle\DependencyInjection;

use Hostnet\Component\EntityBlamable\Blamable;
use Hostnet\Component\EntityBlamable\Attributes\Blamable;
use Hostnet\Component\EntityMutation\Attributes\Mutation;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand All @@ -15,19 +16,16 @@
*/
class HostnetEntityTrackerExtensionTest extends TestCase
{
private $container;

/**
* @var HostnetEntityTrackerExtension
*/
private $extension;
private ContainerBuilder $container;
private HostnetEntityTrackerExtension $extension;

#[\Override]
public function setUp(): void
{
$this->container = new ContainerBuilder();

$this->extension = $this->getMockBuilder(HostnetEntityTrackerExtension::class)
->setMethods(['validateComponent', 'validateClass'])
->onlyMethods(['validateComponent', 'validateClass'])
->getMock();
}

Expand Down Expand Up @@ -60,7 +58,7 @@ public function testLoadMutation(): void

$this->extension->expects(self::once())
->method('validateComponent')
->with('Hostnet\Component\EntityMutation\Mutation', 'mutation');
->with(Mutation::class, 'mutation');

$this->extension->load($configs, $this->container);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/Functional/Fixtures/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

class TestKernel extends Kernel
{
/**
* {@inheritdoc}
*/
#[\Override]
public function registerBundles(): array
{
return [
Expand All @@ -22,16 +20,19 @@ public function registerBundles(): array
];
}

#[\Override]
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__ . '/config/config.yaml');
}

#[\Override]
public function getCacheDir(): string
{
return __DIR__ . '/../../../var/cache/' . $this->getEnvironment();
}

#[\Override]
public function getLogDir(): string
{
return __DIR__ . '/../../../var/logs';
Expand Down
2 changes: 2 additions & 0 deletions tests/Functional/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
*/
class FunctionalTest extends KernelTestCase
{
#[\Override]
protected function setUp(): void
{
static::bootKernel();
}

#[\Override]
protected static function getKernelClass(): string
{
return TestKernel::class;
Expand Down
3 changes: 2 additions & 1 deletion tests/Services/Blamable/DefaultBlamableProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class DefaultBlamableProviderTest extends TestCase
{
use ProphecyTrait;

private $token_storage;
private TokenStorageInterface $token_storage;

#[\Override]
protected function setUp(): void
{
$this->token_storage = $this->createMock(TokenStorageInterface::class);
Expand Down