Skip to content
Snippets Groups Projects
Commit b38ec8c2 authored by Jacob Rockowitz's avatar Jacob Rockowitz
Browse files

Merge branch '6.x' into 6.2.x

parents bdfb2fcc 7dab64e9
No related branches found
Tags 8.x-3.0-alpha6
No related merge requests found
......@@ -46,7 +46,9 @@ function webform_webform_options_time_zones_alter(array &$options, array $elemen
*/
function webform_webform_options_country_codes_alter(array &$options, array $element = []) {
if (empty($options)) {
$options = CountryManager::getStandardList();
/** @var \Drupal\Core\Locale\CountryManagerInterface $country_manager */
$country_manager = \Drupal::service('country_manager');
$options = $country_manager->getList();
}
}
......@@ -55,7 +57,9 @@ function webform_webform_options_country_codes_alter(array &$options, array $ele
*/
function webform_webform_options_country_names_alter(array &$options, array $element = []) {
if (empty($options)) {
$countries = CountryManager::getStandardList();
/** @var \Drupal\Core\Locale\CountryManagerInterface $country_manager */
$country_manager = \Drupal::service('country_manager');
$countries = $country_manager->getList();
$options = array_combine($countries, $countries);
}
}
......
......@@ -5,7 +5,6 @@ namespace Drupal\webform\Plugin\WebformElement;
use Drupal\Component\Serialization\Json;
use Drupal\webform\Element\WebformMessage as WebformMessageElement;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Locale\CountryManager;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -38,6 +37,13 @@ class Telephone extends TextBase {
*/
protected $telephoneValidator;
/**
* The country manager.
*
* @var \Drupal\Core\Locale\CountryManagerInterface
*/
protected $countryManager;
/**
* {@inheritdoc}
*/
......@@ -47,6 +53,7 @@ class Telephone extends TextBase {
$instance->telephoneValidator = ($instance->moduleHandler->moduleExists('telephone_validation'))
? $container->get('telephone_validation.validator')
: NULL;
$instance->countryManager = $container->get('country_manager');
return $instance;
}
......@@ -159,7 +166,7 @@ class Telephone extends TextBase {
'#title' => $this->t('Initial country'),
'#type' => 'select',
'#empty_option' => $this->t('- None -'),
'#options' => CountryManager::getStandardList(),
'#options' => $this->countryManager->getList(),
'#states' => [
'visible' => [':input[name="properties[international]"]' => ['checked' => TRUE]],
],
......@@ -167,7 +174,7 @@ class Telephone extends TextBase {
$form['telephone']['international_preferred_countries'] = [
'#title' => $this->t('Preferred countries'),
'#type' => 'select',
'#options' => CountryManager::getStandardList(),
'#options' => $this->countryManager->getList(),
'#description' => $this->t('Specify the countries to appear at the top of the list.'),
'#select2' => TRUE,
'#multiple' => TRUE,
......
......@@ -5,6 +5,7 @@ namespace Drupal\webform\Plugin\WebformElement;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Locale\CountryManager;
use Drupal\webform\WebformSubmissionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'telephone' (composite) element.
......@@ -20,6 +21,22 @@ use Drupal\webform\WebformSubmissionInterface;
*/
class WebformTelephone extends WebformCompositeBase {
/**
* The country manager.
*
* @var \Drupal\Core\Locale\CountryManagerInterface
*/
protected $countryManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
$instance->countryManager = $container->get('country_manager');
return $instance;
}
/**
* {@inheritdoc}
*/
......@@ -102,6 +119,7 @@ class WebformTelephone extends WebformCompositeBase {
*/
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['composite']['phone__international'] = [
'#title' => $this->t('Enhance support for international phone numbers'),
'#type' => 'checkbox',
......@@ -114,7 +132,7 @@ class WebformTelephone extends WebformCompositeBase {
'#empty_option' => $this->t('- None -'),
'#options' => [
'auto' => $this->t('Auto detect'),
] + CountryManager::getStandardList(),
] + $this->countryManager->getList(),
'#states' => [
'visible' => [
':input[name="properties[phone__international]"]' => ['checked' => TRUE],
......
......@@ -1033,8 +1033,10 @@ class WebformSubmissionExporter implements WebformSubmissionExporterInterface {
$latest_query->sort('sid', 'DESC');
$latest_query->range(0, (int) $export_options['range_latest']);
if ($latest_query_entity_ids = $latest_query->execute()) {
$query->condition('sid', end($latest_query_entity_ids), '>=');
$query->condition('sid', $latest_query_entity_ids, 'IN');
}
$query->sort('created');
$query->sort('sid');
}
else {
// Sort by created and sid in ASC or DESC order.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment