本文整理汇总了PHP中Symfony\Component\Intl\Intl::getRegionBundle方法的典型用法代码示例。如果您正苦于以下问题:PHP Intl::getRegionBundle方法的具体用法?PHP Intl::getRegionBundle怎么用?PHP Intl::getRegionBundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Intl\Intl
的用法示例。
在下文中一共展示了Intl::getRegionBundle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'choices' => Intl::getRegionBundle()->getCountryNames(),
'choice_translation_domain' => false,
));
}
示例2: loadForm
/**
* Load the form
*/
private function loadForm()
{
// gender dropdown values
$genderValues = array('male' => \SpoonFilter::ucfirst(BL::getLabel('Male')), 'female' => \SpoonFilter::ucfirst(BL::getLabel('Female')));
// birthdate dropdown values
$days = range(1, 31);
$months = \SpoonLocale::getMonths(BL::getInterfaceLanguage());
$years = range(date('Y'), 1900);
// create form
$this->frm = new BackendForm('add');
// create elements
$this->frm->addText('email')->setAttribute('type', 'email');
$this->frm->addPassword('password');
$this->frm->addText('display_name');
$this->frm->addText('first_name');
$this->frm->addText('last_name');
$this->frm->addText('city');
$this->frm->addDropdown('gender', $genderValues);
$this->frm->addDropdown('day', array_combine($days, $days));
$this->frm->addDropdown('month', $months);
$this->frm->addDropdown('year', array_combine($years, $years));
$this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()));
// set default elements dropdowns
$this->frm->getField('gender')->setDefaultElement('');
$this->frm->getField('day')->setDefaultElement('');
$this->frm->getField('month')->setDefaultElement('');
$this->frm->getField('year')->setDefaultElement('');
$this->frm->getField('country')->setDefaultElement('');
}
示例3: validateUPU_S10
public static function validateUPU_S10($track)
{
if (!preg_match("/^([A-Z]{2})(\\d{8})(\\d{1})([A-Z]{2})\$/", $track, $matches)) {
return false;
}
list($track, $serviceIndicator, $serialNumber, $checkDigit, $countryCode) = $matches;
// Check $serviceIndicator
if (!preg_match("/([ELMRUVCHABDNPZ][A-Z])|(Q[A-M])|(G[AD])/", $serviceIndicator)) {
return false;
}
// Check $checkDigit
$serialNumberDigits = str_split($serialNumber);
$weightFactors = array(8, 6, 4, 2, 3, 5, 9, 7);
$weightedSum = array_reduce(range(0, 7), function ($sum, $i) use($serialNumberDigits, $weightFactors) {
return $sum + $serialNumberDigits[$i] * $weightFactors[$i];
});
$res = 11 - $weightedSum % 11;
$appropriateCheckDigit = $res >= 1 && $res <= 9 ? $res : ($res == 11 ? 5 : 0);
if ($appropriateCheckDigit != $checkDigit) {
return false;
}
// Check $countryCode
$countryCodes = array_keys(Intl::getRegionBundle()->getCountryNames());
if (!in_array($countryCode, $countryCodes)) {
return false;
}
return true;
}
示例4: validate
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Country) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Country');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedTypeException($value, 'string');
}
$value = (string) $value;
$countries = Intl::getRegionBundle()->getCountryNames();
if (!isset($countries[$value])) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Country::NO_SUCH_COUNTRY_ERROR)
->addViolation();
} else {
$this->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Country::NO_SUCH_COUNTRY_ERROR)
->addViolation();
}
}
}
示例5: loadChoiceList
/**
* {@inheritdoc}
*/
public function loadChoiceList($value = null)
{
if (null !== $this->choiceList) {
return $this->choiceList;
}
return $this->choiceList = new ArrayChoiceList(array_flip(Intl::getRegionBundle()->getCountryNames()), $value);
}
示例6: translateCountryIsoCode
/**
* @param mixed $country
* @param string $locale
*
* @return string
*/
public function translateCountryIsoCode($country, $locale = null)
{
if ($country instanceof CountryInterface) {
return Intl::getRegionBundle()->getCountryName($country->getCode(), $locale);
}
return Intl::getRegionBundle()->getCountryName($country, $locale);
}
示例7: getDisplayCountries
/**
* Returns the country names for a locale.
*
* @param string $locale The locale to use for the country names
*
* @return array The country names with their codes as keys
*
* @throws \RuntimeException When the resource bundles cannot be loaded
*/
public static function getDisplayCountries($locale)
{
if (!isset(self::$countries[$locale])) {
self::$countries[$locale] = Intl::getRegionBundle()->getCountryNames($locale);
}
return self::$countries[$locale];
}
示例8: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
if (self::WIDGET_COUNTRY_CHOICE === $options['widget']) {
$util = PhoneNumberUtil::getInstance();
$countries = array();
if (is_array($options['country_choices'])) {
foreach ($options['country_choices'] as $country) {
$code = $util->getCountryCodeForRegion($country);
if ($code) {
$countries[$country] = $code;
}
}
}
if (empty($countries)) {
foreach ($util->getSupportedRegions() as $country) {
$countries[$country] = $util->getCountryCodeForRegion($country);
}
}
$countryChoices = array();
foreach (Intl::getRegionBundle()->getCountryNames() as $region => $name) {
if (false === isset($countries[$region])) {
continue;
}
$countryChoices[$region] = sprintf('%s (+%s)', $name, $countries[$region]);
}
$countryOptions = $numberOptions = array('error_bubbling' => true, 'required' => $options['required'], 'disabled' => $options['disabled'], 'translation_domain' => $options['translation_domain']);
$countryOptions['required'] = true;
$countryOptions['choices'] = $countryChoices;
$countryOptions['preferred_choices'] = $options['preferred_country_choices'];
$countryOptions['choice_translation_domain'] = false;
$builder->add('country', 'choice', $countryOptions)->add('number', 'text', $numberOptions)->addViewTransformer(new PhoneNumberToArrayTransformer(array_keys($countryChoices)));
} else {
$builder->addViewTransformer(new PhoneNumberToStringTransformer($options['default_region'], $options['format']));
}
}
示例9: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$countries = Intl::getRegionBundle()->getCountryNames();
// add your custom field
$builder->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))->add('plainPassword', 'repeated', array('type' => 'password', 'options' => array('translation_domain' => 'FOSUserBundle'), 'first_options' => array('label' => 'form.password'), 'second_options' => array('label' => 'form.password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch'))->add('lastname', 'text')->add('firstname', 'text')->add('image', new AetImageType())->add('pays', 'country', array('expanded' => false, 'multiple' => false))->add('matricule', 'text')->add('whoami', 'textarea', array('required' => false))->add('ville', 'text')->add('code_postale', 'text')->add('telephone', 'text')->add('activite_principale', 'choice', array('choices' => array('Art, Design' => 'Art, Design', 'Audiovisuel - Spectacle' => 'Audiovisuel - Spectacle', 'Audit, gestion' => 'Audit, gestion', 'Automobile' => 'Automobile', 'Banque, assurance' => 'Banque, assurance', 'Bois (filière)' => 'Bois (filière)', 'BTP, architecture' => 'BTP, architecture', 'Chimie, pharmacie' => 'Chimie, pharmacie', 'Commerce, distribution' => 'Commerce, distribution', 'Communication - Marketing, publicité' => 'Communication - Marketing, publicité', 'Construction aéronautique, ferroviaire et navale' => 'Construction aéronautique, ferroviaire et navale', 'Culture - Artisanat d\'art' => 'Culture - Artisanat d\'art', 'Droit, justice' => 'Droit, justice', 'Edition, Journalisme' => 'Edition, Journalisme', 'Électronique' => 'Électronique', 'Énergie' => 'Énergie', 'Enseignement' => 'Enseignement', 'Environnement' => 'Environnement', 'Fonction publique' => 'Fonction publique', 'Hôtellerie, restauration' => 'Hôtellerie, restauration', 'Industrie alimentaire' => 'Industrie alimentaire', 'Informatique, internet et télécom' => 'Informatique, internet et télécom', 'Logistique, transport' => 'Logistique, transport', 'Maintenance, entretien' => 'Maintenance, entretien', 'Mécanique' => 'Mécanique', 'Mode et industrie textile' => 'Mode et industrie textile', 'Recherche' => 'Recherche', 'Santé' => 'Santé', 'Social' => 'Social', 'Sport, loisirs – Tourisme' => 'Sport, loisirs – Tourisme', 'Traduction - interprétariat' => 'Traduction - interprétariat'), 'required' => false, 'mapped' => true))->add('promotion', 'birthday', array('widget' => 'choice', 'years' => range(date('Y') - 110, date('Y')), 'empty_value' => array('year' => '----')));
}
示例10: load
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
$countryRepository = $this->getCountryRepository();
$countries = Intl::getRegionBundle()->getCountryNames($this->defaultLocale);
if (Intl::isExtensionLoaded()) {
$localisedCountries = array('es_ES' => Intl::getRegionBundle()->getCountryNames('es_ES'));
} else {
$localisedCountries = array();
}
foreach ($countries as $isoName => $name) {
$country = $countryRepository->createNew();
$country->setCurrentLocale($this->defaultLocale);
$country->setName($name);
foreach ($localisedCountries as $locale => $translatedCountries) {
$country->setCurrentLocale($locale);
$country->setName($translatedCountries[$isoName]);
}
$country->setIsoName($isoName);
if ('US' === $isoName) {
$this->addUsStates($country);
}
$manager->persist($country);
$this->setReference('Sylius.Country.' . $isoName, $country);
}
$manager->flush();
}
示例11: getCountryName
/**
* Return the country name using the Locale class.
*
* @param string $isoCode Country ISO 3166-1 alpha 2 code
* @param null|string $locale Locale code
*
* @return null|string Country name
*/
public function getCountryName($isoCode, $locale = null)
{
if ($isoCode === null) {
return;
}
return $locale === null ? Intl::getRegionBundle()->getCountryName($isoCode) : Intl::getRegionBundle()->getCountryName($isoCode, $locale);
}
示例12: guard
/**
* @param mixed $value
*
* @throws InvalidCountryCodeException
*/
protected function guard($value)
{
$countryName = Intl::getRegionBundle()->getCountryName($value);
if (null === $countryName) {
throw new InvalidCountryCodeException($value);
}
}
示例13: loadForm
/**
* Load the form
*/
protected function loadForm()
{
$rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
$rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y');
$this->frm = new BackendForm('edit');
$this->frm->addText('company', $this->record['company']);
$this->frm->addText('name', $this->record['name']);
$this->frm->addText('firstname', $this->record['firstname']);
$this->frm->addText('email', $this->record['email']);
$this->frm->addText('address', $this->record['address']);
$this->frm->addText('zipcode', $this->record['zipcode']);
$this->frm->addText('city', $this->record['city']);
// $this->frm->addText('country', $this->record['country']);
$this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()), $this->record['country']);
$this->frm->addText('phone', $this->record['phone']);
$this->frm->addText('fax', $this->record['fax']);
$this->frm->addText('website', $this->record['website']);
$this->frm->addText('vat', $this->record['vat']);
$this->frm->addTextArea('zipcodes', $this->record['zipcodes']);
$this->frm->addText('remark', $this->record['remark']);
//$this->frm->addText('assort', $this->record['assort']);
//$this->frm->addText('open', $this->record['open']);
//$this->frm->addText('closed', $this->record['closed']);
//$this->frm->addText('visit', $this->record['visit']);
//$this->frm->addText('size', $this->record['size']);
//$this->frm->addEditor('text', $this->record['text']);
$this->frm->addImage('image');
$this->frm->addCheckbox('delete_image');
$this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']);
foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
$addressesLanguage = BackendAddressesModel::getLanguage($this->id, $language);
$fieldText = $this->frm->addEditor("text_" . strtolower($language), $addressesLanguage['text']);
$fieldOpeningHours = $this->frm->addEditor("opening_hours_" . strtolower($language), $addressesLanguage['opening_hours']);
$this->fieldLanguages[$key]["key"] = $key;
$this->fieldLanguages[$key]["language"] = $language;
$this->fieldLanguages[$key]["text"] = $fieldText->parse();
$this->fieldLanguages[$key]["opening_hours"] = $fieldOpeningHours->parse();
}
//--Get all the groups
$groups = BackendAddressesModel::getAllGroups();
if (!empty($groups)) {
//--Loop all the users
foreach ($groups as &$group) {
$groupCheckboxes[] = array("label" => $group["title"], "value" => $group["id"]);
}
//--Get the users from the group
$groupsAddress = BackendAddressesModel::getGroupsForAddress($this->id);
//--Create a selected-array
$groupCheckboxesSelected = count($groupsAddress) > 0 ? array_keys($groupsAddress) : null;
//--Add multicheckboxes to form
$this->frm->addMultiCheckbox("groups", $groupCheckboxes, $groupCheckboxesSelected);
}
$groups2 = BackendAddressesModel::getAllGroupsTreeArray();
$this->tpl->assign('groups2', $groups2);
$this->tpl->assign('groups2selected', $groupCheckboxesSelected == null ? array() : $groupCheckboxesSelected);
// meta
$this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'company', true);
$this->meta->setUrlCallback('Backend\\Modules\\Addresses\\Engine\\Model', 'getUrl', array($this->record['id']));
}
示例14: eventDetailAction
/**
* Returns template for event detail
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function eventDetailAction()
{
$countries = array();
foreach (Intl::getRegionBundle()->getCountryNames() as $alpha2 => $country) {
$countries[] = array('id' => $alpha2, 'name' => $country);
}
return $this->render('SuluEventBundle:Event:detail.html.twig', array('countries' => $countries));
}
示例15: getCountryCodes
/**
* @param CountryInterface[] $countries
*
* @return array
*/
private function getCountryCodes(array $countries)
{
$countryCodes = [];
/* @var CountryInterface $country */
foreach ($countries as $country) {
$countryCodes[$country->getCode()] = Intl::getRegionBundle()->getCountryName($country->getCode());
}
return $countryCodes;
}