Commit 21c3ceaa authored by Joris van Eijden's avatar Joris van Eijden Committed by Sascha Grossenbacher
Browse files

Issue #3203003 by JvE, lukus, guardiola86: Error: Call to a member function...

Issue #3203003 by JvE, lukus, guardiola86: Error: Call to a member function mainPropertyName() on null
parent 7bf1ff46
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,6 +6,6 @@ core_version_requirement: ^8.8 || ^9
configure: bynder.configuration_form

dependencies:
  - drupal:media
  - drupal:media (>= 8.5)
  - entity_browser:entity_browser (>= 8.x-2.x)
  - jquery_ui_tooltip:jquery_ui_tooltip
+0 −28
Original line number Diff line number Diff line
@@ -408,34 +408,6 @@ class Bynder extends MediaSourceBase {
    return parent::buildConfigurationForm($form, $form_state);
  }

  /**
   * Get the primary value stored in the source field.
   *
   * @todo This helper method was added to MediaSourceBase in 8.5.0 but we
   * replicate it here because we want to support 8.4.0 sites as well. This
   * method can be safely removed once there is no need to support 8.4 anymore,
   * and we ensure the core Media dependency is bumped to 8.5.0 at least.
   *
   * @param \Drupal\media\MediaInterface $media
   *   A media item.
   *
   * @return mixed
   *   The source value.
   *
   * @throws \RuntimeException
   *   If the source field for the media source is not defined.
   */
  public function getSourceFieldValue(MediaInterface $media) {
    $source_field = $this->configuration['source_field'];
    if (empty($source_field)) {
      throw new \RuntimeException('Source field for media source is not defined.');
    }

    /** @var \Drupal\Core\Field\FieldItemInterface $field_item */
    $field_item = $media->get($source_field)->first();
    return $field_item->{$field_item->mainPropertyName()};
  }

  /**
   * Creates the metadata field storage definition.
   *