public function ElementEntityClassTrait::viewElements in Element Class Formatter 8        
                          
                  
                        
File
 
   - src/Plugin/Field/FieldFormatter/ElementEntityClassTrait.php, line 48
 
  
  Class
  
  - ElementEntityClassTrait 
 
  - The ElementEntityClassTrait is used for adding classes to the
#item_attributes of fields that display other entities.
 
  Namespace
  Drupal\element_class_formatter\Plugin\Field\FieldFormatter
Code
public function viewElements(FieldItemListInterface $items, $langcode) {
  $elements = parent::viewElements($items, $langcode);
  $entities = $this
    ->getEntitiesToView($items, $langcode);
  $class = $this
    ->getSetting('class');
  return $this
    ->setEntityClass($elements, $class, $entities);
}