function DefaultsSectionStorageTest::providerTestExtractEntityFromRoute
Provides data for ::testExtractEntityFromRoute().
File
- 
              core/
modules/ layout_builder/ tests/ src/ Unit/ DefaultsSectionStorageTest.php, line 151  
Class
- DefaultsSectionStorageTest
 - @coversDefaultClass \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage[[api-linebreak]]
 
Namespace
Drupal\Tests\layout_builder\UnitCode
public static function providerTestExtractEntityFromRoute() {
  // Data provider values are:
  // - whether a successful result is expected
  // - the expected entity ID
  // - the value to pass to ::extractEntityFromRoute()
  // - the defaults to pass to ::extractEntityFromRoute().
  $data = [];
  $data['with value'] = [
    TRUE,
    'foo.bar.baz',
    'foo.bar.baz',
    [],
  ];
  $data['empty value, without bundle'] = [
    TRUE,
    'my_entity_type.bundle_name.default',
    '',
    [
      'entity_type_id' => 'my_entity_type',
      'view_mode_name' => 'default',
      'bundle_key' => 'my_bundle',
      'my_bundle' => 'bundle_name',
    ],
  ];
  $data['empty value, with bundle'] = [
    TRUE,
    'my_entity_type.bundle_name.default',
    '',
    [
      'entity_type_id' => 'my_entity_type',
      'view_mode_name' => 'default',
      'bundle' => 'bundle_name',
    ],
  ];
  $data['without value, empty defaults'] = [
    FALSE,
    NULL,
    '',
    [],
  ];
  return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.