increment example


            $customer->setGroup($customerGroup);
        }

        if ($customer->getAffiliate()) {
            $customer->setAffiliate((int) $this->getPartnerId($customer));
        } else {
            $customer->setAffiliate(0);
        }

        if (!$customer->getNumber() && $this->config->get('shopwareManagedCustomerNumbers')) {
            $customer->setNumber((string) $this->numberIncrementer->increment('user'));
        }

        $this->validator->validate($customer);
        $this->modelManager->persist($customer);
        $this->modelManager->flush($customer);
        $this->modelManager->refresh($customer);
    }

    private function getPartnerId(Customer $customer): int
    {
        return (int) $this->connection->fetchColumn('SELECT id FROM s_emarketing_partner WHERE idcode = ?', [$customer->getAffiliate()]);
    }

if (!is_callable('sodium_increment')) {
    /** * @see ParagonIE_Sodium_Compat::increment() * @param string $string * @return void * @throws SodiumException * @throws TypeError */
    function sodium_increment(&$string)
    {
        ParagonIE_Sodium_Compat::increment($string);
    }
}
if (!is_callable('sodium_library_version_major')) {
    /** * @see ParagonIE_Sodium_Compat::library_version_major() * @return int */
    function sodium_library_version_major()
    {
        return ParagonIE_Sodium_Compat::library_version_major();
    }
}

        $new = $this;

        foreach ($taxCollection as $calculatedTax) {
            $exists = $new->get($this->getKey($calculatedTax));
            if (!$exists) {
                $new->add(clone $calculatedTax);

                continue;
            }

            $exists->increment($calculatedTax);
        }

        return $new;
    }

    public function round(CashRounding $rounding, CashRoundingConfig $config): void
    {
        foreach ($this->elements as $tax) {
            $tax->setTax(
                $rounding->mathRound($tax->getTax()$config)
            );
        }
$password = $this->Request()->getParam('newPassword');

        // Encode the password with md5         if (!empty($password)) {
            $customer->setPassword($password);
        }

        if (!$customer->getNumber() && Shopware()->Config()->get('shopwareManagedCustomerNumbers')) {
            /** @var NumberRangeIncrementerInterface $incrementer */
            $incrementer = Shopware()->Container()->get(NumberRangeIncrementerInterface::class);
            $customer->setNumber((string) $incrementer->increment('user'));
        }

        $this->getManager()->persist($customer);
        $this->getManager()->flush();

        $this->View()->assign([
            'success' => true,
            'data' => $this->getCustomer($customer->getId()),
        ]);
    }

    
$this->attributePersister = Shopware()->Container()->get(DataPersister::class);
        $this->modelManager = $container->get(ModelManager::class);
    }

    /** * Get a unique order number * * @return string The reserved order number */
    public function sGetOrderNumber()
    {
        $number = $this->numberRangeIncrementer->increment('invoice');
        $number = $this->eventManager->filter(
            'Shopware_Modules_Order_GetOrdernumber_FilterOrdernumber',
            $number,
            ['subject' => $this]
        );

        return (string) $number;
    }

    /** * Check each basket row for instant downloads * * @param array $basketRow * @param int $orderID * @param int $orderDetailsID * * @return array */
