You are here

protected function ComputedItemList::ensurePopulated in Salesforce Suite 8.3

Makes sure that the item list is never empty.

For 'normal' fields that use database storage the field item list is initially empty, but since this is a computed field this always has a value. Make sure the item list is always populated, so this field is not skipped for rendering in EntityViewDisplay and friends.

@todo This will no longer be necessary once #2392845 is fixed.

See also

https://www.drupal.org/node/2392845

3 calls to ComputedItemList::ensurePopulated()
ComputedItemList::getIterator in modules/salesforce_mapping/src/Plugin/Field/ComputedItemList.php
ComputedItemList::getValue in modules/salesforce_mapping/src/Plugin/Field/ComputedItemList.php
Gets the data value.
ComputedItemList::isEmpty in modules/salesforce_mapping/src/Plugin/Field/ComputedItemList.php
Determines whether the list contains any non-empty items.

File

modules/salesforce_mapping/src/Plugin/Field/ComputedItemList.php, line 51

Class

ComputedItemList
Lifted from https://www.drupal.org/docs/8/api/entity-api/dynamicvirtual-field-values....

Namespace

Drupal\salesforce_mapping\Plugin\Field

Code

protected function ensurePopulated() {
  if (!isset($this->list[0])) {
    $this->list[0] = $this
      ->createItem(0);
  }
}