ResourceFieldEntityText.php in RESTful 7.2
File
src/Plugin/resource/Field/ResourceFieldEntityText.php
View source
<?php
namespace Drupal\restful\Plugin\resource\Field;
use Drupal\restful\Http\RequestInterface;
use Drupal\restful\Plugin\resource\DataInterpreter\DataInterpreterInterface;
class ResourceFieldEntityText extends ResourceFieldEntity implements ResourceFieldEntityInterface {
public function preprocess($value) {
$field_info = field_info_field($this
->getProperty());
if (!($instance = field_info_instance($this
->getEntityType(), $this
->getProperty(), $this
->getBundle()))) {
return NULL;
}
$return = NULL;
if ($field_info['cardinality'] == 1) {
if (!$instance['settings']['text_processing']) {
return $value;
}
return array(
'value' => $value,
'format' => 'filtered_html',
);
}
foreach ($value as $delta => $single_value) {
if (!$instance['settings']['text_processing']) {
$return[$delta] = $single_value;
}
else {
$return[$delta] = array(
'value' => $single_value,
'format' => 'filtered_html',
);
}
}
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();
}
}