You are here

class ResourceFieldEntityText in RESTful 7.2

Hierarchy

Expanded class hierarchy of ResourceFieldEntityText

File

src/Plugin/resource/Field/ResourceFieldEntityText.php, line 13
Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldEntityText.

Namespace

Drupal\restful\Plugin\resource\Field
View source
class ResourceFieldEntityText extends ResourceFieldEntity implements ResourceFieldEntityInterface {

  /**
   * {@inheritdoc}
   */
  public function preprocess($value) {

    // Text field. Check if field has an input format.
    $field_info = field_info_field($this
      ->getProperty());

    // If there was no bundle that had the field instance, then return NULL.
    if (!($instance = field_info_instance($this
      ->getEntityType(), $this
      ->getProperty(), $this
      ->getBundle()))) {
      return NULL;
    }
    $return = NULL;
    if ($field_info['cardinality'] == 1) {

      // Single value.
      if (!$instance['settings']['text_processing']) {
        return $value;
      }
      return array(
        'value' => $value,
        // TODO: This is hardcoded! Fix it.
        'format' => 'filtered_html',
      );
    }

    // Multiple values.
    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;
  }

  /**
   * {@inheritdoc}
   */
  public function executeProcessCallbacks($value) {
    return $this->decorated
      ->executeProcessCallbacks($value);
  }

  /**
   * {@inheritdoc}
   */
  public function getRequest() {
    return $this->decorated
      ->getRequest();
  }

