protected function IefTableViewModeTestTrait::configureViewModeIef in Inline Entity Form Table View Mode 8.2
Configured the view mode ief_table.
Parameters
string $entity_type_id: The entity type id to configure.
string $bundle: The bundle to configure.
array $components: An array of component names to configure in the view mode.
Throws
\Drupal\Core\Entity\EntityStorageException
1 call to IefTableViewModeTestTrait::configureViewModeIef()
- ComplexTableViewModeWidgetTest::testWidgetBehaviorBeforeAndAfterConfigureTheViewModeIef in tests/
src/ FunctionalJavascript/ ComplexTableViewModeWidgetTest.php - Test the widget behavior before and after configure the view mode ief.
File
- tests/
src/ Traits/ IefTableViewModeTestTrait.php, line 101
Class
- IefTableViewModeTestTrait
- Provides common functionality for the IEF table view mode test classes.
Namespace
Drupal\Tests\ief_table_view_mode\TraitsCode
protected function configureViewModeIef($entity_type_id, $bundle, array $components) {
$ief_view_mode = $entity_type_id . '.' . EntityInlineTableViewModeForm::IEF_TABLE_VIEW_MODE_NAME;
// Create the view mode ief_table if not exists.
if (!EntityViewMode::load($ief_view_mode)) {
$view_mode = EntityViewMode::create([
'id' => $ief_view_mode,
'label' => 'Inline Entity Form Table',
'targetEntityType' => $entity_type_id,
]);
$view_mode
->save();
}
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
if (!($display = EntityViewDisplay::load("{$entity_type_id}.{$bundle}." . EntityInlineTableViewModeForm::IEF_TABLE_VIEW_MODE_NAME))) {
$display = EntityViewDisplay::create([
'targetEntityType' => $entity_type_id,
'bundle' => $bundle,
'mode' => EntityInlineTableViewModeForm::IEF_TABLE_VIEW_MODE_NAME,
'status' => TRUE,
]);
$display
->save();
}
$this
->assertNotNull($display, 'Configure the view display ief table.');
foreach ($display
->getComponents() as $component_name => $component) {
$display
->removeComponent($component_name);
}
foreach ($components as $component_name) {
$display
->setComponent($component_name);
}
$display
->save();
$this
->assertTrue(TRUE, new FormattableMarkup('The view mode ief_table is configured with the follow components: (%components).', [
'%components' => implode(', ', $components),
]));
}