You are here

public function Bynder::hasMetadataChanged in Bynder 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/media/Source/Bynder.php \Drupal\bynder\Plugin\media\Source\Bynder::hasMetadataChanged()
  2. 4.0.x src/Plugin/media/Source/Bynder.php \Drupal\bynder\Plugin\media\Source\Bynder::hasMetadataChanged()

Compares the local metadata and the remote metadata in case it changed.

Parameters

\Drupal\media\MediaInterface $media: The media entity.

array $remote_metadata: The remote metadata.

Return value

bool TRUE if the remote metadata has changed. Otherwise, FALSE.

1 call to Bynder::hasMetadataChanged()
Bynder::ensureMetadata in src/Plugin/media/Source/Bynder.php
Ensures the given media entity has Bynder metadata information in place.

File

src/Plugin/media/Source/Bynder.php, line 321

Class

Bynder
Provides media source plugin for Bynder.

Namespace

Drupal\bynder\Plugin\media\Source

Code

public function hasMetadataChanged(MediaInterface $media, array $remote_metadata) {
  $remote_metadata = $this
    ->filterRemoteMetadata($remote_metadata);
  if ($media
    ->get(BynderMetadataItem::METADATA_FIELD_NAME)
    ->isEmpty() && !empty($remote_metadata)) {
    return TRUE;
  }
  $local_metadata = (array) Json::decode((string) $media
    ->get(BynderMetadataItem::METADATA_FIELD_NAME)->value);
  return $local_metadata !== $remote_metadata;
}