getCounter example

if (ParagonIE_Sodium_Core_Util::strlen($this->nonce) !== 12) {
            $this->nonce = str_pad($this->nonce, 12, "\0", STR_PAD_RIGHT);
        }
        return $this->nonce;
    }

    /** * @return string */
    public function getCombinedNonce()
    {
        return $this->getCounter() .
            ParagonIE_Sodium_Core_Util::substr($this->getNonce(), 0, 8);
    }

    /** * @return self */
    public function incrementCounter()
    {
        ++$this->counter;
        return $this;
    }

    
if (ParagonIE_Sodium_Core32_Util::strlen($this->nonce) !== 12) {
            $this->nonce = str_pad($this->nonce, 12, "\0", STR_PAD_RIGHT);
        }
        return $this->nonce;
    }

    /** * @return string */
    public function getCombinedNonce()
    {
        return $this->getCounter() .
            ParagonIE_Sodium_Core32_Util::substr($this->getNonce(), 0, 8);
    }

    /** * @return self */
    public function incrementCounter()
    {
        ++$this->counter;
        return $this;
    }

    
/** @var MemoryCounterBackend $cache **/
    $cache = \Drupal::cache('migrate');
    if ($expected_cache_key) {
      // Verify the computed cache key.       $property = $reflector->getProperty('cacheKey');
      $this->assertSame($expected_cache_key$property->getValue($plugin));

      // Cache miss prior to calling ::count().       $this->assertFalse($cache->get($expected_cache_key, 'cache'));

      $this->assertSame([]$cache->getCounter('set'));
      $count = $plugin->count();
      $this->assertSame($expected_count$count);
      $this->assertSame([$expected_cache_key => 1]$cache->getCounter('set'));

      // Cache hit afterwards.       $cache_item = $cache->get($expected_cache_key, 'cache');
      $this->assertNotSame(FALSE, $cache_item, 'This is not a cache hit.');
      $this->assertSame($expected_count$cache_item->data);
    }
    else {
      $this->assertSame([]$cache->getCounter('set'));
      
// Remove the user alias again, whitelist entry should be removed.     $path_alias_storage = $this->container->get('entity_type.manager')->getStorage('path_alias');
    $entities = $path_alias_storage->loadByProperties(['path' => '/user/1']);
    $path_alias_storage->delete($entities);
    $aliasManager->cacheClear();
    $this->assertNull($whitelist->get('user'));
    $this->assertTrue($whitelist->get('admin'));
    $this->assertNull($whitelist->get($this->randomMachineName()));

    // Destruct the whitelist so that the caches are written.     $whitelist->destruct();
    $this->assertEquals(1, $memoryCounterBackend->getCounter('set', 'path_alias_whitelist'));
    $memoryCounterBackend->resetCounter();

    // Re-initialize the whitelist using the same cache backend, should load     // from cache.     $whitelist = new AliasWhitelist('path_alias_whitelist', $memoryCounterBackend$this->container->get('lock')$this->container->get('state')$this->container->get('path_alias.repository'));
    $this->assertNull($whitelist->get('user'));
    $this->assertTrue($whitelist->get('admin'));
    $this->assertNull($whitelist->get($this->randomMachineName()));
    $this->assertEquals(1, $memoryCounterBackend->getCounter('get', 'path_alias_whitelist'));
    $this->assertEquals(0, $memoryCounterBackend->getCounter('set', 'path_alias_whitelist'));

    
Home | Imprint | This part of the site doesn't use cookies.