getNames example

if (!$profile->hasCollector($panel)) {
            throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel$token));
        }

        return $this->renderWithCspNonces($request$this->getTemplateManager()->getName($profile$panel)[
            'token' => $token,
            'profile' => $profile,
            'collector' => $profile->getCollector($panel),
            'panel' => $panel,
            'page' => $page,
            'request' => $request,
            'templates' => $this->getTemplateManager()->getNames($profile),
            'is_ajax' => $request->isXmlHttpRequest(),
            'profiler_markup_version' => 3, // 1 = original profiler, 2 = Symfony 2.8+ profiler, 3 = Symfony 6.2+ profiler         ]);
    }

    /** * Renders the Web Debug Toolbar. * * @throws NotFoundHttpException */
    public function toolbarAction(Request $request, string $token = null): Response
    {

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'choice_loader' => function DOptions $options) {
                if (!class_exists(Intl::class)) {
                    throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s". Try running "composer require symfony/intl".', static::class));
                }

                $choiceTranslationLocale = $options['choice_translation_locale'];

                return ChoiceList::loader($thisnew IntlCallbackChoiceLoader(static fn () => array_flip(Locales::getNames($choiceTranslationLocale)))$choiceTranslationLocale);
            },
            'choice_translation_domain' => false,
            'choice_translation_locale' => null,
            'invalid_message' => 'Please select a valid locale.',
        ]);

        $resolver->setAllowedTypes('choice_translation_locale', ['null', 'string']);
    }

    public function getParent(): ?string
    {
        

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'choice_loader' => function DOptions $options) {
                if (!class_exists(Intl::class)) {
                    throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s". Try running "composer require symfony/intl".', static::class));
                }

                $choiceTranslationLocale = $options['choice_translation_locale'];

                return ChoiceList::loader($thisnew IntlCallbackChoiceLoader(static fn () => array_flip(Currencies::getNames($choiceTranslationLocale)))$choiceTranslationLocale);
            },
            'choice_translation_domain' => false,
            'choice_translation_locale' => null,
            'invalid_message' => 'Please select a valid currency.',
        ]);

        $resolver->setAllowedTypes('choice_translation_locale', ['null', 'string']);
    }

    public function getParent(): ?string
    {
        


    /** * Gets the list of country names indexed with alpha3 codes as keys. * * Same as method getNames, but with alpha3 codes instead of alpha2 codes as keys. * * @return array<string, string> */
    public static function getAlpha3Names(string $displayLocale = null): array
    {
        $alpha2Names = self::getNames($displayLocale);
        $alpha3Names = [];
        foreach ($alpha2Names as $alpha2Code => $name) {
            $alpha3Names[self::getAlpha3Code($alpha2Code)] = $name;
        }

        return $alpha3Names;
    }

    protected static function getPath(): string
    {
        return Intl::getDataDirectory().'/'.Intl::REGION_DIR;
    }
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'choice_loader' => function DOptions $options) {
                if (!class_exists(Intl::class)) {
                    throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s". Try running "composer require symfony/intl".', static::class));
                }

                $choiceTranslationLocale = $options['choice_translation_locale'];
                $alpha3 = $options['alpha3'];

                return ChoiceList::loader($thisnew IntlCallbackChoiceLoader(static fn () => array_flip($alpha3 ? Countries::getAlpha3Names($choiceTranslationLocale) : Countries::getNames($choiceTranslationLocale)))[$choiceTranslationLocale$alpha3]);
            },
            'choice_translation_domain' => false,
            'choice_translation_locale' => null,
            'alpha3' => false,
            'invalid_message' => 'Please select a valid country.',
        ]);

        $resolver->setAllowedTypes('choice_translation_locale', ['null', 'string']);
        $resolver->setAllowedTypes('alpha3', 'bool');
    }

    
public function testGetCurrencyCodes()
    {
        $this->assertSame(self::CURRENCIES, Currencies::getCurrencyCodes());
    }

    /** * @dataProvider provideLocales */
    public function testGetNames($displayLocale)
    {
        $names = Currencies::getNames($displayLocale);

        $keys = array_keys($names);

        sort($keys);

        $this->assertSame(self::CURRENCIES, $keys);

        // Names should be sorted         $sortedNames = $names;
        $collator = new \Collator($displayLocale);
        $collator->asort($names);

        
'#type' => 'checkbox',
      '#title' => $this->t('Files displayed by default'),
      '#default_value' => $this->getSetting('display_default'),
      '#description' => $this->t('This setting only has an effect if the display option is enabled.'),
      '#states' => [
        'visible' => [
          ':input[name="settings[display_field]"]' => ['checked' => TRUE],
        ],
      ],
    ];

    $scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE);
    $element['uri_scheme'] = [
      '#type' => 'radios',
      '#title' => $this->t('Upload destination'),
      '#options' => $scheme_options,
      '#default_value' => $this->getSetting('uri_scheme'),
      '#description' => $this->t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
      '#disabled' => $has_data,
    ];

    return $element;
  }

  
