Commit dc0cfdbe authored by jrockowitz's avatar jrockowitz Committed by jrockowitz

Issue #2912426 by jrockowitz: 8.x-5.0-beta19 release

parent f37bee64
......@@ -136,7 +136,7 @@ function webform_requirements($phase) {
'#suffix' => '</strong></dt>',
],
'description' => [
'#markup' => $project['description'],
'#markup' => $project['description'],
'#prefix' => '<dd>',
'#suffix' => '</dd>',
],
......
......@@ -175,8 +175,8 @@ class WebformUiElementTestForm extends WebformUiElementFormBase {
// Rebuild is throwing the below error.
// LogicException: Settings can not be serialized.
// $form_state->setRebuild();
// @todo Determine what object is being serialized with webform.
// @todo Determine what object is being serialized with webform
//
// The webform element configuration is stored in the 'properties' key in
// the webform, pass that through for submission.
$element_form_state = clone $form_state;
......
......@@ -101,7 +101,7 @@ abstract class WebformCompositeBase extends FormElement {
}
// Make sure to remove any #options reference on textfields
// To prevnnt "An illegal choice has been detected." error
// To prevnnt "An illegal choice has been detected." error.
// @see FormValidator::performRequiredValidation()
if ($composite_element['#type'] == 'textfield') {
unset($composite_element['#options']);
......@@ -204,4 +204,5 @@ abstract class WebformCompositeBase extends FormElement {
$form_state->setValueForElement($element, NULL);
}
}
}
......@@ -90,7 +90,7 @@ class WebformElementMultiple extends FormElement {
],
];
// Set disabled
// Set disabled.
if (!empty($element['#disabled'])) {
$element['container']['cardinality']['#disabled'] = TRUE;
$element['container']['cardinality_number']['#disabled'] = TRUE;
......
......@@ -714,7 +714,7 @@ class WebformElementStates extends FormElement {
* @return array
* An associative array of translated state options.
*/
static public function getStateOptions() {
public static function getStateOptions() {
return [
'visible' => t('Visible'),
'invisible' => t('Hidden'),
......@@ -735,7 +735,7 @@ class WebformElementStates extends FormElement {
* @return array
* An associative array of translated trigger options.
*/
static public function getTriggerOptions() {
public static function getTriggerOptions() {
return [
'empty' => t('Empty'),
'filled' => t('Filled'),
......
......@@ -85,7 +85,9 @@ abstract class WebformExcludedBase extends FormElement {
* @return array
* An array container the header for the excluded tableselect element.
*/
public static function getWebformExcludedHeader() { }
public static function getWebformExcludedHeader() {
return [];
}
/**
* Get options for excluded tableselect element.
......@@ -98,6 +100,8 @@ abstract class WebformExcludedBase extends FormElement {
* An array of options containing title, name, and type of items for a
* tableselect element.
*/
public static function getWebformExcludedOptions(array $element) { }
public static function getWebformExcludedOptions(array $element) {
return [];
}
}
......@@ -57,7 +57,7 @@ class WebformHtmlEditor extends FormElement {
* Prepares a #type 'webform_html_editor' render element for input.html.twig.
*
* @param array $element
* An associative array containing the properties of the element
* An associative array containing the properties of the element.
*
* @return array
* The HTML Editor which can be a CodeMirror element, TextFormat, or
......@@ -83,7 +83,7 @@ class WebformHtmlEditor extends FormElement {
return $element;
}
// If #context and format is defined return 'text_format' element
// If #context and format is defined return 'text_format' element.
$format = \Drupal::config('webform.settings')->get('html_editor.format') ?: $element['#format'];
if ($format) {
$element['value'] += [
......@@ -131,7 +131,7 @@ class WebformHtmlEditor extends FormElement {
if (isset($element['#states'])) {
webform_process_states($element, '#wrapper_attributes');
}
return $element;
}
......@@ -192,15 +192,12 @@ class WebformHtmlEditor extends FormElement {
$allowed_tags[] = 'fieldset';
$allowed_tags[] = 'legend';
return $allowed_tags;
break;
case 'html':
return Xss::getHtmlTagList();
break;
default:
return preg_split('/ +/', $allowed_tags);
break;
}
}
......@@ -227,7 +224,7 @@ class WebformHtmlEditor extends FormElement {
$text = preg_replace('#</p>\s*$#', '', $text);
}
}
if ($format = \Drupal::config('webform.settings')->get('html_editor.format')) {
if ($render) {
return check_markup($text, $format);
......@@ -256,7 +253,7 @@ class WebformHtmlEditor extends FormElement {
/**
* Strip dis-allowed HTML tags from HTML text.
*
* @param $text
* @param string $text
* HTML text.
*
* @return string
......
......@@ -9,7 +9,6 @@ use Drupal\Core\Render\Markup;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Utility\WebformElementHelper;
/**
* Provides a webform element to assist in creation of multiple elements.
*
......
......@@ -199,7 +199,7 @@ class WebformOptions extends FormElement {
if ($options_description && !empty($value['description'])) {
$option_text .= WebformOptionsHelper::DESCRIPTION_DELIMITER . $value['description'];
}
// Populate empty option value or option text.
if ($option_value === '') {
$option_value = $option_text;
......
......@@ -95,7 +95,7 @@ class WebformSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
static public function getSubscribedEvents() {
public static function getSubscribedEvents() {
$events = [];
$events[KernelEvents::RESPONSE][] = ['onRespondRedirectPrivateFileAccess'];
return $events;
......
......@@ -224,7 +224,7 @@ class WebformSubmissionLimitBlock extends BlockBase implements ContainerFactoryP
$form_state->setError($form['advanced']['entity_id'], $this->t('An %label id is required.', $t_args));
}
elseif (!$this->entityTypeManager->getStorage($values['entity_type'])->load($values['entity_id'])) {
$form_state->setError($form['advanced']['entity_id'], $this->t('A valid %label is required.', $t_args ));
$form_state->setError($form['advanced']['entity_id'], $this->t('A valid %label is required.', $t_args));
}
}
}
......@@ -255,7 +255,7 @@ class WebformSubmissionLimitBlock extends BlockBase implements ContainerFactoryP
$limit = $this->getLimit();
$build['progress_bar'] = [
'#theme' => 'progress_bar',
'#percent' => round(($total/$limit) * 100),
'#percent' => round(($total / $limit) * 100),
];
if ($message = $this->configuration['progress_bar_message']) {
$build['progress_bar']['#message']['#markup'] = $this->replaceTokens($message);
......@@ -372,7 +372,7 @@ class WebformSubmissionLimitBlock extends BlockBase implements ContainerFactoryP
/**
* Get the source entity.
*
* @return EntityInterface|bool|null
* @return \Drupal\Core\Entity\EntityInterface|bool|null
* The source entity, NULL the if source entity is not applicable,
* or FALSE if the source entity is not available.
*/
......@@ -433,7 +433,7 @@ class WebformSubmissionLimitBlock extends BlockBase implements ContainerFactoryP
*
* @param string $type
* The submission type which can be 'webform' or 'user'.
* @param $source_entity
* @param string $source_entity
* Flag indicating if source entity should be included in available tokens.
*
* @return array
......@@ -451,8 +451,8 @@ class WebformSubmissionLimitBlock extends BlockBase implements ContainerFactoryP
$token_name = self::getTokenName($token_type, $type, $source_entity);
$args = [
'@type' => $token_type,
'@name'=> $tokens[$token_name]['name'],
'@description'=> $tokens[$token_name]['description'],
'@name' => $tokens[$token_name]['name'],
'@description' => $tokens[$token_name]['description'],
];
$token_items[$token_type] = [
'#markup' => new FormattableMarkup('[@type] =&gt; @name<br/><em>@description</em>', $args),
......@@ -472,14 +472,14 @@ class WebformSubmissionLimitBlock extends BlockBase implements ContainerFactoryP
* Get token name.
*
* @param string $prefix
* Token prefix which can be 'total' or 'limit',
* Token prefix which can be 'total' or 'limit'.
* @param string $type
* The submission type which can be 'webform' or 'user'.
* @param $source_entity
* Flag indicating if source entity should be included in available tokens.
*
* @return string
* A token name
* A token name.
*/
protected static function getTokenName($prefix = 'limit', $type, $source_entity = FALSE) {
$parts = [$prefix, $type];
......
......@@ -32,7 +32,7 @@ class Webform extends ConditionPluginBase implements ContainerFactoryPluginInter
protected $entityStorage;
/**
* The webform entity reference manager
* The webform entity reference manager.
*
* @var \Drupal\webform\WebformEntityReferenceManagerInterface
*/
......
......@@ -83,7 +83,7 @@ class WebformSubmissionDevelGenerate extends DevelGenerateBase implements Contai
protected $webformSubmissionGenerate;
/**
* The webform entity reference manager
* The webform entity reference manager.
*
* @var \Drupal\webform\WebformEntityReferenceManagerInterface
*/
......@@ -280,7 +280,11 @@ class WebformSubmissionDevelGenerate extends DevelGenerateBase implements Contai
$this->generateSubmission($values);
if (function_exists('drush_log') && $i % drush_get_option('feedback', 1000) == 0) {
$now = time();
drush_log(dt('Completed @feedback submissions (@rate submissions/min)', ['@feedback' => drush_get_option('feedback', 1000), '@rate' => (drush_get_option('feedback', 1000) * 60) / ($now - $start)]), 'ok');
$dt_args = [
'@feedback' => drush_get_option('feedback', 1000),
'@rate' => (drush_get_option('feedback', 1000) * 60) / ($now - $start),
];
drush_log(dt('Completed @feedback submissions (@rate submissions/min)', $dt_args), 'ok');
$start = $now;
}
}
......
......@@ -5,7 +5,6 @@ namespace Drupal\webform\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\webform\WebformMessageManagerInterface;
/**
* Plugin implementation of the 'Webform rendered entity' formatter.
......@@ -26,8 +25,8 @@ class WebformEntityReferenceEntityFormatter extends WebformEntityReferenceFormat
*/
public static function defaultSettings() {
return [
'source_entity' => TRUE,
] + parent::defaultSettings();
'source_entity' => TRUE,
] + parent::defaultSettings();
}
/**
......@@ -68,7 +67,8 @@ class WebformEntityReferenceEntityFormatter extends WebformEntityReferenceFormat
$elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
// Do not display the webform if the current user can't create submissions.
// Do not display the webform if the current user can't
// create submissions.
if ($entity->id() && !$entity->access('submission_create')) {
$elements[$delta] = [];
}
......
......@@ -2,14 +2,11 @@
namespace Drupal\webform\Plugin\Field\FieldType;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\webform\WebformInterface;
/**
......@@ -109,7 +106,6 @@ class WebformEntityReferenceItem extends EntityReferenceItem {
return $properties;
}
/**
* {@inheritdoc}
*/
......
......@@ -28,7 +28,7 @@ class Checkboxes extends OptionsBase {
'multiple_error' => '',
// Options settings.
'options_display' => 'one_column',
'options_description_display' => 'description',
'options_description_display' => 'description',
// iCheck settings.
'icheck' => '',
];
......
......@@ -31,7 +31,7 @@ abstract class DateBase extends WebformElementBase {
/****************************************************************************/
// Element rendering methods.
/****************************************************************************/
/**
* {@inheritdoc}
*/
......
......@@ -42,7 +42,6 @@ class DateList extends DateBase {
];
}
/**
* {@inheritdoc}
*/
......@@ -208,11 +207,10 @@ class DateList extends DateBase {
parent::setConfigurationFormDefaultValue($form, $element_properties, $property_element, $property_name);
}
/**
* After build handler for Datelist element.
*/
public static function afterBuild(array $element, \Drupal\Core\Form\FormStateInterface $form_state) {
public static function afterBuild(array $element, FormStateInterface $form_state) {
// Reverse years from min:max to max:min.
// @see \Drupal\Core\Datetime\Element\DateElementBase::datetimeRangeYears
if (!empty($element['#date_year_range_reverse']) && isset($element['year']) && isset($element['year']['#options'])) {
......
......@@ -379,7 +379,7 @@ class DateTime extends DateBase {
/**
* After build handler for Datetime elements.
*/
public static function afterBuild(array $element, \Drupal\Core\Form\FormStateInterface $form_state) {
public static function afterBuild(array $element, FormStateInterface $form_state) {
if (isset($element['time'])) {
if (!empty($element['#date_time_min'])) {
$element['time']['#min'] = $element['#date_time_min'];
......
......@@ -174,4 +174,5 @@ class EntityAutocomplete extends WebformElementBase implements WebformElementEnt
return $item;
}
}
}
......@@ -63,5 +63,5 @@ class Item extends WebformMarkup {
'#field_suffix' => '{field_suffix}',
];
}
}
......@@ -21,14 +21,14 @@ class Label extends ContainerBase {
*/
public function getDefaultProperties() {
return [
'title' => '',
// General settings.
'description' => '',
// Form validation.
'required' => FALSE,
// Attributes.
'attributes' => [],
] + $this->getDefaultBaseProperties();
'title' => '',
// General settings.
'description' => '',
// Form validation.
'required' => FALSE,
// Attributes.
'attributes' => [],
] + $this->getDefaultBaseProperties();
}
/**
......
......@@ -95,7 +95,7 @@ abstract class OptionsBase extends WebformElementBase {
/**
* Get the other option base element type.
*
* @return string|NULL
* @return string|null
* The base element type (select|radios|checkboxes|buttons).
*/
protected function getOptionsOtherType() {
......@@ -110,14 +110,17 @@ abstract class OptionsBase extends WebformElementBase {
$this->otherOptionType = FALSE;
}
return $this->otherOptionType ;
return $this->otherOptionType;
}
/**
* {@inheritdoc}
*/
public function getTranslatableProperties() {
return array_merge(parent::getTranslatableProperties(), ['options', 'empty_option', 'option_label']);
return array_merge(
parent::getTranslatableProperties(),
['options', 'empty_option', 'option_label']
);
}
/**
......@@ -140,7 +143,7 @@ abstract class OptionsBase extends WebformElementBase {
* {@inheritdoc}
*/
public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
$is_wrapper_fieldset = in_array($element['#type'], ['checkboxes', 'radios', 'webform_entity_checkboxes', 'webform_entity_radios', 'webform_term_checkboxes','webform_toggles', 'webform_buttons']);
$is_wrapper_fieldset = in_array($element['#type'], ['checkboxes', 'radios', 'webform_entity_checkboxes', 'webform_entity_radios', 'webform_term_checkboxes', 'webform_toggles', 'webform_buttons']);
if ($is_wrapper_fieldset) {
// Issue #2396145: Option #description_display for webform element fieldset
// is not changing anything.
......@@ -458,7 +461,6 @@ abstract class OptionsBase extends WebformElementBase {
}
}
/**
* {@inheritdoc}
*/
......
......@@ -62,12 +62,12 @@ class Range extends NumericBase {
*/
public function preview() {
return parent::preview() + [
'#min'=> 0,
'#max'=> 100,
'#step'=> 1,
'#range__output'=> TRUE,
'#range__output_prefix'=> '$',
'#range__output_suffix'=> '.00',
'#min' => 0,
'#max' => 100,
'#step' => 1,
'#range__output' => TRUE,
'#range__output_prefix' => '$',
'#range__output_suffix' => '.00',
];
}
......
......@@ -98,9 +98,9 @@ class Telephone extends TextBase {
// Issue #2484693: Telephone Link field formatter breaks Drupal with 5
// digits or less in the number
// return [
// '#type' => 'link',
// '#title' => $value,
// '#url' => \Drupal::pathValidator()->getUrlIfValid('tel:' . $value),
// '#type' => 'link',
// '#title' => $value,
// '#url' => \Drupal::pathValidator()->getUrlIfValid('tel:' . $value),
// ];
// Workaround: Manually build a static HTML link.
$t_args = [':tel' => 'tel:' . $value, '@tel' => $value];
......
......@@ -103,7 +103,7 @@ abstract class TextBase extends WebformElementBase {
],
];
if ($this->librariesManager->isExcluded('jquery.inputmask')) {
$form['form']['input_mask'] ['#access'] = FALSE;
$form['form']['input_mask']['#access'] = FALSE;
}
// Pattern.
......
......@@ -7,7 +7,6 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Mail\MailFormatHelper;
use Drupal\filter\Entity\FilterFormat;
use Drupal\webform\Plugin\WebformElementBase;
use Drupal\webform\WebformSubmissionConditionsValidator;
use Drupal\webform\WebformSubmissionInterface;
/**
......@@ -246,4 +245,5 @@ class TextFormat extends WebformElementBase {
$elements = $this->getCompositeElements();
return (isset($elements[$key])) ? TRUE : FALSE;
}
}
......@@ -145,13 +145,13 @@ trait WebformEntityReferenceTrait {
*/
public function getItemFormats() {
$formats = parent::getItemFormats() + [
'link' => $this->t('Link'),
'id' => $this->t('Entity ID'),
'label' => $this->t('Label'),
'text' => $this->t('Label (ID)'),
'teaser' => $this->t('Teaser'),
'default' => $this->t('Default'),
];
'link' => $this->t('Link'),
'id' => $this->t('Entity ID'),
'label' => $this->t('Label'),
'text' => $this->t('Label (ID)'),
'teaser' => $this->t('Teaser'),
'default' => $this->t('Default'),
];
if ($this->hasProperty('breadcrumb')) {
$formats['breadcrumb'] = $this->t('Breadcrumb');
}
......@@ -545,7 +545,7 @@ trait WebformEntityReferenceTrait {
'js-hide',
'js-webform-entity-reference-submit',
'js-webform-novalidate',
]
],
],
];
......@@ -626,7 +626,7 @@ trait WebformEntityReferenceTrait {
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
static public function validateEntityReferenceCallback(array $form, FormStateInterface $form_state) {
public static function validateEntityReferenceCallback(array $form, FormStateInterface $form_state) {
$form_state->clearErrors();
}
......@@ -638,7 +638,7 @@ trait WebformEntityReferenceTrait {
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
static public function submitEntityReferenceCallback(array $form, FormStateInterface $form_state) {
public static function submitEntityReferenceCallback(array $form, FormStateInterface $form_state) {
$form_state->setRebuild();
}
......@@ -653,7 +653,7 @@ trait WebformEntityReferenceTrait {
* @return array
* The properties element.
*/
static public function entityReferenceAjaxCallback(array $form, FormStateInterface $form_state) {
public static function entityReferenceAjaxCallback(array $form, FormStateInterface $form_state) {
$button = $form_state->getTriggeringElement();
$element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1));
return $element;
......
......@@ -83,4 +83,4 @@ class WebformImageFile extends WebformManagedFileBase {
}
}
}
\ No newline at end of file
}
......@@ -324,7 +324,7 @@ class WebformLikert extends WebformElementBase {
return $this->formatHtml($element, $webform_submission);
}
}
/**
* {@inheritdoc}
*/
......@@ -342,7 +342,7 @@ class WebformLikert extends WebformElementBase {
],
];
}
/**
* {@inheritdoc}
*/
......
......@@ -97,7 +97,6 @@ class WebformTermsOfService extends Checkbox {
];
}
/**
* {@inheritdoc}
*/
......@@ -116,7 +115,7 @@ class WebformTermsOfService extends Checkbox {
'#options' => [
WebformTermsOfServiceElement::TERMS_MODAL => $this->t('Modal'),
WebformTermsOfServiceElement::TERMS_SLIDEOUT => $this->t('Slideout'),
]
],
];
$form['terms_of_service']['terms_title'] = [
'#type' => 'textfield',
......
......@@ -649,7 +649,8 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
$element['#element_validate'] = $element_validate;
}
// Add webform element #minlength, #unique, and/or #multiple validation handler.
// Add webform element #minlength, #unique, and/or #multiple
// validation handler.
if (isset($element['#minlength'])) {
$element['#element_validate'][] = [get_class($this), 'validateMinlength'];
}
......@@ -697,7 +698,7 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
* @param array $element
* The element.
* @param $operation
* The operation
* The operation.
* @param \Drupal\Core\Session\AccountInterface $account
* The user session for which to check access.
*
......@@ -1676,9 +1677,6 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
$form_object = $form_state->getFormObject();
$webform = $form_object->getWebform();
// Check if inline help is enabled and set inline form attributes.
$help_enabled = $this->configFactory->get('webform.settings')->get('ui.description_help');
/* Element settings */
$form['element'] = [
......@@ -1704,8 +1702,8 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
[':input[name="properties[title_display]"]' => ['value' => 'invisible']],
'or',
[':input[name="properties[title_display]"]' => ['value' => 'attribute']],
]
]
],
],
];
$form['element']['description'] = [
'#type' => 'webform_html_editor',
......@@ -2248,8 +2246,8 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
$form['token_tree_link'] = $this->tokenManager->buildTreeLink();
// Set custom properties.
// Note: Storing this information in the webform's state allows modules to view
// and alter this information using webform alteration hooks.
// Note: Storing this information in the webform's state allows modules to
// view and alter this information using webform alteration hooks.
$form_state->set('custom_properties', $custom_properties);
return $this->buildConfigurationFormTabs($form, $form_state);
......@@ -2290,7 +2288,7 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
],
'weight' => 10,
],
'advanced' => [
'advanced' => [
'title' => $this->t('Advanced'),
'elements' => [
'wrapper_attributes',
......@@ -2301,7 +2299,7 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
],
'weight' => 20,
],
'access' => [
'access' => [
'title' => $this->t('Access'),
'elements' => [
'access',
......@@ -2319,7 +2317,8 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
* A webform render array.
* @param array $element_properties
* The element's properties without hash prefix. Any property that is found
* in the webform will be populated and unset from $element_properties array.
* in the webform will be populated and unset from
* $element_properties array.
*
* @return bool
* TRUE is the webform has any inputs.
......@@ -2345,8 +2344,8 @@ class WebformElementBase extends PluginBase implements WebformElementInterface {
// Determine if the property element is an input using the webform element
// manager.
// Note: #access is used to protect inputs and containers that should always
// be visible.
// Note: #access is used to protect inputs and containers that should
// always be visible.
$is_input = $this->elementManager->getElementInstance($property_element)->isInput($property_element);
if ($is_input) {
if (isset($element_properties[$property_name])) {
......
......@@ -82,7 +82,7 @@ interface WebformElementManagerInterface extends PluginManagerInterface, CachedD
* Remove excluded plugin definitions.
*
* @param array $definitions
* The plugin definitions to filter
* The plugin definitions to filter.
*
* @return array
* An array of plugin definitions with excluded plugins removed.
......
......@@ -341,7 +341,7 @@ class EmailWebformHandler extends WebformHandlerBase implements WebformHandlerMe
'#title' => $this->t('Send from'),
'#open' => TRUE,
];
$form['from']['from_mail'] = $this->buildElement('from_mail', $this->t('From email'), $this->t('From email address'), $mail_element_options, $options_element_options, NULL, TRUE);
$form['from']['from_mail'] = $this->buildElement('from_mail', $this->t