function EntityReferenceFormatterTest::createNonCacheableViewMode
Creates a non cacheable view mode.
4 calls to EntityReferenceFormatterTest::createNonCacheableViewMode()
- EntityReferenceFormatterTest::testEntityFormatterIterativeRendering in core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceFormatterTest.php - Tests that iterative rendering is allowed by recursive render protection.
- EntityReferenceFormatterTest::testEntityFormatterRecursiveRendering in core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceFormatterTest.php - Tests the recursive rendering protection of the entity formatter.
- EntityReferenceFormatterTest::testEntityReferenceRecursionProtectionWithRepeatedReferencingEntity in core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceFormatterTest.php - Tests multiple renderings of an entity that references another.
- EntityReferenceFormatterTest::testEntityReferenceRecursiveProtectionWithManyRenderedEntities in core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceFormatterTest.php - Renders the same entity referenced from different places.
File
-
core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceFormatterTest.php, line 604
Class
- EntityReferenceFormatterTest
- Tests the formatters functionality.
Namespace
Drupal\Tests\field\Kernel\EntityReferenceCode
protected function createNonCacheableViewMode() : void {
EntityViewMode::create([
'id' => $this->entityType . '.' . $this->nonCacheableViewMode,
'label' => 'No cache view mode',
'targetEntityType' => $this->entityType,
'cache' => FALSE,
])
->save();
// Set the new view mode to use the 'entity_reference_entity_view'
// formatter displaying entities in non cacheable view mode as well.
EntityViewDisplay::create([
'targetEntityType' => $this->entityType,
'bundle' => $this->bundle,
'mode' => $this->nonCacheableViewMode,
'status' => TRUE,
])
->setComponent($this->fieldName, [
'type' => 'entity_reference_entity_view',
'settings' => [
'view_mode' => $this->nonCacheableViewMode,
],
])
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.