You are here

public function DataProviderDbQuery::view in RESTful 7.2

Read operation.

Parameters

mixed $identifier: The ID of thing being viewed.

Return value

array An array of data for the thing being viewed.

Overrides CrudInterface::view

2 calls to DataProviderDbQuery::view()
DataProviderDbQuery::create in src/Plugin/resource/DataProvider/DataProviderDbQuery.php
Create operation.
DataProviderDbQuery::update in src/Plugin/resource/DataProvider/DataProviderDbQuery.php
Update operation.

File

src/Plugin/resource/DataProvider/DataProviderDbQuery.php, line 209
Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderDbQuery.

Class

DataProviderDbQuery

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

public function view($identifier) {
  $query = $this
    ->getQuery();
  foreach ($this
    ->getIdColumn() as $index => $column) {
    $identifier = is_array($identifier) ? $identifier : array(
      $identifier,
    );
    $query
      ->condition($this
      ->getTableName() . '.' . $column, current($this
      ->getColumnFromIds($identifier, $index)));
  }
  $this
    ->addExtraInfoToQuery($query);
  $result = $query
    ->range(0, 1)
    ->execute()
    ->fetch(\PDO::FETCH_OBJ);
  return $this
    ->mapDbRowToPublicFields($result);
}