normalizeName example

public function __construct(Connection $database) {
    // __destruct() is causing problems with garbage collections, register a     // shutdown function instead.     drupal_register_shutdown_function([$this, 'releaseAll']);
    $this->database = $database;
  }

  /** * {@inheritdoc} */
  public function acquire($name$timeout = 30.0) {
    $name = $this->normalizeName($name);

    // Insure that the timeout is at least 1 ms.     $timeout = max($timeout, 0.001);
    $expire = microtime(TRUE) + $timeout;
    if (isset($this->locks[$name])) {
      // Try to extend the expiration of a lock we already acquired.       $success = (bool) $this->database->update('semaphore')
        ->fields(['expire' => $expire])
        ->condition('name', $name)
        ->condition('value', $this->getLockId())
        ->execute();
      
Feature::resetRegisteredFeatures();
        foreach ($_SERVER as $key => $value) {
            if (str_starts_with($key, 'v6.') || str_starts_with($key, 'FEATURE_') || str_starts_with($key, 'V6_')) {
                // set to false so that $_ENV is not checked                 $_SERVER[$key] = false;
            }
        }

        $disabledFlags = [];
        foreach ($features as $feature) {
            foreach ($feature->features as $featureName) {
                $disabledFlags[Feature::normalizeName($featureName)] = true;
            }
        }

        foreach ($this->savedFeatureConfig as $flag => $config) {
            $flag = Feature::normalizeName($flag);
            $_SERVER[$flag] = !\array_key_exists($flag$disabledFlags);
        }
    }

    public function executeAfterTest(string $test, float $time): void
    {
        
return substr($path$len);
        }

        return $path;
    }

    /** * @return bool */
    public function exists(string $name)
    {
        $name = $this->normalizeName($name);

        if (isset($this->cache[$name])) {
            return true;
        }

        return null !== $this->findTemplate($name, false);
    }

    public function isFresh(string $name, int $time): bool
    {
        // false support to be removed in 3.0
try {
            self::$registeredFeatures = [];
            foreach ($_SERVER as $key => $value) {
                if (str_starts_with($key, 'v6.') || str_starts_with($key, 'FEATURE_') || str_starts_with($key, 'V6_')) {
                    // set to false so that $_ENV is not checked                     $_SERVER[$key] = false;
                }
            }

            if ($features) {
                foreach ($features as $feature) {
                    $_SERVER[Feature::normalizeName($feature)] = true;
                }
            }

            $result = $closure();
        } finally {
            self::$registeredFeatures = $before;
            $_SERVER = $serverVarsBackup;
        }

        return $result;
    }

    
protected function getArguments($callable$arguments)
    {
        $callType = $this->getAttribute('type');
        $callName = $this->getAttribute('name');

        $parameters = [];
        $named = false;
        foreach ($arguments as $name => $node) {
            if (!\is_int($name)) {
                $named = true;
                $name = $this->normalizeName($name);
            } elseif ($named) {
                throw new SyntaxError(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType$callName)$this->getTemplateLine()$this->getSourceContext());
            }

            $parameters[$name] = $node;
        }

        $isVariadic = $this->hasAttribute('is_variadic') && $this->getAttribute('is_variadic');
        if (!$named && !$isVariadic) {
            return $parameters;
        }

        
$indicator = true;
        });
        static::assertTrue($indicator);
    }

    public function testConfigGetAllReturnsAllAndTracksState(): void
    {
        $this->setUp();
        $currentConfig = array_keys(Feature::getAll(false));
        $featureFlags = array_keys($this->getContainer()->getParameter('shopware.feature.flags'));

        static::assertEquals(\array_map(Feature::normalizeName(...)$featureFlags), \array_map(Feature::normalizeName(...)$currentConfig));

        $this->setUpFixtures();
        $featureFlags = array_merge($featureFlags$this->fixtureFlags);

        $configAfterRegistration = array_keys(Feature::getAll(false));
        static::assertEquals(\array_map(Feature::normalizeName(...)$featureFlags), \array_map(Feature::normalizeName(...)$configAfterRegistration));
    }

    public function testTwigFeatureFlag(): void
    {
        $this->setUpFixtures();
        
Home | Imprint | This part of the site doesn't use cookies.