You are here

public function ResourceFieldEntity::getCardinality in RESTful 7.2

Gets the cardinality of the wrapped field.

Return value

int The number of potentially returned fields. Reuses field cardinality constants.

Overrides ResourceFieldInterface::getCardinality

2 calls to ResourceFieldEntity::getCardinality()
ResourceFieldEntity::compoundDocumentId in src/Plugin/resource/Field/ResourceFieldEntity.php
Fetches the embedded identifier(s) for the current resource field, if any.
ResourceFieldEntityReference::preprocess in src/Plugin/resource/Field/ResourceFieldEntityReference.php
Massage the value to set according to the format expected by the wrapper.

File

src/Plugin/resource/Field/ResourceFieldEntity.php, line 1070
Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldEntity

Class

ResourceFieldEntity
Class ResourceFieldEntity.

Namespace

Drupal\restful\Plugin\resource\Field

Code

public function getCardinality() {
  if (isset($this->cardinality)) {
    return $this->cardinality;
  }

  // Default to single cardinality.
  $this->cardinality = 1;
  if ($field_info = $this::fieldInfoField($this
    ->getProperty())) {
    $this->cardinality = empty($field_info['cardinality']) ? $this->cardinality : $field_info['cardinality'];
  }
  return $this->cardinality;
}