Loading phpcs.xml +6 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,12 @@ <exclude-pattern>*/icons/*</exclude-pattern> <exclude-pattern>*/vendor/*</exclude-pattern> <!-- @todo Remove temporary fix when drupal.org testbot script is changed. See https://www.drupal.org/node/3283978 --> <config name="installed_paths" value="../../drupal/coder/coder_sniffer/,../../sirbrillig/phpcs-variable-analysis/,../../slevomat/coding-standard/"/> <rule ref="Drupal"/> <rule ref="DrupalPractice"/> </ruleset> src/Plugin/Field/FieldWidget/ViewModeSwitchWidget.php +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ class ViewModeSwitchWidget extends WidgetBase { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state): array { $value = isset($items[$delta]->value) ? $items[$delta]->value : ''; $value = $items[$delta]->value ?? ''; // Determine view modes allowed to switch to. $options_provider = $this->fieldDefinition Loading src/ViewModeHelper.php +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ class ViewModeHelper implements ViewModeHelperInterface { * {@inheritdoc} */ public function getName(EntityViewModeInterface $entity): string { list(/* Entity type */, $name) = explode('.', (string) $entity->id()); [/* Entity type */, $name] = explode('.', (string) $entity->id()); return $name; } Loading tests/src/Kernel/ViewModeSwitchTest.php +3 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,9 @@ class ViewModeSwitchTest extends ViewModeSwitchTestBase { $this->assertEquals('Recursion detected when trying to switch %origin_view_mode view mode via %view_mode_switches.', $log->message); // Test recursion detection log message context. $variables = unserialize($log->variables); $variables = unserialize($log->variables, [ 'allowed_classes' => FALSE, ]); $this->assertIsArray($variables); $this->assertEquals('foo', $variables['%origin_view_mode']); $this->assertEquals('foo › foo1 › foo', $variables['%view_mode_switches']); Loading Loading
phpcs.xml +6 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,12 @@ <exclude-pattern>*/icons/*</exclude-pattern> <exclude-pattern>*/vendor/*</exclude-pattern> <!-- @todo Remove temporary fix when drupal.org testbot script is changed. See https://www.drupal.org/node/3283978 --> <config name="installed_paths" value="../../drupal/coder/coder_sniffer/,../../sirbrillig/phpcs-variable-analysis/,../../slevomat/coding-standard/"/> <rule ref="Drupal"/> <rule ref="DrupalPractice"/> </ruleset>
src/Plugin/Field/FieldWidget/ViewModeSwitchWidget.php +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ class ViewModeSwitchWidget extends WidgetBase { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state): array { $value = isset($items[$delta]->value) ? $items[$delta]->value : ''; $value = $items[$delta]->value ?? ''; // Determine view modes allowed to switch to. $options_provider = $this->fieldDefinition Loading
src/ViewModeHelper.php +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ class ViewModeHelper implements ViewModeHelperInterface { * {@inheritdoc} */ public function getName(EntityViewModeInterface $entity): string { list(/* Entity type */, $name) = explode('.', (string) $entity->id()); [/* Entity type */, $name] = explode('.', (string) $entity->id()); return $name; } Loading
tests/src/Kernel/ViewModeSwitchTest.php +3 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,9 @@ class ViewModeSwitchTest extends ViewModeSwitchTestBase { $this->assertEquals('Recursion detected when trying to switch %origin_view_mode view mode via %view_mode_switches.', $log->message); // Test recursion detection log message context. $variables = unserialize($log->variables); $variables = unserialize($log->variables, [ 'allowed_classes' => FALSE, ]); $this->assertIsArray($variables); $this->assertEquals('foo', $variables['%origin_view_mode']); $this->assertEquals('foo › foo1 › foo', $variables['%view_mode_switches']); Loading