PHPackages                             teamneusta/pimcore-toolbox-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. teamneusta/pimcore-toolbox-bundle

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

teamneusta/pimcore-toolbox-bundle
=================================

Tools &amp; helpers for Pimcore development

00[1 PRs](https://github.com/teamneusta/pimcore-toolbox-bundle/pulls)PHPCI failing

Since Mar 17Pushed 1y ago8 watchersCompare

[ Source](https://github.com/teamneusta/pimcore-toolbox-bundle)[ Packagist](https://packagist.org/packages/teamneusta/pimcore-toolbox-bundle)[ RSS](/packages/teamneusta-pimcore-toolbox-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Pimcore Toolbox Bundle
======================

[](#pimcore-toolbox-bundle)

Provides common helper classes useful for Pimcore development.

\[\[*TOC*\]\]

Installation
------------

[](#installation)

1. **Require the bundle**

    ```
    composer require teamneusta/pimcore-toolbox-bundle
    ```
2. **Enable the bundle**

    Add the bundle to your `config/bundles.php`:

    ```
    Neusta\Pimcore\ToolboxBundle\PimcoreToolboxBundle::class => ['all' => true],
    ```

Available helpers
-----------------

[](#available-helpers)

Currently, there are some static helpers that aid with versioning, inheritance and access to unpublished assets, data objects and documents.

While Pimcore itself only allows to globally enable/disable those features and resetting them to the previous state after the operation is a repetitive and boring task, these helpers will take care of it – you just have to pass a callable with the desired operations.

### Cache (assets, document, data objects)

[](#cache-assets-document-data-objects)

This helper allows executing your operations with enabled/disabled cache:

```
$fetchObject = fn () => Pimcore\Model\DataObject::getById(123);

$object = Neusta\Pimcore\ToolboxBundle\Cache::withEnabledCache($fetchObject);
$object = Neusta\Pimcore\ToolboxBundle\Cache::withDisabledCache($fetchObject);
```

You may pass as many arguments as you want to the callable:

```
class ObjectRepository {
    public function fetch(int $objectId) {
        return Pimcore\Model\DataObject::getById($objectId);
    }
}

$object = Neusta\Pimcore\ToolboxBundle\Cache::withEnabledCache([new ObjectRepository(), 'fetch'], 123, 'data');
$object = Neusta\Pimcore\ToolboxBundle\Cache::withEnabledCache([new ObjectRepository(), 'fetch'], 123, 'data');
```

### Versioning (assets, document, data objects)

[](#versioning-assets-document-data-objects)

This helper allows executing your operations with enabled/disabled versioning:

```
$object = Pimcore\Model\DataObject::getById(123);
$object->setSomeData('data');

$saveObject = fn () => $object->save();

Neusta\Pimcore\ToolboxBundle\Versioning::withVersioning($saveObject);
Neusta\Pimcore\ToolboxBundle\Versioning::withoutVersioning($saveObject);
```

You may pass as many arguments as you want to the callable:

```
class ObjectManipulator {
    public function manipulateObject(int $id, string $data): bool {
        $object = Pimcore\Model\DataObject::getById($id);
        $object->setSomeData($data);

        try {
            $object->save();
        } catch (\Throwable $e) {
            return false;
        }

        return true;
    }
}

$success = Neusta\Pimcore\ToolboxBundle\Versioning::withVersioning([new ObjectManipulator(), 'manipulateObject'], 123, 'data');
$success = Neusta\Pimcore\ToolboxBundle\Versioning::withoutVersioning([new ObjectManipulator(), 'manipulateObject'], 123, 'data');
```

### Commands

[](#commands)

Sometimes you have several commands which have been implemented separately for reasons of Separation of Concerns, but in a work environment you need to run them together.

This helper allows you to run several commands in one go.

```
  my.batch.command:
      class: Neusta\Pimcore\ToolboxBundle\Command\BatchCommand
      arguments:
          $name: 'all:my:commands'
          $commands:
              - command: 'my:command:1'
              - command: 'my:command:2'
              - command: 'my:command:3'
                arguments:
                    arg1: 'value1'
                    arg2: 'value2'
                options:
                    --option1: 'value1'
                    --option2: 'value2'
      tags: [ 'console.command' ]
```

And after that you can run: `bin/console all:my:commands`

### Inheritance (data objects)

[](#inheritance-data-objects)

This helper allows executing your operations with enabled/disabled inheritance:

```
$object = Pimcore\Model\DataObject::getById(123);

$getData = fn () => $object->getSomeData();

$data = Neusta\Pimcore\ToolboxBundle\DataObject\Inheritance::withInheritedValues($getData);
$data = Neusta\Pimcore\ToolboxBundle\DataObject\Inheritance::withoutInheritedValues($getData);
```

You may pass as many arguments as you want to the callable:

```
class DataProvider {
    public function fetchData(int $objectId) {
        return Pimcore\Model\DataObject::getById($objectId)->getSomeData();
    }
}

$data = Neusta\Pimcore\ToolboxBundle\DataObject\Inheritance::withInheritedValues([new DataProvider(), 'fetchData'], 123);
$data = Neusta\Pimcore\ToolboxBundle\DataObject\Inheritance::withoutInheritedValues([new DataProvider(), 'fetchData'], 123);
```

### Localized field (data objects)

[](#localized-field-data-objects)

This helper allows executing your operations with enabled/disabled fallback values:

```
$object = Pimcore\Model\DataObject::getById(123);

$getSomeLocalizedField = fn () => $object->getSomeLocalizedField();

$data = Neusta\Pimcore\ToolboxBundle\DataObject\LocalizedField::withFallbackValues($getSomeLocalizedField);
$data = Neusta\Pimcore\ToolboxBundle\DataObject\LocalizedField::withoutFallbackValues($getSomeLocalizedField);
```

You may pass as many arguments as you want to the callable:

```
class DataProvider {
    public function fetchData(int $objectId) {
        return Pimcore\Model\DataObject::getById($objectId)->getSomeLocalizedField();
    }
}

$data = Neusta\Pimcore\ToolboxBundle\DataObject\LocalizedField::withFallbackValues([new DataProvider(), 'fetchData'], 123);
$data = Neusta\Pimcore\ToolboxBundle\DataObject\LocalizedField::withoutFallbackValues([new DataProvider(), 'fetchData'], 123);
```

### Publishing (data objects)

[](#publishing-data-objects)

This helper allows executing your operations with inclusion/exclusion of unpublished objects.

```
$getObjects = fn () => (new Pimcore\Model\DataObject\Listing())->getObjects();

$objects = Neusta\Pimcore\ToolboxBundle\DataObject\Publishing::withUnpublishedObjects($getObjects);
$objects = Neusta\Pimcore\ToolboxBundle\DataObject\Publishing::withoutUnpublishedObjects($getObjects);
```

You may pass as many arguments as you want to the callable:

```
class ObjectRepository {
    public function findByCondition(string $value): array {
        $listing = new Pimcore\Model\DataObject\Listing();
        $listing->setCondition('some_row = ?', [$value]);

        return $listing->getObjects();
    }
}

$objects = Neusta\Pimcore\ToolboxBundle\DataObject\Publishing::withUnpublishedObjects([new ObjectRepository(), 'findByCondition'], 'value');
$objects = Neusta\Pimcore\ToolboxBundle\DataObject\Publishing::withoutUnpublishedObjects([new ObjectRepository(), 'findByCondition'], 'value');
```

### Publishing (documents)

[](#publishing-documents)

This helper allows executing your operations with inclusion/exclusion of unpublished documents.

```
$getDocuments = fn () => (new Pimcore\Model\Document\Listing())->getDocuments();

$documents = Neusta\Pimcore\ToolboxBundle\Document\Publishing::withUnpublishedDocuments($getDocuments);
$documents = Neusta\Pimcore\ToolboxBundle\Document\Publishing::withoutUnpublishedDocuments($getDocuments);
```

You may pass as many arguments as you want to the callable:

```
class DocumentRepository {
    public function findByCondition(string $value): array {
        $listing = new Pimcore\Model\Document\Listing();
        $listing->setCondition('some_row = ?', [$value]);

        return $listing->getDocuments();
    }
}

$documents = Neusta\Pimcore\ToolboxBundle\Document\Publishing::withUnpublishedDocuments([new DocumentRepository(), 'findByCondition'], 'value');
$documents = Neusta\Pimcore\ToolboxBundle\Document\Publishing::withoutUnpublishedDocuments([new DocumentRepository(), 'findByCondition'], 'value');
```

### [Repositories (assets, document, data objects)](docs/repositories.md)

[](#repositories-assets-document-data-objects)

### [Wrapper for static methods](docs/wrappers.md)

[](#wrapper-for-static-methods)

### [Classification Values](docs/classification.md)

[](#classification-values)

### File Size Calculation

[](#file-size-calculation)

Sometimes you need the size of an asset or an image; i.e. the size of the physical file behind this elements.

Therefore, we offer a new Service called `Neusta\Pimcore\ToolboxBundle\Service\FileSizeService`. This service offers a method called `getFileSize` which returns the size of the file in bytes.

But as you can read [here](https://en.wikipedia.org/wiki/Byte#Multiple-byte_units) it is not that easy. You can decide if you want to get the size of the file in bytes, kilobytes, megabytes or gigabytes or use IEC compatible units (KiB, MiB, GiB).

Using helpers in migration classes
----------------------------------

[](#using-helpers-in-migration-classes)

Create a public alias for the service you need:

```
# config/services.yaml
services:
    # ...

    app.toolbox.select_factory:
        alias: Neusta\Pimcore\ToolboxBundle\Factory\SelectFactory
        public: true
```

Implement the `ContainerAwareInterface` and use the `ContainerAwareTrait`. Now you can fetch the service:

```
// ...

final class Version20770101141207 extends AbstractMigration implements ContainerAwareInterface
{
    use ContainerAwareTrait;

    public function up(Schema $schema): void
    {
        $factory = $this->container->get('app.toolbox.select_factory');

        // ...
    }

    // ...
}
```

Keep in mind that this approach is deprecated since Symfony 6.4 and won't work with Symfony 7, but there isn't really
a replacement at the moment (see: [doctrine/DoctrineMigrationsBundle#521](https://github.com/doctrine/DoctrineMigrationsBundle/issues/521)).

Contribution
------------

[](#contribution)

Feel free to open issues for any bug, feature request, or other ideas.

Please remember to create an issue before creating large pull requests.

### Local Development

[](#local-development)

To develop on a local machine, the vendor dependencies are required.

```
bin/composer install
```

We use composer scripts for our main quality tools. They can be executed via the `bin/composer` file as well.

```
bin/composer cs:fix
bin/composer phpstan
```

For the tests there is a different script, that includes a database setup.

```
bin/run-tests
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12913211?v=4)[team neusta SE](/maintainers/teamneusta)[@teamneusta](https://github.com/teamneusta)

---

Top Contributors

[![lukadschaak](https://avatars.githubusercontent.com/u/2377363?v=4)](https://github.com/lukadschaak "lukadschaak (1 commits)")

### Embed Badge

![Health badge](/badges/teamneusta-pimcore-toolbox-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/teamneusta-pimcore-toolbox-bundle/health.svg)](https://phpackages.com/packages/teamneusta-pimcore-toolbox-bundle)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
