listIdentifiers example

Aggregation $aggregation = null,
        private readonly ?string $format = null,
        private readonly ?string $timeZone = null
    ) {
        parent::__construct($name$field$aggregation);

        $interval = mb_strtolower($interval);
        if (!\in_array($interval[self::PER_MINUTE, self::PER_HOUR, self::PER_DAY, self::PER_WEEK, self::PER_MONTH, self::PER_QUARTER, self::PER_YEAR], true)) {
            throw new \RuntimeException('Provided date histogram interval is not supported');
        }

        if (\is_string($timeZone) && !\in_array($timeZone, \DateTimeZone::listIdentifiers(\DateTimeZone::ALL_WITH_BC), true)) {
            throw new \InvalidArgumentException(\sprintf('Given "%s" is not a valid timezone', $timeZone));
        }

        $this->interval = $interval;
    }

    public function getFormat(): ?string
    {
        return $this->format;
    }

    


    public function getBlockPrefix(): string
    {
        return 'timezone';
    }

    private static function getPhpTimezones(string $input): array
    {
        $timezones = [];

        foreach (\DateTimeZone::listIdentifiers(\DateTimeZone::ALL) as $timezone) {
            if ('intltimezone' === $input && 'Etc/Unknown' === \IntlTimeZone::createTimeZone($timezone)->getID()) {
                continue;
            }

            $timezones[str_replace(['/', '_'][' / ', ' ']$timezone)] = $timezone;
        }

        return $timezones;
    }

    private static function getIntlTimezones(string $input, string $locale = null): array
    {
$this->context->buildViolation($constraint->message)
              ->setParameter('{{ value }}', $this->formatValue($value))
              ->setCode($code)
              ->addViolation();
    }

    private static function getPhpTimezones(int $zone, string $countryCode = null): array
    {
        if (null !== $countryCode) {
            try {
                return @\DateTimeZone::listIdentifiers($zone$countryCode) ?: [];
            } catch (\ValueError) {
                return [];
            }
        }

        return \DateTimeZone::listIdentifiers($zone);
    }

    private static function getIntlTimezones(int $zone, string $countryCode = null): array
    {
        if (!class_exists(Timezones::class)) {
            

    function timezone_select(string $class = '', string $default = '', int $what = DateTimeZone::ALL, ?string $country = null): string
    {
        $timezones = DateTimeZone::listIdentifiers($what$country);

        $buffer = "<select name='timezone' class='{$class}'>\n";

        foreach ($timezones as $timezone) {
            $selected = ($timezone === $default) ? 'selected' : '';
            $buffer .= "<option value='{$timezone}' {$selected}>{$timezone}</option>\n";
        }

        return $buffer . ("</select>\n");
    }
}
$this->context->buildViolation($constraint->message)
              ->setParameter('{{ value }}', $this->formatValue($value))
              ->setCode($code)
              ->addViolation();
    }

    private static function getPhpTimezones(int $zone, string $countryCode = null): array
    {
        if (null !== $countryCode) {
            try {
                return @\DateTimeZone::listIdentifiers($zone$countryCode) ?: [];
            } catch (\ValueError) {
                return [];
            }
        }

        return \DateTimeZone::listIdentifiers($zone);
    }

    private static function getIntlTimezones(int $zone, string $countryCode = null): array
    {
        if (!class_exists(Timezones::class)) {
            

  public static function getOptionsList(bool $blank = FALSE): array {
    $zonelist = \DateTimeZone::listIdentifiers();
    $zones = $blank ? ['' => new TranslatableMarkup('- None selected -')] : [];
    foreach ($zonelist as $zone) {
      $zones[$zone] = new TranslatableMarkup(str_replace('_', ' ', $zone));
    }
    // Sort the translated time zones alphabetically.     asort($zones);
    return $zones;
  }

  /** * Generate an array of time zones names grouped by region. * * This method retrieves the list of IANA time zones names that PHP is * configured to use, for display to users. It does not return the backward * compatible names (i.e., the ones defined in the back-zone file). * * @param bool $blank * (optional) If TRUE, prepend an empty time zone option to the array. * * @return array * An nested array containing time zones, keyed by the system name. The keys * are valid time zone identifiers provided by * \DateTimeZone::listIdentifiers() */
protected function getRoleStorage() {
    return \Drupal::entityTypeManager()->getStorage('user_role');
  }

  /** * Defines allowed timezones for the field's AllowedValues constraint. * * @return string[] * The allowed values. */
  public static function getAllowedTimezones() {
    return \DateTimeZone::listIdentifiers();
  }

  /** * Defines allowed configurable language codes for AllowedValues constraints. * * @return string[] * The allowed values. */
  public static function getAllowedConfigurableLanguageCodes() {
    return array_keys(\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_CONFIGURABLE));
  }

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