  /**
   * {@inheritdoc}
   */
  public function setRequest(RequestInterface $request) {
    $this->decorated
      ->setRequest($request);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefinition() {
    return $this->decorated
      ->getDefinition();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ResourceFieldEntity::$bundle protected property The bundle name.
ResourceFieldEntity::$column protected property If the property is a field, set the column that would be used in queries. For example, the default column for a text field would be "value". Defaults to the first column returned by field_info_field(), otherwise FALSE.
ResourceFieldEntity::$decorated protected property Decorated resource field.
ResourceFieldEntity::$entityType protected property The entity type.
ResourceFieldEntity::$formatter protected property Used for rendering the value of a configurable field using Drupal field API's formatter. The value is the $display value that is passed to field_view_field().
ResourceFieldEntity::$imageStyles protected property Array of image styles to apply to this resource field maps to an image field.
ResourceFieldEntity::$property protected property A copy of the underlying property.
ResourceFieldEntity::$subProperty protected property A sub property name of a property to take from it the content.
ResourceFieldEntity::$wrapperMethod protected property The wrapper's method name to perform on the field. This can be used for example to get the entity label, by setting the value to "label". Defaults to "value".
ResourceFieldEntity::$wrapperMethodOnEntity protected property A Boolean to indicate on what to perform the wrapper method. If TRUE the method will perform on the entity (e.g. $wrapper->label()) and FALSE on the property or sub property (e.g. $wrapper->field_reference->label()).
ResourceFieldEntity::access public function Overrides ResourceFieldInterface::access
ResourceFieldEntity::addDefaults public function Almost all the defaults come are applied by the object's property defaults. Overrides ResourceFieldInterface::addDefaults
ResourceFieldEntity::addMetadata public function Add metadata to the field. Overrides ResourceFieldInterface::addMetadata
ResourceFieldEntity::autoDiscovery public function
ResourceFieldEntity::buildResourceMetadataItem protected function Builds a metadata item for a field value. 1
ResourceFieldEntity::compoundDocumentId public function Fetches the embedded identifier(s) for the current resource field, if any. Overrides ResourceFieldInterface::compoundDocumentId
ResourceFieldEntity::create public static function Factory. Overrides ResourceFieldInterface::create
ResourceFieldEntity::decorate public function Decorate the object. Overrides ResourceFieldEntityInterface::decorate
ResourceFieldEntity::entityTypeWrapper protected function Gets the \EntityStructureWrapper for the entity type.
ResourceFieldEntity::fieldClassName public static function Get the class name to use based on the field definition.
ResourceFieldEntity::fieldInfoField protected static function Gets statically cached information about a field.
ResourceFieldEntity::fieldValue protected function Get value from a property.
ResourceFieldEntity::formatterValue protected function Get value from a field rendered by Drupal field API's formatter.
ResourceFieldEntity::getAccessCallbacks public function Overrides ResourceFieldInterface::getAccessCallbacks
ResourceFieldEntity::getBundle public function Overrides ResourceFieldEntityInterface::getBundle
ResourceFieldEntity::getCallback public function Overrides ResourceFieldInterface::getCallback
ResourceFieldEntity::getCardinality public function Gets the cardinality of the wrapped field. Overrides ResourceFieldInterface::getCardinality
ResourceFieldEntity::getColumn public function Overrides ResourceFieldEntityInterface::getColumn
ResourceFieldEntity::getEntityType public function Overrides ResourceFieldEntityInterface::getEntityType
ResourceFieldEntity::getFormatter public function Overrides ResourceFieldEntityInterface::getFormatter
ResourceFieldEntity::getImageStyles public function Overrides ResourceFieldEntityInterface::getImageStyles
ResourceFieldEntity::getImageUris public static function Get the image URLs based on the configured image styles. Overrides ResourceFieldEntityInterface::getImageUris
ResourceFieldEntity::getMetadata public function Add metadata to the field. Overrides ResourceFieldInterface::getMetadata
ResourceFieldEntity::getMethods public function Overrides ResourceFieldInterface::getMethods
ResourceFieldEntity::getProcessCallbacks public function Overrides ResourceFieldInterface::getProcessCallbacks
ResourceFieldEntity::getProperty public function Overrides ResourceFieldInterface::getProperty
ResourceFieldEntity::getPublicFieldInfo public function Gets the public field info object. Overrides ResourceFieldInterface::getPublicFieldInfo
ResourceFieldEntity::getPublicName public function Overrides ResourceFieldInterface::getPublicName
ResourceFieldEntity::getResource public function Overrides ResourceFieldInterface::getResource
ResourceFieldEntity::getSubProperty public function Overrides ResourceFieldEntityInterface::getSubProperty
ResourceFieldEntity::getWrapperMethod public function Overrides ResourceFieldEntityInterface::getWrapperMethod
ResourceFieldEntity::id public function Gets the ID of the resource field. Overrides ResourceFieldInterface::id
ResourceFieldEntity::isArrayNumeric public static function Helper method to determine if an array is numeric. Overrides ResourceFieldInterface::isArrayNumeric
ResourceFieldEntity::isComputed public function Checks if the current field is computed. Overrides ResourceFieldInterface::isComputed
ResourceFieldEntity::isWrapperMethodOnEntity public function Overrides ResourceFieldEntityInterface::isWrapperMethodOnEntity
ResourceFieldEntity::nestedDottedChildren protected function Get the children of a query string parameter that apply to the field.
ResourceFieldEntity::nestedDottedFilters protected function Process the filter query string for the relevant sub-query.
ResourceFieldEntity::populatePublicInfoField protected function Populate public info field with Property API information.
ResourceFieldEntity::propertyIdentifier protected function Helper function to get the identifier from a property wrapper. 1
ResourceFieldEntity::propertyIsField public static function Checks if a given string represents a Field API field. Overrides ResourceFieldEntityInterface::propertyIsField
ResourceFieldEntity::propertyOnEntity protected function Sets the resource field property to the schema field in the entity.
ResourceFieldEntity::propertyWrapper protected function Get the wrapper for the property associated to the current field.
ResourceFieldEntity::referencedId protected function Helper function to get the referenced entity ID. 1
ResourceFieldEntity::render public function Gets the value of a field and applies all process callbacks to it. Overrides ResourceFieldInterface::render
ResourceFieldEntity::resourceValue protected function Get value for a field based on another resource.
ResourceFieldEntity::set public function Gets the value for the field given a data source. Overrides ResourceFieldInterface::set
ResourceFieldEntity::setAccessCallbacks public function Overrides ResourceFieldInterface::setAccessCallbacks
ResourceFieldEntity::setBundle public function Overrides ResourceFieldEntityInterface::setBundle
ResourceFieldEntity::setCallback public function Overrides ResourceFieldInterface::setCallback
ResourceFieldEntity::setCardinality public function Set the cardinality. Overrides ResourceFieldInterface::setCardinality
ResourceFieldEntity::setColumn public function Overrides ResourceFieldEntityInterface::setColumn
ResourceFieldEntity::setEntityType public function Overrides ResourceFieldEntityInterface::setEntityType
ResourceFieldEntity::setFormatter public function Overrides ResourceFieldEntityInterface::setFormatter
ResourceFieldEntity::setImageStyles public function Overrides ResourceFieldEntityInterface::setImageStyles
ResourceFieldEntity::setMethods public function Overrides ResourceFieldInterface::setMethods
ResourceFieldEntity::setProcessCallbacks public function Overrides ResourceFieldInterface::setProcessCallbacks
ResourceFieldEntity::setProperty public function Overrides ResourceFieldInterface::setProperty
ResourceFieldEntity::setPublicFieldInfo public function Gets the public field info object. Overrides ResourceFieldInterface::setPublicFieldInfo
ResourceFieldEntity::setPublicName public function Overrides ResourceFieldInterface::setPublicName
ResourceFieldEntity::setResource public function Overrides ResourceFieldInterface::setResource
ResourceFieldEntity::setSubProperty public function Overrides ResourceFieldEntityInterface::setSubProperty
ResourceFieldEntity::setWrapperMethod public function Overrides ResourceFieldEntityInterface::setWrapperMethod
ResourceFieldEntity::setWrapperMethodOnEntity public function Overrides ResourceFieldEntityInterface::setWrapperMethodOnEntity
ResourceFieldEntity::singleValue protected function Returns the value for the current single field.
ResourceFieldEntity::value public function Gets the value for the field given a data source. Overrides ResourceFieldInterface::value 1
ResourceFieldEntity::__construct public function Constructor. 1
ResourceFieldEntityText::executeProcessCallbacks public function Executes the process callbacks. Overrides ResourceFieldEntity::executeProcessCallbacks
ResourceFieldEntityText::getDefinition public function Gets the original field definition as declared in Resource::publicFields(). Overrides ResourceFieldEntity::getDefinition
ResourceFieldEntityText::getRequest public function Get the request in the data provider. Overrides ResourceFieldEntity::getRequest
ResourceFieldEntityText::preprocess public function Massage the value to set according to the format expected by the wrapper. Overrides ResourceFieldEntity::preprocess
ResourceFieldEntityText::setRequest public function Set the request. Overrides ResourceFieldEntity::setRequest