You are here

class FeedsEntityProcessorPropertyEntityType in Feeds entity processor 7

Handler for specified entity type property.

Hierarchy

Expanded class hierarchy of FeedsEntityProcessorPropertyEntityType

1 string reference to 'FeedsEntityProcessorPropertyEntityType'
feeds_entity_processor_feeds_entity_processor_properties in ./feeds_entity_processor.feeds.inc
Implements hook_feeds_entity_processor_properties().

File

src/Property/FeedsEntityProcessorPropertyEntityType.php, line 11
Contains FeedsEntityProcessorPropertyEntityType.

View source
class FeedsEntityProcessorPropertyEntityType extends FeedsEntityProcessorPropertyDefault {

  /**
   * Implements FeedsEntityProcessorPropertyInterface::validate().
   */
  public function validate(&$value) {
    $info = $this
      ->getPropertyInfo();
    $entity_type = $info['type'];
    if ($value) {
      $entity = entity_load_single($entity_type, $value);
      if (!$entity) {
        $entity_info = entity_get_info();
        $entity_type_label = $entity_info[$entity_type]['label'];
        return array(
          t('@entity_type with ID "@entity_id" does not exist.', array(
            '@entity_type' => $entity_type_label,
            '@entity_id' => $value,
          )),
        );
      }
      $wrapper = entity_metadata_wrapper($entity_type, $value);
      return parent::validate($wrapper);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function setValue($value, array $mapping) {
    $info = $this
      ->getPropertyInfo();
    if (is_scalar($value)) {
      $wrapper = entity_metadata_wrapper($info['type'], $value);
    }
    parent::setValue($wrapper, $mapping);
  }

  /**
   * {@inheritdoc}
   */
  protected function getDataType() {
    $type = parent::getDataType();
    $info = entity_get_info($type);
    if (isset($info['entity keys']['id'])) {
      $id_key = $info['entity keys']['id'];
      if (isset($info['base table field types'][$id_key])) {
        $type .= ' (' . $info['base table field types'][$id_key] . ')';
      }
    }
    return $type;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsEntityProcessorPropertyDefault::$name private property The property name.
FeedsEntityProcessorPropertyDefault::$processor private property The processor used to process the data.
FeedsEntityProcessorPropertyDefault::$propertyInfo private property Info about the given property.
FeedsEntityProcessorPropertyDefault::$wrapper private property Entity wrapper.
FeedsEntityProcessorPropertyDefault::entityWrapper public function Implements FeedsEntityProcessorPropertyInterface::entityWrapper(). Overrides FeedsEntityProcessorPropertyInterface::entityWrapper
FeedsEntityProcessorPropertyDefault::getFormField public function Implements FeedsEntityProcessorPropertyInterface::getFormField(). Overrides FeedsEntityProcessorPropertyInterface::getFormField 3
FeedsEntityProcessorPropertyDefault::getMappingTarget public function Implements FeedsEntityProcessorPropertyInterface::getMappingTarget(). Overrides FeedsEntityProcessorPropertyInterface::getMappingTarget 2
FeedsEntityProcessorPropertyDefault::getName public function Implements FeedsEntityProcessorPropertyInterface::getName(). Overrides FeedsEntityProcessorPropertyInterface::getName
FeedsEntityProcessorPropertyDefault::getProcessor public function Implements FeedsEntityProcessorPropertyInterface::getProcessor(). Overrides FeedsEntityProcessorPropertyInterface::getProcessor
FeedsEntityProcessorPropertyDefault::getPropertyInfo public function Implements FeedsEntityProcessorPropertyInterface::getPropertyInfo(). Overrides FeedsEntityProcessorPropertyInterface::getPropertyInfo
FeedsEntityProcessorPropertyDefault::__construct public function FeedsEntityProcessorPropertyDefault object constructor.
FeedsEntityProcessorPropertyEntityType::getDataType protected function Returns the data type of the current property (if known). Overrides FeedsEntityProcessorPropertyDefault::getDataType
FeedsEntityProcessorPropertyEntityType::setValue public function Implements FeedsEntityProcessorPropertyInterface::setValue(). Overrides FeedsEntityProcessorPropertyDefault::setValue
FeedsEntityProcessorPropertyEntityType::validate public function Implements FeedsEntityProcessorPropertyInterface::validate(). Overrides FeedsEntityProcessorPropertyDefault::validate