use AdminFunctionalTestBehaviour;
    use IntegrationTestBehaviour;

    public function testEndpoint(): void
    {
        $gatewayRegistry = $this->getContainer()->get('shopware.increment.gateway.registry');

        $gateway = $gatewayRegistry->get(IncrementGatewayRegistry::MESSAGE_QUEUE_POOL);

        $gateway->reset('message_queue_stats', 'foo');
        $gateway->reset('message_queue_stats', 'bar');
        $gateway->increment('message_queue_stats', 'foo');
        $gateway->increment('message_queue_stats', 'bar');
        $gateway->increment('message_queue_stats', 'bar');

        $url = '/api/_info/queue.json';
        $client = $this->getBrowser();
        $client->request('GET', $url);

        static::assertSame(200, $client->getResponse()->getStatusCode());

        $entries = json_decode($client->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        
private MySQLIncrementer $mysqlIncrementer;

    protected function setUp(): void
    {
        $this->mysqlIncrementer = new MySQLIncrementer($this->getContainer()->get(Connection::class));
        $this->mysqlIncrementer->setPool('user-activity-pool');
    }

    public function testIncrement(): void
    {
        $this->mysqlIncrementer->increment('test-user-1', 'sw.product.index');

        $list = $this->mysqlIncrementer->list('test-user-1');

        static::assertNotNull($list['sw.product.index']);
        static::assertEquals(1, $list['sw.product.index']['count']);

        $this->mysqlIncrementer->increment('test-user-1', 'sw.product.index');

        $list = $this->mysqlIncrementer->list('test-user-1');

        static::assertEquals(2, $list['sw.product.index']['count']);
    }


    protected function tearDown(): void
    {
        parent::tearDown();

        $this->redis?->flushAll();
    }

    public function testIncrement(): void
    {
        $this->incrementer->increment('test', 't1');
        $this->incrementer->increment('test', 't1');
        $this->incrementer->increment('test', 't1');

        $keys = $this->incrementer->list('test');
        static::assertArrayHasKey('t1', $keys);
        static::assertSame(3, $keys['t1']['count']);
    }

    public function testDecrement(): void
    {
        $this->incrementer->increment('test', 't1');
        
$value += $offset;

        return $this->save($key$value$ttl) ? $value : false;
    }

    /** * {@inheritDoc} */
    public function decrement(string $key, int $offset = 1)
    {
        return $this->increment($key, -$offset);
    }

    /** * {@inheritDoc} */
    public function clean()
    {
        return $this->deleteFiles($this->path, false, true);
    }

    /** * {@inheritDoc} */
/** * {@inheritDoc} */
    public function increment(string $key, int $offset = 1)
    {
        if ($this->config['raw']) {
            return false;
        }

        $key = static::validateKey($key$this->prefix);

        return $this->memcached->increment($key$offset$offset, 60);
    }

    /** * {@inheritDoc} */
    public function decrement(string $key, int $offset = 1)
    {
        if ($this->config['raw']) {
            return false;
        }

        
$this->arrayIncrementer->setPool('user-activity-pool');
    }

    public function testDecrementDoesNotCreate(): void
    {
        $this->arrayIncrementer->decrement('test', 'test');
        static::assertEmpty($this->arrayIncrementer->list('test'));
    }

    public function testIncrement(): void
    {
        $this->arrayIncrementer->increment('test-user-1', 'sw.product.index');

        $list = $this->arrayIncrementer->list('test-user-1');

        static::assertNotNull($list['sw.product.index']);
        static::assertEquals(1, $list['sw.product.index']['count']);

        $this->arrayIncrementer->increment('test-user-1', 'sw.product.index');

        $list = $this->arrayIncrementer->list('test-user-1');

        static::assertEquals(2, $list['sw.product.index']['count']);
    }
/** @var AdminApiSource $source */
        $source = $context->getSource();
        static::assertNotNull($source->getUserId());
        $this->userId = Uuid::fromBytesToHex($source->getUserId());

        $this->gateway->reset($this->userId, 'foo');
    }

    public function testListEndpoint(): void
    {
        $this->gateway->increment($this->userId, 'foo');
        $this->gateway->increment($this->userId, 'foo');
        $this->gateway->increment($this->userId, 'bar');

        $url = '/api/_action/increment/user_activity?cluster=' . $this->userId;
        $client = $this->getBrowser();
        $client->request('GET', $url);

        static::assertSame(200, $client->getResponse()->getStatusCode());

        $entries = json_decode((string) $client->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        
public function testStringMagicGet()
    {
        $proxy = $this->createLazyProxy(StringMagicGetClass::classfn () => new StringMagicGetClass());

        $this->assertSame('abc', $proxy->abc);
    }

    public function testFinalPublicClass()
    {
        $proxy = $this->createLazyProxy(FinalPublicClass::classfn () => new FinalPublicClass());

        $this->assertSame(1, $proxy->increment());
        $this->assertSame(2, $proxy->increment());
        $this->assertSame(1, $proxy->decrement());
    }

    public function testOverwritePropClass()
    {
        $proxy = $this->createLazyProxy(TestOverwritePropClass::classfn () => new TestOverwritePropClass('123', 5));

        $this->assertSame('123', $proxy->getDep());
        $this->assertSame(1, $proxy->increment());
    }

    

        $key = static::validateKey($key$this->prefix);

        return $this->redis->hIncrBy($key, '__ci_value', $offset);
    }

    /** * {@inheritDoc} */
    public function decrement(string $key, int $offset = 1)
    {
        return $this->increment($key, -$offset);
    }

    /** * {@inheritDoc} */
    public function clean()
    {
        return $this->redis->flushDB();
    }

    /** * {@inheritDoc} */
$violations = $this->getManager()->validate($order);
        if ($violations->count() > 0) {
            throw new ValidationException($violations);
        }

        $this->createAddresses($params$order);

        // Generate an order number if none was provided. Doing it after validation since         // the generation of the order number cannot be reverted in a simple manner.         if ($order->getNumber() === null) {
            $orderNumberGenerator = Shopware()->Container()->get(NumberRangeIncrementerInterface::class);
            $orderNumber = $orderNumberGenerator->increment('invoice');

            $order->setNumber((string) $orderNumber);
            foreach ($order->getDetails() as $detail) {
                $detail->setNumber((string) $orderNumber);
            }
        }

        $this->getManager()->persist($order);
        $this->flush();

        return $order;
    }
Home | Imprint | This part of the site doesn't use cookies.