Skip to content
Open
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
752 changes: 595 additions & 157 deletions LICENSE.md

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
# Pimcore VersionDiffBundle
# OpenDXP VersionDiffBundle

A small Pimcore bundle that compares Pimcore `Version` snapshots and builds structured diffs for DataObjects.
A small OpenDXP bundle that compares OpenDXP `Version` snapshots and builds structured diffs for DataObjects.

**Note:** This README file was generated using AI. The code was done by a human.

## Requirements

- PHP 8.3+
- Pimcore `>=12.0 <13.0 || ^2026.1.6`
- OpenDXP `>=12.0 <13.0 || ^2026.1.6`

## Installation

```bash
composer require saitho/pimcore-versiondiff-bundle
```

The bundle class can be enabled in `config/bundles.php` or via the Pimcore extension manager, but this is **optional** — the utility classes are usable as soon as Composer autoloads the package.
The bundle class can be enabled in `config/bundles.php` or via the OpenDXP extension manager, but this is **optional** — the utility classes are usable as soon as Composer autoloads the package.

## What it does

The bundle provides utilities to:

- Load Pimcore versions by element ID / ctype.
- Load OpenDXP versions by element ID / ctype.
- Find the previous version of a given `Version`.
- Build recursive diffs between two arbitrary objects or arrays.
- Build Pimcore DataObject-aware diffs that ignore version metadata and normalize object relations.
- Build OpenDXP DataObject-aware diffs that ignore version metadata and normalize object relations.
- Group version diffs by date and cache the result.

## Main components

| Class | Purpose |
|-------|---------|
| `VersionDiffBundle` | Empty Pimcore bundle registration class. |
| `Utility\VersionUtility` | Fetch versions and resolve the previous version of a `Pimcore\Model\Version`. |
| `VersionDiffBundle` | Empty OpenDXP bundle registration class. |
| `Utility\VersionUtility` | Fetch versions and resolve the previous version of a `OpenDxp\Model\Version`. |
| `Utility\DiffUtility` | Recursively diff arrays / objects into an array of changed values. |
| `Utility\DataObjectUtility` | Pimcore DataObject-specific diff helpers. |
| `Utility\DataObjectUtility` | OpenDXP DataObject-specific diff helpers. |
| `Model\VersionResult` | Wrapper around a list of `Version` instances with grouping helpers. |
| `Model\VersionDiff` | Generic diff result: old data, new data, diff array. |
| `Model\DataObjectVersionDiff` | VersionDiff for `DataObject\Concrete` with `wasPublished()` / `wasUnpublished()` helpers. |
Expand All @@ -44,7 +44,7 @@ The bundle provides utilities to:
### Diff a DataObject against its previous version

```php
use Pimcore\Model\Version;
use OpenDxp\Model\Version;
use Saitho\VersionDiffBundle\Utility\DataObjectUtility;

/** @var Version $version */
Expand Down Expand Up @@ -101,16 +101,16 @@ Nested objects and arrays are diffed recursively. Added keys show `null` as the

## DataObject-specific behavior

`DataObjectUtility::getDiff()` performs a few Pimcore-specific normalizations before diffing:
`DataObjectUtility::getDiff()` performs a few OpenDXP-specific normalizations before diffing:

- Ignores internal version fields: `__dataVersionTimestamp`, `modificationDate`, `versionCount`.
- Ignores Carbon's `constructedObjectId`.
- Re-keys object relations by the related object's ID so array diffs stay stable.

## Caching

`DataObjectUtility::getDiffGroupedByDate()` writes results to Pimcore's `Cache` under the tag `versionDiff`. Pass additional cache tags if you want to invalidate the cache together with other application data.
`DataObjectUtility::getDiffGroupedByDate()` writes results to OpenDXP's `Cache` under the tag `versionDiff`. Pass additional cache tags if you want to invalidate the cache together with other application data.

## License

This bundle is licensed under the Pimcore Open Core License (POCL). See [LICENSE.md](LICENSE.md).
This bundle is licensed under the OpenDXP Open Core License (POCL). See [LICENSE.md](LICENSE.md).
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "saitho/pimcore-versiondiff-bundle",
"name": "saitho/opendxp-versiondiff-bundle",
"require": {
"pimcore/pimcore": ">=12.0 <13.0 || ^2026.1.6"
"open-dxp/opendxp": "^1.0.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Model/DataObjectVersionDiff.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Saitho\VersionDiffBundle\Model;

use Pimcore\Model\DataObject\Concrete;
use OpenDxp\Model\DataObject\Concrete;

/**
* @extends VersionDiff<Concrete>
Expand Down
2 changes: 1 addition & 1 deletion src/Model/VersionResult.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Saitho\VersionDiffBundle\Model;

use Pimcore\Model\Version;
use OpenDxp\Model\Version;

class VersionResult
{
Expand Down
8 changes: 4 additions & 4 deletions src/Utility/DataObjectUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
namespace Saitho\VersionDiffBundle\Utility;

use Carbon\Carbon;
use Pimcore\Cache;
use Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\Version;
use OpenDxp\Cache;
use OpenDxp\Model\DataObject;
use OpenDxp\Model\DataObject\Concrete;
use OpenDxp\Model\Version;
use Saitho\VersionDiffBundle\Model\DataObjectVersionDiff;
use Saitho\VersionDiffBundle\Model\VersionResult;

Expand Down
2 changes: 1 addition & 1 deletion src/Utility/VersionUtility.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Saitho\VersionDiffBundle\Utility;

use Pimcore\Model\Version;
use OpenDxp\Model\Version;
use Saitho\VersionDiffBundle\Model\VersionResult;

class VersionUtility
Expand Down
4 changes: 2 additions & 2 deletions src/VersionDiffBundle.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace Saitho\VersionDiffBundle;

use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
use OpenDxp\Extension\Bundle\AbstractOpenDxpBundle;

class VersionDiffBundle extends AbstractPimcoreBundle
class VersionDiffBundle extends AbstractOpenDxpBundle
{
}