public function FivestarItem::getTargetEntity in Fivestar 8
Get target entity.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface $entity:
array $field_settings:
Return value
\Drupal\Core\Entity\FieldableEntityInterface|null
2 calls to FivestarItem::getTargetEntity()
- FivestarItem::delete in src/
Plugin/ Field/ FieldType/ FivestarItem.php - Defines custom delete behavior for field values.
- FivestarItem::postSave in src/
Plugin/ Field/ FieldType/ FivestarItem.php - Defines custom post-save behavior for field values.
File
- src/
Plugin/ Field/ FieldType/ FivestarItem.php, line 295
Class
- FivestarItem
- Plugin implementation of the 'fivestar' field type.
Namespace
Drupal\fivestar\Plugin\Field\FieldTypeCode
public function getTargetEntity(FieldableEntityInterface $entity, array $field_settings) {
if ($field_settings['enable_voting_target'] !== TRUE) {
return NULL;
}
if (!$entity
->hasField($field_settings['target_bridge_field'])) {
return NULL;
}
$bridge_entity = $entity->{$field_settings['target_bridge_field']}->entity;
if ($bridge_entity && $bridge_entity
->hasField($field_settings['target_fivestar_field'])) {
return $bridge_entity;
}
return NULL;
}