You are here

public function OpignoCertificate::getViewModeSelectorField in Opigno certificate 8

Same name and namespace in other branches
  1. 3.x src/Entity/OpignoCertificate.php \Drupal\opigno_certificate\Entity\OpignoCertificate::getViewModeSelectorField()

Returns the view mode selector field, if available.

Return value

\Drupal\Core\Field\FieldDefinitionInterface|null A field definition or NULL if no view mode selector field is defined.

Overrides OpignoCertificateInterface::getViewModeSelectorField

File

src/Entity/OpignoCertificate.php, line 182

Class

OpignoCertificate
Defines the opigno_certificate entity class.

Namespace

Drupal\opigno_certificate\Entity

Code

public function getViewModeSelectorField() {
  if (!isset($this->viewModeSelectorField)) {
    $this->viewModeSelectorField = FALSE;

    /** @var \Drupal\Core\Field\FieldDefinitionInterface[] $fields */
    $fields = $this
      ->getFieldDefinitions();
    foreach ($fields as $field) {
      if ($field
        ->getType() == 'view_mode_selector') {
        $this->viewModeSelectorField = $field;
        break;
      }
    }
  }
  return $this->viewModeSelectorField ?: NULL;
}