You are here

protected function BynderWidgetBase::checkType in Bynder 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderWidgetBase::checkType()
  2. 4.0.x src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderWidgetBase::checkType()

Check that media type is properly configured.

Return value

bool Returns TRUE if media type is configured correctly.

2 calls to BynderWidgetBase::checkType()
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 checkType() {

  /** @var \Drupal\media\MediaTypeInterface $type */
  $type = $this->entityTypeManager
    ->getStorage('media_type')
    ->load($this->configuration['media_type']);
  if (!$type) {
    (new BundleNotExistException($this->configuration['media_type']))
      ->logException()
      ->displayMessage();
    return FALSE;
  }
  elseif (!$type
    ->getSource() instanceof Bynder) {
    (new BundleNotBynderException($type
      ->label()))
      ->logException()
      ->displayMessage();
    return FALSE;
  }
  return TRUE;
}