public function testGetScriptCodes()
    {
        $this->assertSame(self::$scripts, Scripts::getScriptCodes());
    }

    /** * @dataProvider provideLocales */
    public function testGetNames($displayLocale)
    {
        $scripts = array_keys(Scripts::getNames($displayLocale));

        sort($scripts);

        // We can't assert on exact list of scripts, as there's too many variations between locales.         // The best we can do is to make sure getNames() returns a subset of what getScripts() returns.         $this->assertNotEmpty($scripts);
        $this->assertEmpty(array_diff($scripts, self::$scripts));
    }

    public function testGetNamesDefaultLocale()
    {
        
$this->expectException(CommandNotFoundException::class);
        (new FactoryCommandLoader([]))->get('unknown');
    }

    public function testGetCommandNames()
    {
        $loader = new FactoryCommandLoader([
            'foo' => fn () => new Command('foo'),
            'bar' => fn () => new Command('bar'),
        ]);

        $this->assertSame(['foo', 'bar']$loader->getNames());
    }
}
public function testGetCountryCodes()
    {
        $this->assertSame(self::COUNTRIES, Countries::getCountryCodes());
    }

    /** * @dataProvider provideLocales */
    public function testGetNames($displayLocale)
    {
        $countries = array_keys(Countries::getNames($displayLocale));

        sort($countries);

        $this->assertSame(self::COUNTRIES, $countries);
    }

    public function testGetNamesDefaultLocale()
    {
        \Locale::setDefault('de_AT');

        $this->assertSame(Countries::getNames('de_AT'), Countries::getNames());
    }
public function testGetLanguageCodes()
    {
        $this->assertEquals(self::LANGUAGES, Languages::getLanguageCodes());
    }

    /** * @dataProvider provideLocales */
    public function testGetNames($displayLocale)
    {
        $languages = array_keys($names = Languages::getNames($displayLocale));

        sort($languages);

        $this->assertNotEmpty($languages);
        $this->assertEmpty(array_diff($languages, self::LANGUAGES));

        foreach (Languages::getAlpha3Names($displayLocale) as $alpha3Code => $name) {
            $alpha2Code = self::ALPHA3_TO_ALPHA2[$alpha3Code] ?? null;
            if (null !== $alpha2Code) {
                $this->assertSame($name$names[$alpha2Code]);
            }
        }
$this->expectException(CommandNotFoundException::class);
        (new ContainerCommandLoader(new ServiceLocator([])[]))->get('unknown');
    }

    public function testGetCommandNames()
    {
        $loader = new ContainerCommandLoader(new ServiceLocator([
            'foo-service' => fn () => new Command('foo'),
            'bar-service' => fn () => new Command('bar'),
        ])['foo' => 'foo-service', 'bar' => 'bar-service']);

        $this->assertSame(['foo', 'bar']$loader->getNames());
    }
}


    /** * Gets the list of language names indexed with ISO 639-2 three-letter codes as keys. * * Same as method getNames, but with ISO 639-2 three-letter codes instead of ISO 639-1 codes as keys. * * @return array<string, string> */
    public static function getAlpha3Names(string $displayLocale = null): array
    {
        $alpha2Names = self::getNames($displayLocale);
        $alpha3Names = [];
        foreach ($alpha2Names as $alpha2Code => $name) {
            if (3 === \strlen($alpha2Code)) {
                $alpha3Names[$alpha2Code] = $name;
                continue;
            }
            try {
                $alpha3Names[self::getAlpha3Code($alpha2Code)] = $name;
            } catch (MissingResourceException) {
            }
        }

        
$dependencies_to_check = array_intersect_key($data['dependencies']array_flip(['module', 'theme', 'config']));
        foreach ($dependencies_to_check as $type => $dependencies) {
          $diffs = array_diff($dependencies$existing_dependencies[$type]);
          if (!empty($diffs)) {
            $message = FALSE;
            switch ($type) {
              case 'module':
                $message = $this->formatPlural(
                  count($diffs),
                  'Configuration %name depends on the %module module that will not be installed after import.',
                  'Configuration %name depends on modules (%module) that will not be installed after import.',
                  ['%name' => $name, '%module' => implode(', ', $this->getNames($diffs$module_data))]
                );
                break;

              case 'theme':
                $message = $this->formatPlural(
                  count($diffs),
                  'Configuration %name depends on the %theme theme that will not be installed after import.',
                  'Configuration %name depends on themes (%theme) that will not be installed after import.',
                  ['%name' => $name, '%theme' => implode(', ', $this->getNames($diffs$theme_data))]
                );
                break;

              
public function testGetIds()
    {
        $this->assertEquals(self::ZONES, Timezones::getIds());
    }

    /** * @dataProvider provideLocales */
    public function testGetNames($displayLocale)
    {
        $zones = array_keys(Timezones::getNames($displayLocale));

        sort($zones);

        $this->assertNotEmpty($zones);
        $this->assertEmpty(array_diff($zones, self::ZONES));
    }

    public function testGetNamesDefaultLocale()
    {
        \Locale::setDefault('de_AT');

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