You are here

public function ResourceFieldEntity::addDefaults in RESTful 7.2

Almost all the defaults come are applied by the object's property defaults.

Overrides ResourceFieldInterface::addDefaults

File

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

Class

ResourceFieldEntity
Class ResourceFieldEntity.

Namespace

Drupal\restful\Plugin\resource\Field

Code

public function addDefaults() {

  // Set the defaults from the decorated.
  $this
    ->setResource($this->decorated
    ->getResource());

  // If entity metadata wrapper methods were used, then return the appropriate
  // entity property.
  if ($this
    ->isWrapperMethodOnEntity() && $this
    ->getWrapperMethod()) {
    $this
      ->propertyOnEntity();
  }

  // Set the Entity related defaults.
  if (($this->property = $this->decorated
    ->getProperty()) && ($field = $this::fieldInfoField($this->property)) && $field['type'] == 'image' && ($image_styles = $this
    ->getImageStyles())) {

    // If it's an image check if we need to add image style processing.
    $process_callbacks = $this
      ->getProcessCallbacks();
    array_unshift($process_callbacks, array(
      array(
        $this,
        'getImageUris',
      ),
      array(
        $image_styles,
      ),
    ));
    $this
      ->setProcessCallbacks($process_callbacks);
  }
}