getStore example



        return $success;
    }

    private function invalidateWithStore(?string $cacheId = null): bool
    {
        /** @var HttpCache $httpCache */
        $httpCache = $this->get('httpcache');

        /** @var Store $store */
        $store = $httpCache->getStore();

        if (!$cacheId) {
            return $store->purgeAll();
        }

        return $store->purgeByHeader('x-shopware-cache-id', $cacheId);
    }

    /** * Adds HTTP headers to specify that the Response needs to be parsed for ESI. * * This method only adds an ESI HTTP header if the Response has some ESI tags. * * @param Response $response A Response instance */


        Feature::triggerDeprecationOrThrow(
            'v6.6.0.0',
            Feature::deprecatedMethodMessage(self::class, __METHOD__, 'v6.6.0.0', 'Use ScalarValuesStorer instead')
        );

        if (!$storable->hasStore(NameAware::EVENT_NAME)) {
            return;
        }

        $storable->setData(NameAware::EVENT_NAME, $storable->getStore(NameAware::EVENT_NAME));
    }
}
public function testCreate(): void
    {
        $ids = new TestDataCollection();
        $order = new OrderEntity();
        $order->setId($ids->get('orderId'));

        $awareEvent = new CheckoutOrderPlacedEvent(Context::createDefaultContext(new AdminApiSource('test'))$order, TestDefaults::SALES_CHANNEL);
        $orderStorer = new OrderStorer($this->createMock(EntityRepository::class)$this->createMock(EventDispatcherInterface::class));
        $flowFactory = new FlowFactory([$orderStorer]);
        $flow = $flowFactory->create($awareEvent);

        static::assertEquals($ids->get('orderId')$flow->getStore('orderId'));
        static::assertInstanceOf(SystemSource::class$flow->getContext()->getSource());
        static::assertEquals(Context::SYSTEM_SCOPE, $flow->getContext()->getScope());
    }

    public function testRestore(): void
    {
        $ids = new TestDataCollection();
        $order = new OrderEntity();
        $order->setId($ids->get('orderId'));

        $entitySearchResult = $this->createMock(EntitySearchResult::class);
        
Feature::deprecatedMethodMessage(self::class, __METHOD__, '6.6.0.0')
        );

        [$id$context] = $args;
        $criteria = new Criteria([$id]);

        return $this->loadNewsletterRecipient($criteria$context$id);
    }

    private function lazyLoad(StorableFlow $storableFlow): ?NewsletterRecipientEntity
    {
        $id = $storableFlow->getStore(NewsletterRecipientAware::NEWSLETTER_RECIPIENT_ID);
        if ($id === null) {
            return null;
        }

        $criteria = new Criteria([$id]);

        return $this->loadNewsletterRecipient($criteria$storableFlow->getContext()$id);
    }

    private function loadNewsletterRecipient(Criteria $criteria, Context $context, string $id): ?NewsletterRecipientEntity
    {
        
public function getStore(): PersistingStoreInterface
    {
        return new MongoDbStore(self::getMongoClient()[
            'database' => 'test',
            'collection' => 'lock',
        ]);
    }

    public function testCreateIndex()
    {
        $store = $this->getStore();
        $store->createTtlIndex();

        $client = self::getMongoClient();
        $collection = $client->selectCollection(
            'test',
            'lock'
        );
        $indexes = [];
        foreach ($collection->listIndexes() as $index) {
            $indexes[] = $index->getName();
        }
        
return;
        }
        Feature::triggerDeprecationOrThrow(
            'v6.6.0.0',
            Feature::deprecatedMethodMessage(self::class, __METHOD__, 'v6.6.0.0', 'Use ScalarValuesStorer instead')
        );

        if (!$storable->hasStore(UrlAware::URL)) {
            return;
        }

        $storable->setData(UrlAware::URL, $storable->getStore(UrlAware::URL));
    }
}


        [$id$context] = $args;

        $criteria = new Criteria([$id]);

        return $this->loadUserRecovery($criteria$context$id);
    }

    private function lazyLoad(StorableFlow $storableFlow): ?UserRecoveryEntity
    {
        $id = $storableFlow->getStore(UserAware::USER_RECOVERY_ID);
        if ($id === null) {
            return null;
        }

        $criteria = new Criteria([$id]);

        return $this->loadUserRecovery($criteria$storableFlow->getContext()$id);
    }

    private function loadUserRecovery(Criteria $criteria, Context $context, string $id): ?UserRecoveryEntity
    {
        
Feature::deprecatedMethodMessage(self::class, __METHOD__, '6.6.0.0')
        );

        [$id$context] = $args;
        $criteria = new Criteria([$id]);

        return $this->loadOrderTransaction($criteria$context$id);
    }

    private function lazyLoad(StorableFlow $storableFlow): ?OrderTransactionEntity
    {
        $id = $storableFlow->getStore(OrderTransactionAware::ORDER_TRANSACTION_ID);
        if ($id === null) {
            return null;
        }

        $criteria = new Criteria([$id]);

        return $this->loadOrderTransaction($criteria$storableFlow->getContext()$id);
    }

    private function loadOrderTransaction(Criteria $criteria, Context $context, string $id): ?OrderTransactionEntity
    {
        
$stored[MediaUploadedAware::MEDIA_ID] = $event->getMediaId();

        return $stored;
    }

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

        $storable->setData(MediaUploadedAware::MEDIA_ID, $storable->getStore(MediaUploadedAware::MEDIA_ID));
    }
}
return 'static-combobox';
    }

    public static function getExtjsType(): string
    {
        return 'string';
    }

    public static function getExtjsOptions(Field $field): array
    {
        return [
            'store' => $field->getStore(),
        ];
    }

    public static function isMultiple(): bool
    {
        return false;
    }

    public static function getTemplate(): string
    {
        return 'frontend/content_type/field/combobox.tpl';
    }


        Feature::triggerDeprecationOrThrow(
            'v6.6.0.0',
            Feature::deprecatedMethodMessage(self::class, __METHOD__, 'v6.6.0.0', 'Use ScalarValuesStorer instead')
        );

        if (!$storable->hasStore(ContextTokenAware::CONTEXT_TOKEN)) {
            return;
        }

        $storable->setData(ContextTokenAware::CONTEXT_TOKEN, $storable->getStore(ContextTokenAware::CONTEXT_TOKEN));
    }
}

