Storage Manager Component

v3.1 2020-07-29 12:52 UTC

This package is auto-updated.

Last update: 2021-03-29 00:38:47 UTC



To provide an easy way to store data with references to proxies, without storing the proxies themselves. A deep copy of the original object is made, in which any proxies will be turned into a StorableEntity, which contains only the proxy class name and it's identifiers. These will be used to retrieve a managed proxy upon load().


composer require aeviiq/storage-manager


With the Symfony service container
// config/services.yml
    shared: false

Aeviiq\StorageManager\StorageManagerInterface: '@Aeviiq\StorageManager\StorageManager'
    autowire: true


final class FooController
     * @var StorageManagerInterface
    private $storageManager;

    public function __construct(StorageManagerInterface $storageManager)
        $this->storageManager = $storageManager;

    public function step1(Request $request, EntityManagerInterface $em): Response
        $repository = $em->getRepository(Foo::class);
        $foo = $repository->find(1);
        $bar = new Bar('some value', 1234, $foo);
        $this->storageManager->save('some_key', $bar);
        // A copy of $bar is saved and the entity is converted to a StorableEntity.
        // The actual entity/proxy itself does not get saved into the session.
        // $bar is untouched and can be used like normal.
        // Any changes done to $bar after the save() will not be stored without
        // and explicit save() call.

        return new Response('Some response.');

    public function step2(Request $request): Response
        // $bar will have all last saved values and $foo will be a managed entity.
        $bar = $this->storageManager->load('some_key');