ResourceFieldEntityFile.php in RESTful 7.2
File
src/Plugin/resource/Field/ResourceFieldEntityFile.php
View source
<?php
namespace Drupal\restful\Plugin\resource\Field;
use Drupal\restful\Http\RequestInterface;
class ResourceFieldEntityFile extends ResourceFieldEntity implements ResourceFieldEntityInterface {
public function preprocess($value) {
$field_info = field_info_field($this
->getProperty());
if ($field_info['cardinality'] == 1) {
return array(
'fid' => $value,
'display' => TRUE,
);
}
$value = is_array($value) ? $value : explode(',', $value);
$return = array();
foreach ($value as $delta => $single_value) {
$return[$delta] = array(
'fid' => $single_value,
'display' => TRUE,
);
}
return $return;
}
public function executeProcessCallbacks($value) {
return $this->decorated
->executeProcessCallbacks($value);
}
public function getRequest() {
return $this->decorated
->getRequest();
}
public function setRequest(RequestInterface $request) {
$this->decorated
->setRequest($request);
}
public function getDefinition() {
return $this->decorated
->getDefinition();
}
}