You are here

public function ResourceFieldEntity::__construct in RESTful 7.2

Constructor.

Parameters

array $field: Contains the field values.

RequestInterface $request: The request.

Throws

ServerConfigurationException If the entity type is empty.

1 call to ResourceFieldEntity::__construct()
ResourceFieldEntityReference::__construct in src/Plugin/resource/Field/ResourceFieldEntityReference.php
Constructs a ResourceFieldEntityReference.
1 method overrides ResourceFieldEntity::__construct()
ResourceFieldEntityReference::__construct in src/Plugin/resource/Field/ResourceFieldEntityReference.php
Constructs a ResourceFieldEntityReference.

File

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

Class

ResourceFieldEntity
Class ResourceFieldEntity.

Namespace

Drupal\restful\Plugin\resource\Field

Code

public function __construct(array $field, RequestInterface $request) {
  if ($this->decorated) {
    $this
      ->setRequest($request);
  }
  if (empty($field['entityType'])) {
    throw new ServerConfigurationException(sprintf('Unknown entity type for %s resource field.', __CLASS__));
  }
  $this
    ->setEntityType($field['entityType']);
  $this->wrapperMethod = isset($field['wrapper_method']) ? $field['wrapper_method'] : $this->wrapperMethod;
  $this->subProperty = isset($field['sub_property']) ? $field['sub_property'] : $this->subProperty;
  $this->formatter = isset($field['formatter']) ? $field['formatter'] : $this->formatter;
  $this->wrapperMethodOnEntity = isset($field['wrapper_method_on_entity']) ? $field['wrapper_method_on_entity'] : $this->wrapperMethodOnEntity;
  $this->column = isset($field['column']) ? $field['column'] : $this->column;
  $this->imageStyles = isset($field['image_styles']) ? $field['image_styles'] : $this->imageStyles;
  if (!empty($field['bundle'])) {

    // TODO: Document this usage.
    $this
      ->setBundle($field['bundle']);
  }
}