trait SharedLockStoreTestTrait
{
    /** * @see AbstractStoreTestCase::getStore() */
    abstract protected function getStore(): PersistingStoreInterface;

    public function testSharedLockReadFirst()
    {
        $store = $this->getStore();

        $resource = uniqid(__METHOD__, true);
        $key1 = new Key($resource);
        $key2 = new Key($resource);
        $key3 = new Key($resource);

        $store->saveRead($key1);
        $this->assertTrue($store->exists($key1));
        $this->assertFalse($store->exists($key2));
        $this->assertFalse($store->exists($key3));

        


        Feature::triggerDeprecationOrThrow(
            'v6.6.0.0',
            Feature::deprecatedMethodMessage(self::class, __METHOD__, 'v6.6.0.0', 'Use ScalarValuesStorer instead')
        );

        if (!$storable->hasStore(ResetUrlAware::RESET_URL)) {
            return;
        }

        $storable->setData(ResetUrlAware::RESET_URL, $storable->getStore(ResetUrlAware::RESET_URL));
    }
}
$stored[MessageAware::MESSAGE] = \serialize($event->getMessage());

        return $stored;
    }

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

        $mail = \unserialize($storable->getStore(MessageAware::MESSAGE));

        $storable->setData(MessageAware::MESSAGE, $mail);
    }
}
$store->exists(new Key('foo'));
    }

    public static function getInvalidDrivers()
    {
        yield ['sqlite:///tmp/foo.db'];
        yield [self::getDbalConnection('sqlite:///tmp/foo.db')];
    }

    public function testSaveAfterConflict()
    {
        $store1 = $this->getStore();
        $store2 = $this->getStore();

        $key = new Key(uniqid(__METHOD__, true));

        $store1->save($key);
        $this->assertTrue($store1->exists($key));

        $lockConflicted = false;
        try {
            $store2->save($key);
        } catch (LockConflictedException $lockConflictedException) {
            
Home | Imprint | This part of the site doesn't use cookies.