You are here

protected function BynderWidgetBase::checkBundle in Bynder 8

Check that media bundle is properly configured.

Return value

bool Returns TRUE if media bundle is configured correctly.

2 calls to BynderWidgetBase::checkBundle()
BynderSearch::prepareEntities in src/Plugin/EntityBrowser/Widget/BynderSearch.php
BynderWidgetBase::getForm in src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php

File

src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php, line 193

Class

BynderWidgetBase
Base class for Bynder Entity browser widgets.

Namespace

Drupal\bynder\Plugin\EntityBrowser\Widget

Code

protected function checkBundle() {

  /** @var \Drupal\media_entity\MediaBundleInterface $bundle */
  $bundle = $this->entityTypeManager
    ->getStorage('media_bundle')
    ->load($this->configuration['media_bundle']);
  if (!$bundle) {
    (new BundleNotExistException($this->configuration['media_bundle']))
      ->logException()
      ->displayMessage();
    return FALSE;
  }
  elseif (!$bundle
    ->getType() instanceof Bynder) {
    (new BundleNotBynderException($bundle
      ->label()))
      ->logException()
      ->displayMessage();
    return FALSE;
  }
  return TRUE;
}