D
D
Daria Motorina2020-06-23 20:38:32
symfony
Daria Motorina, 2020-06-23 20:38:32

How to install lazy load for League\Flysystem\Adapter\Local service?

Hey!
Please tell me how to solve this problem correctly.
Symfony 5.0, dev env, package 1up-lab/OneupFlysystemBundle .
I want to set lazy loading for League\Flysystem\Adapter\Local, but it doesn't work.
Checking class_implements($filesystem) doesn't show proxy interfaces, checking via bin/console debug:container doesn't change anything either.

#config/services.yaml
services:
    _defaults:
        autowire: true
        autoconfigure: true
        bind:
            $filesystem: '@oneup_flysystem.local_filesystem_adapter'
    #other stuff
    League\Flysystem\Adapter\Local:
        lazy: true

Installed symfony/proxy-manager-bridge and ocramius/proxy-manager in advance, cleaned var/cache.
Different configuration options give errors:
- replacing a class with an alias:
The definition for "oneup_flysystem.local_filesystem_adapter" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.

- adding an alias to class parameters:
The configuration key "lazy" is unsupported for the service "League\Flysystem\Adapter\Local" which is defined as an alias in "/app/config/services.yaml". Allowed configuration keys for service ali  
  ases are "alias", "public" and "deprecated" in /app/config/services.yaml (which is loaded in resource "/app/config/services.yaml").

I understand that I'm setting up the service incorrectly, but I'm confused about which side to approach it from.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2020-06-23
@glaphire

// App\Kernel
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
    // ...
    $container->addCompilerPass(new class implements CompilerPassInterface {
        public function process(ContainerBuilder $container)
        {
            $container->getDefinition('oneup_flysystem.adapter.local')->setLazy(true);
        }
    });
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question