Skip to content
Snippets Groups Projects

Issue #3203024: Fix what reported by phpcs

2 files
+ 16
15
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -4,20 +4,20 @@ namespace Drupal\default_paragraphs\Plugin\Field\FieldWidget;
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldFilteredMarkup;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Utility\Token;
use Drupal\default_paragraphs\Events\DefaultParagraphsAddEvent;
use Drupal\default_paragraphs\Events\DefaultParagraphsEvents;
use Drupal\paragraphs\Entity\Paragraph;
use Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Utility\Token;
/**
* Plugin implementation of the 'entity_reference_revisions paragraphs' widget.
@@ -71,7 +71,7 @@ class DefaultParagraphsWidget extends ParagraphsWidget implements ContainerFacto
* Event dispatcher service.
* @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
* The entity display repository.
* @param \Drupal\Core\Utility\Token $token_service.
* @param \Drupal\Core\Utility\Token $token_service
* Token service.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EventDispatcherInterface $event_dispatcher, EntityDisplayRepositoryInterface $entity_display_repository, Token $token_service) {
@@ -203,8 +203,8 @@ class DefaultParagraphsWidget extends ParagraphsWidget implements ContainerFacto
],
],
'#element_validate' => [
[$this, 'settingsFormDefaultParagraphsValidate']
]
[$this, 'settingsFormDefaultParagraphsValidate'],
],
];
// We iterate over the allowed paragraph types, if nothing is selected yet.
@@ -242,7 +242,7 @@ class DefaultParagraphsWidget extends ParagraphsWidget implements ContainerFacto
],
'value' => [
'#type' => 'checkbox',
'#default_value' => isset($defaults[$key]['value']) ? $defaults[$key]['value'] : 0,
'#default_value' => $defaults[$key]['value'] ?? 0,
],
'edit_mode' => [
'#type' => 'select',
@@ -250,7 +250,7 @@ class DefaultParagraphsWidget extends ParagraphsWidget implements ContainerFacto
'edit' => $this->t('Open'),
'closed' => $this->t('Closed'),
],
'#default_value' => isset($defaults[$key]['edit_mode']) ? $defaults[$key]['edit_mode'] : 'closed',
'#default_value' => $defaults[$key]['edit_mode'] ?? 'closed',
],
'weight' => [
'#type' => 'weight',
@@ -265,7 +265,7 @@ class DefaultParagraphsWidget extends ParagraphsWidget implements ContainerFacto
];
$elements['default_paragraph_types'][$key]['#attributes']['class'][] = 'draggable';
$elements['default_paragraph_types'][$key]['#weight'] = isset($defaults[$key]['weight']) ? $defaults[$key]['weight'] : 1000;
$elements['default_paragraph_types'][$key]['#weight'] = $defaults[$key]['weight'] ?? 1000;
}
}
@@ -283,16 +283,16 @@ class DefaultParagraphsWidget extends ParagraphsWidget implements ContainerFacto
if ($cardinality !== -1) {
$default_paragraph_count = 0;
foreach ($element['#value'] as $key => $data) {
foreach ($element['#value'] as $data) {
if (!empty($data['value'])) {
$default_paragraph_count++;
}
}
if ($default_paragraph_count > $cardinality) {
$form_state->setErrorByName('default_paragraph_types', t('@field field allows you to select not more than @total paragraph types as default.', [
$form_state->setErrorByName('default_paragraph_types', $this->t('@field field allows you to select not more than @total paragraph types as default.', [
'@field' => $field_label,
'@total' => $cardinality
'@total' => $cardinality,
]));
}
}
@@ -358,7 +358,7 @@ class DefaultParagraphsWidget extends ParagraphsWidget implements ContainerFacto
$field_state['paragraphs'][$delta] = [
'entity' => $paragraphs_entity,
'display' => $display,
'mode' => isset($default_type['edit_mode']) ? $default_type['edit_mode'] : 'closed',
'mode' => $default_type['edit_mode'] ?? 'closed',
'original_delta' => 1,
];
$max++;
Loading