You are here

public function ResourceFieldResource::getTargetColumn in RESTful 7.2

Gets the table column for joins.

Return value

string The column to make a join for nested filters.

Overrides ResourceFieldResourceInterface::getTargetColumn

File

src/Plugin/resource/Field/ResourceFieldResource.php, line 386
Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldResource.

Class

ResourceFieldResource

Namespace

Drupal\restful\Plugin\resource\Field

Code

public function getTargetColumn() {
  if (empty($this->targetColumn)) {

    // Check the definition of the decorated field.
    $definition = $this->decorated
      ->getDefinition();
    if (!empty($definition['targetColumn'])) {
      $this->targetColumn = $definition['targetColumn'];
    }
    elseif ($this
      ->isInstanceOf(ResourceFieldEntityReferenceInterface::class)) {
      $entity_info = entity_get_info($this
        ->getResourcePlugin()
        ->getEntityType());

      // Assume that the relationship is through the entity key id.
      $this->targetColumn = $entity_info['entity keys']['id'];
    }
    else {
      throw new ServerConfigurationException(sprintf('Target column could not be found for field "%s".', $this
        ->getPublicName()));
    }
  }
  return $this->targetColumn;
}