lazy example


namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use App\BarService;

return function DContainerConfigurator $c) {
    $c->services()
        ->set('bar', 'Class1')->public()
        ->set(BarService::class)
            ->public()
            ->abstract(true)
            ->lazy()
        ->set('foo')
            ->parent(BarService::class)
            ->public()
            ->decorate('bar', 'b', 1)
            ->args([service('b')])
            ->class('Class2')
            ->file('file.php')
            ->parent('bar')
            ->parent(BarService::class)
    ;
};
$stored[OrderTransactionAware::ORDER_TRANSACTION_ID] = $event->getOrderTransactionId();

        return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(OrderTransactionAware::ORDER_TRANSACTION_ID)) {
            return;
        }

        $storable->lazy(
            OrderTransactionAware::ORDER_TRANSACTION,
            $this->lazyLoad(...)
        );
    }

    /** * @param array<int, mixed> $args * * @deprecated tag:v6.6.0 - Will be removed in v6.6.0.0 */
    public function load(array $args): ?OrderTransactionEntity
    {
$stored[ProductAware::PRODUCT_ID] = $event->getProductId();

        return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(ProductAware::PRODUCT_ID)) {
            return;
        }

        $storable->lazy(
            ProductAware::PRODUCT,
            $this->lazyLoad(...)
        );
    }

    /** * @param array<int, mixed> $args * * @deprecated tag:v6.6.0 - Will be removed in v6.6.0.0 */
    public function load(array $args): ?ProductEntity
    {
return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(CustomerGroupAware::CUSTOMER_GROUP_ID)) {
            return;
        }

        $storable->setData(CustomerGroupAware::CUSTOMER_GROUP_ID, $storable->getStore(CustomerGroupAware::CUSTOMER_GROUP_ID));

        $storable->lazy(
            CustomerGroupAware::CUSTOMER_GROUP,
            $this->lazyLoad(...)
        );
    }

    /** * @param array<int, mixed> $args * * @deprecated tag:v6.6.0 - Will be removed in v6.6.0.0 */
    public function load(array $args): ?CustomerGroupEntity
    {
$stored[CustomerRecoveryAware::CUSTOMER_RECOVERY_ID] = $event->getCustomerRecoveryId();

        return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(CustomerRecoveryAware::CUSTOMER_RECOVERY_ID)) {
            return;
        }

        $storable->lazy(
            CustomerRecoveryAware::CUSTOMER_RECOVERY,
            $this->lazyLoad(...)
        );
    }

    /** * @param array<int, mixed> $args * * @deprecated tag:v6.6.0 - Will be removed in v6.6.0.0 */
    public function load(array $args): ?CustomerRecoveryEntity
    {
$stored[UserAware::USER_RECOVERY_ID] = $event->getUserId();

        return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(UserAware::USER_RECOVERY_ID)) {
            return;
        }

        $storable->lazy(
            UserAware::USER_RECOVERY,
            $this->lazyLoad(...)
        );
    }

    /** * @param array<int, mixed> $args * * @deprecated tag:v6.6.0 - Will be removed in v6.6.0.0 */
    public function load(array $args): ?UserRecoveryEntity
    {
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\ChoiceList\ChoiceList;
use Symfony\Component\OptionsResolver\OptionsResolver;

class LazyChoiceTypeExtension extends AbstractTypeExtension
{
    public static $extendedType;

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefault('choice_loader', ChoiceList::lazy($thisfn () => [
            'Lazy A' => 'lazy_a',
            'Lazy B' => 'lazy_b',
        ]));
    }

    public static function getExtendedTypes(): iterable
    {
        return [self::$extendedType];
    }
}

            ->tag('controller.argument_value_resolver', ['priority' => 100, 'name' => DateTimeValueResolver::class])

        ->set('argument_resolver.request_payload', RequestPayloadValueResolver::class)
            ->args([
                service('serializer'),
                service('validator')->nullOnInvalid(),
                service('translator')->nullOnInvalid(),
            ])
            ->tag('controller.targeted_value_resolver', ['name' => RequestPayloadValueResolver::class])
            ->tag('kernel.event_subscriber')
            ->lazy()

        ->set('argument_resolver.request_attribute', RequestAttributeValueResolver::class)
            ->tag('controller.argument_value_resolver', ['priority' => 100, 'name' => RequestAttributeValueResolver::class])

        ->set('argument_resolver.request', RequestValueResolver::class)
            ->tag('controller.argument_value_resolver', ['priority' => 50, 'name' => RequestValueResolver::class])

        ->set('argument_resolver.session', SessionValueResolver::class)
            ->tag('controller.argument_value_resolver', ['priority' => 50, 'name' => SessionValueResolver::class])

        ->set('argument_resolver.service', ServiceValueResolver::class)
            
