You are here

public function MediaTarget::isEmpty in Media Feeds 8

Returns if the value for the target is empty.

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.

Return value

bool True if the value on the entity is empty. False otherwise.

Overrides FieldTargetBase::isEmpty

1 call to MediaTarget::isEmpty()
MediaTarget::setTarget in src/Feeds/Target/MediaTarget.php
Sets the values on an object.

File

src/Feeds/Target/MediaTarget.php, line 447

Class

MediaTarget
Defines a wrapper target around a paragraph bundle's target field.

Namespace

Drupal\media_feeds\Feeds\Target

Code

public function isEmpty($values) {
  $properties = $this->targetDefinition
    ->getProperties();
  $emptyValues = 0;
  foreach ($values as $value) {
    $currentProperties = array_keys($value);
    $emptyProps = [];
    foreach ($properties as $property) {
      foreach ($currentProperties as $currentProperty) {
        if ($currentProperty === $property) {
          if (!strlen($value[$currentProperty])) {
            $emptyProps[] = $currentProperty;
          }
        }
      }
    }
    if (count($emptyProps) === count($properties)) {
      $emptyValues++;
    }
  }
  return $emptyValues === count($values);
}