You are here

protected function OpignoUserSelectionController::getEntityField in Opigno Learning path 3.x

@opigno_deprecated

2 calls to OpignoUserSelectionController::getEntityField()
OpignoUserSelectionController::getGroupImage in modules/opigno_user_selection/src/Controller/OpignoUserSelectionController.php
@opigno_deprecated
OpignoUserSelectionController::getuserAvatar in modules/opigno_user_selection/src/Controller/OpignoUserSelectionController.php
@opigno_deprecated

File

modules/opigno_user_selection/src/Controller/OpignoUserSelectionController.php, line 62

Class

OpignoUserSelectionController
Returns responses for Opigno User Selection routes.

Namespace

Drupal\opigno_user_selection\Controller

Code

protected function getEntityField(EntityInterface $entity, string $field_name) {

  /** @var \Drupal\Core\Entity\FieldableEntityInterface $user */
  if ($entity
    ->hasField($field_name) && !($field = $entity
    ->get($field_name))
    ->isEmpty()) {
    if (($child_entity = $field->entity) instanceof EntityInterface) {
      return $child_entity;
    }
  }
  return FALSE;
}