ResourceFieldDbColumn.php in RESTful 7.2
File
src/Plugin/resource/Field/ResourceFieldDbColumn.php
View source
<?php
namespace Drupal\restful\Plugin\resource\Field;
use Drupal\restful\Exception\ServerConfigurationException;
use Drupal\restful\Http\RequestInterface;
use Drupal\restful\Plugin\resource\DataInterpreter\DataInterpreterInterface;
class ResourceFieldDbColumn extends ResourceField implements ResourceFieldDbColumnInterface {
protected $columnForQuery;
public function __construct(array $field, RequestInterface $request) {
parent::__construct($field, $request);
$this->columnForQuery = empty($field['columnForQuery']) ? $this
->getProperty() : $field['columnForQuery'];
}
public static function create(array $field, RequestInterface $request = NULL) {
$resource_field = new static($field, $request ?: restful()
->getRequest());
$resource_field
->addDefaults();
return $resource_field;
}
public function getColumnForQuery() {
return $this->columnForQuery;
}
public function value(DataInterpreterInterface $interpreter) {
$value = parent::value($interpreter);
if (isset($value)) {
return $value;
}
return $interpreter
->getWrapper()
->get($this
->getProperty());
}
}