Skip to content
Closed
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
/.phpunit.result.cache
/composer.lock
/bin
.idea
.env.test
phpunit.xml
tests/Fixtures/app/var/
36 changes: 18 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
],
"require": {
"php": ">=8.1",
"doctrine/annotations": "^1.14",
"doctrine/annotations": "2.*",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/orm": "^2.14",
"doctrine/orm": "^3.3.1",
"elasticsearch/elasticsearch": "^7.1",
"symfony/dotenv": "6.4.*",
"symfony/expression-language": "6.4.*",
"symfony/framework-bundle": "^6.4",
"symfony/messenger": "6.4.*",
"symfony/property-info": "6.4.*",
"symfony/runtime": "6.4.*",
"symfony/serializer": "6.4.*",
"symfony/validator": "6.4.*",
"symfony/yaml": "6.4.*",
"symfony/dotenv": "7.2.*",
"symfony/expression-language": "7.2.*",
"symfony/framework-bundle": "7.2.*",
"symfony/messenger": "7.2.*",
"symfony/property-info": "7.2.*",
"symfony/runtime": "7.2.*",
"symfony/serializer": "7.2.*",
"symfony/validator": "7.2.*",
"symfony/yaml": "7.2.*",
"ext-simplexml": "*",
"symfony/security-bundle": "^6.4",
"symfony/finder": "^6.4"
"symfony/security-bundle": "7.2.*",
"symfony/finder": "7.2.*"
},
"require-dev": {
"symfony/browser-kit": "6.4.*",
"symfony/css-selector": "6.4.*",
"symfony/console": "6.4.*",
"symfony/phpunit-bridge": "^6.4",
"symfony/browser-kit": "7.2.*",
"symfony/css-selector": "7.2.*",
"symfony/console": "7.2.*",
"symfony/phpunit-bridge": "7.2.*",
"symfony/test-pack": "^1.1"
},
"prefer-stable": true,
Expand All @@ -48,7 +48,7 @@
"dev-master": "1.0-dev"
},
"symfony": {
"require": "6.4.*"
"require": "7.2.*"
}
},
"conflict": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Locastic\Loggastic\Metadata\LoggableContext\Factory;

use Doctrine\Common\Annotations\Reader;
use Locastic\Loggastic\Annotation\Loggable;
use Locastic\Loggastic\Metadata\LoggableContext\LoggableContextCollection;
use Locastic\Loggastic\Util\RecursiveClassIterator;
Expand All @@ -12,9 +11,10 @@ final class AnnotationLoggableContextCollectionFactory implements LoggableContex
/**
* @param string[] $loggablePaths
*/
public function __construct(private readonly LoggableContextCollectionFactoryInterface $decorated, private readonly Reader $reader, private readonly array $loggablePaths)
{
}
public function __construct(
private readonly LoggableContextCollectionFactoryInterface $decorated,
private readonly array $loggablePaths
) {}

public function create(): LoggableContextCollection
{
Expand All @@ -34,10 +34,6 @@ public function create(): LoggableContextCollection
if ($loggable = $this->getLoggableAttribute($reflectionClass)) {
$classes[$className] = ['groups' => $loggable->getGroups()];
}

if (null !== $this->reader && $loggable = $this->reader->getClassAnnotation($reflectionClass, Loggable::class)) {
$classes[$className] = $loggable->getGroups();
}
}

return new LoggableContextCollection($classes);
Expand All @@ -53,4 +49,4 @@ private function getLoggableAttribute(\ReflectionClass $reflectionClass): ?Logga

return null;
}
}
}
1 change: 0 additions & 1 deletion src/Resources/config/loggable_context.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ services:
decorates: 'locastic_activity_log.metadata.loggable.context_collection_factory'
arguments:
- '@.inner'
- '@annotations.reader'
- '%locastic_activity_log.dir.loggable_classes%'

Locastic\Loggastic\Metadata\LoggableContext\Factory\LoggableContextFactoryInterface:
Expand Down
5 changes: 5 additions & 0 deletions src/Serializer/ActivityLogCollectionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ public function supportsNormalization($data, string $format = null, array $conte
{
return $data instanceof Collection && self::FORMAT === $format;
}

public function getSupportedTypes(?string $format): array
{
return [];
}
}
16 changes: 12 additions & 4 deletions src/Util/ArrayDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ public static function arrayDiffRecursive($array1, $array2): array
foreach ($array1 as $key => $value) {
if (is_array($array2) && array_key_exists($key, $array2)) {
if (is_array($value)) {
$recursiveDiff = self::arrayDiffRecursive($value, $array2[$key]);
if (count($recursiveDiff)) {
$return[$key] = $recursiveDiff;
if (isset($value['id'])) {
$id = $value['id'];
$recursiveDiff = self::arrayDiffRecursive($value, $array2[$key] ?? []);
if (count($recursiveDiff)) {
$return[$id] = $recursiveDiff;
}
} else {
$recursiveDiff = self::arrayDiffRecursive($value, $array2[$key]);
if (count($recursiveDiff)) {
$return[$key] = $recursiveDiff;
}
}
} else {
if ($value != $array2[$key]) {
Expand All @@ -27,4 +35,4 @@ public static function arrayDiffRecursive($array1, $array2): array

return $return;
}
}
}
16 changes: 7 additions & 9 deletions tests/Fixtures/app/Model/DummyBlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,27 @@
use Locastic\Loggastic\Annotation\Loggable;
use Symfony\Component\Serializer\Annotation\Groups;

/**
* @Loggable(groups={"dummy_blog_post_log"})
*/
#[Loggable(groups: ["dummy_blog_post_log"])]
class DummyBlogPost
{
private int $id;

/** @Groups({"dummy_blog_post_log"}) */
#[Groups(["dummy_blog_post_log"])]
private ?string $title;

/** @Groups({"dummy_blog_post_log"}) */
#[Groups(["dummy_blog_post_log"])]
private array $tags = [];

/** @Groups({"dummy_blog_post_log"}) */
#[Groups(["dummy_blog_post_log"])]
private int $position = 0;

/** @Groups({"dummy_blog_post_log"}) */
#[Groups(["dummy_blog_post_log"])]
private ?\DateTime $publishAt;

/** @Groups({"dummy_blog_post_log"}) */
#[Groups(["dummy_blog_post_log"])]
private bool $enabled;

/** @Groups({"dummy_blog_post_log"}) */
#[Groups(["dummy_blog_post_log"])]
private Collection $photos;

public function __construct()
Expand Down
5 changes: 2 additions & 3 deletions tests/FunctionalTests/ActivityLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@ public function testLogEdit(): void
$this->activityLogger->logUpdatedItem($this->blogPost);

$activityLogs = $this->activityLogProvider->getActivityLogsByClassAndId(DummyBlogPost::class, 15);

self::assertCount(4, $activityLogs);

$editedLog = $activityLogs[3];
$editedLog = end($activityLogs);

self::assertInstanceOf(ActivityLogInterface::class, $editedLog);
self::assertEquals(ActivityLogAction::EDITED, $editedLog->getAction());
Expand Down Expand Up @@ -193,7 +192,7 @@ public function testProviderByClassAndIndexLimitAndOffset(): void
{
$activityLogs = $this->activityLogProvider->getActivityLogsByIndexAndId('dummy_blog_post_activity_log',15, [],20, 3);

$editedLog = $activityLogs[0];
$editedLog = reset($activityLogs);

self::assertCount(1, $activityLogs);
self::assertInstanceOf(ActivityLogInterface::class, $editedLog);
Expand Down
Loading