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