/** * {@inheritdoc} */ public function setValue($value, array $mapping) { $info = $this->getPropertInfo(); if (is_scalar($value)) { $wrapper = entity_metadata_wrapper($info['type'], $value); } parent::setValue($wrapper, $mapping); }
/** * {@inheritdoc} */ public function validate(&$value) { // Entity API won't accept empty date values. if (empty($value)) { $value = NULL; return array(); } return parent::validate($value); }
/** * {@inheritdoc} */ public function setValue($value, array $mapping) { $wrapper = NULL; if (is_scalar($value)) { $entity_type = $this->getMappingEntityType($mapping); if (!$entity_type) { throw new FeedsValidationException(t('Mapping option %name not set for target %target.', array('%name' => t('Entity type'), '%target' => !empty($mapping['target']) ? $mapping['target'] : $this->getName()))); } $wrapper = entity_metadata_wrapper($entity_type, $value); } if (is_array($value) && !empty($value['entity_type']) && !empty($value['entity_id'])) { $wrapper = entity_metadata_wrapper($value['entity_type'], $value['entity_id']); } if ($wrapper) { parent::setValue($wrapper, $mapping); } }
/** * {@inheritdoc} */ public function getFormField(&$form, &$form_state, $default) { $field = parent::getFormField($form, $form_state, $default); $field['#type'] = 'checkbox'; return $field; }