You are here

public function DisplayHelper::getNewFields in Lightning Core 8

Same name and namespace in other branches
  1. 8.5 src/DisplayHelper.php \Drupal\lightning_core\DisplayHelper::getNewFields()
  2. 8.2 src/DisplayHelper.php \Drupal\lightning_core\DisplayHelper::getNewFields()
  3. 8.3 src/DisplayHelper.php \Drupal\lightning_core\DisplayHelper::getNewFields()
  4. 8.4 src/DisplayHelper.php \Drupal\lightning_core\DisplayHelper::getNewFields()

Returns newly added field components, optionally filtered by a function.

Parameters

\Drupal\Core\Entity\Display\EntityDisplayInterface $display: The display config entity.

callable|NULL $filter: (optional) The function on which to filter the fields, accepting the field storage definition as an argument.

Return value

array The newly added components.

File

src/DisplayHelper.php, line 98

Class

DisplayHelper
Helps query and configure various display settings.

Namespace

Drupal\lightning_core

Code

public function getNewFields(EntityDisplayInterface $display, callable $filter = NULL) {
  $fields = $this->entityFieldManager
    ->getFieldStorageDefinitions($display
    ->getTargetEntityTypeId());
  if ($filter) {
    $fields = array_filter($fields, $filter);
  }
  return array_intersect_key($this
    ->getNewComponents($display), $fields);
}