public function MediaTarget::setTarget in Media Feeds 8
Sets the values on an object.
Parameters
\Drupal\feeds\FeedInterface $feed: The feed object.
\Drupal\Core\Entity\EntityInterface $entity: The target object.
string $target: The name of the target to set.
array $values: A list of values to set on the target.
Overrides EntityReference::setTarget
File
- src/
Feeds/ Target/ MediaTarget.php, line 425
Class
- MediaTarget
- Defines a wrapper target around a paragraph bundle's target field.
Namespace
Drupal\media_feeds\Feeds\TargetCode
public function setTarget(FeedInterface $feed, EntityInterface $entity, $field_name, array $values) {
if ($this
->isEmpty($values)) {
return null;
}
$target = $this->targetDefinition;
$target = $target
->getFieldDefinition();
$field_name = $target
->getName();
if (!$this->isMedia) {
parent::setTarget($feed, $entity, $field_name, $values);
}
else {
$info = $target->media_feeds_info;
$mediaEntity = $this
->createMediaEntity($entity, $info['host']['bundle'], $info['host']['field']);
$mediaEntity->{$field_name} = NULL;
if ($mediaEntity
->hasField($field_name)) {
//
}
else {
$stop = null;
}
$this->targetInstance
->setTarget($feed, $mediaEntity, $target
->getName(), $values);
}
}