$di->load(Prototype::class.'\\', '../Prototype')
        ->public()
        ->autoconfigure()
        ->exclude('../Prototype/{OtherDir,BadClasses,SinglyImplementedInterface,StaticConstructor}')
        ->factory('f')
        ->deprecate('vendor/package', '1.1', '%service_id%')
        ->args([0])
        ->args([1])
        ->autoconfigure(false)
        ->tag('foo')
        ->parent('foo');
    $di->set('foo')->lazy()->abstract()->public();
    $di->get(Prototype\Foo::class)->lazy(false);
};
use App\FooService;
use Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype;

return function DContainerConfigurator $c) {
    $s = $c->services()->defaults()->public();
    $s->instanceof(Prototype\Foo::class)
        ->property('p', 0)
        ->call('setFoo', [service('foo')])
        ->tag('tag', ['k' => 'v'])
        ->share(false)
        ->lazy()
        ->configurator('c')
        ->property('p', 1);

    $s->load(Prototype::class.'\\', '../Prototype')->exclude('../Prototype/*/*');

    $s->set('foo', FooService::class);
};
return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(OrderAware::ORDER_ID)) {
            return;
        }

        $storable->setData(OrderAware::ORDER_ID, $storable->getStore(OrderAware::ORDER_ID));

        $storable->lazy(
            OrderAware::ORDER,
            $this->lazyLoad(...)
        );
    }

    /** * @param array<int, mixed> $args * * @deprecated tag:v6.6.0 - Will be removed in v6.6.0.0 */
    public function load(array $args): ?OrderEntity
    {
return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(CustomerAware::CUSTOMER_ID)) {
            return;
        }

        $storable->setData(CustomerAware::CUSTOMER_ID, $storable->getStore(CustomerAware::CUSTOMER_ID));

        $storable->lazy(
            CustomerAware::CUSTOMER,
            $this->lazyLoad(...)
        );
    }

    /** * @param array<int, mixed> $args * * @deprecated tag:v6.6.0 - Will be removed in v6.6.0.0 */
    public function load(array $args): ?CustomerEntity
    {
<?php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return function DContainerConfigurator $c) {
    $di = $c->services()->defaults()->public();
    $di->set('foo', 'stdClass')->lazy('SomeInterface');
};
$di->load(Prototype::class.'\\', '../Prototype')
        ->public()
        ->autoconfigure()
        ->exclude(['../Prototype/OtherDir', '../Prototype/BadClasses', '../Prototype/SinglyImplementedInterface', '../Prototype/StaticConstructor'])
        ->factory('f')
        ->deprecate('vendor/package', '1.1', '%service_id%')
        ->args([0])
        ->args([1])
        ->autoconfigure(false)
        ->tag('foo')
        ->parent('foo');
    $di->set('foo')->lazy()->abstract()->public();
    $di->get(Prototype\Foo::class)->lazy(false);
};
$stored[NewsletterRecipientAware::NEWSLETTER_RECIPIENT_ID] = $event->getNewsletterRecipientId();

        return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(NewsletterRecipientAware::NEWSLETTER_RECIPIENT_ID)) {
            return;
        }

        $storable->lazy(
            NewsletterRecipientAware::NEWSLETTER_RECIPIENT,
            $this->lazyLoad(...)
        );
    }

    /** * @param array<int, mixed> $args * * @deprecated tag:v6.6.0 - Will be removed in v6.6.0.0 */
    public function load(array $args): ?NewsletterRecipientEntity
    {
Home | Imprint | This part of the site doesn't use cookies.