You are here

protected function BynderWidgetBase::checkType in Bynder 8.3

Same name and namespace in other branches
  1. 8.2 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::checkType in src/Plugin/EntityBrowser/Widget/BynderSearch.php
Check that media type is properly configured.
BynderWidgetBase::getForm in src/Plugin/EntityBrowser/Widget/BynderWidgetBase.php
1 method overrides BynderWidgetBase::checkType()
BynderSearch::checkType in src/Plugin/EntityBrowser/Widget/BynderSearch.php
Check that media type is properly configured.

File

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

Class

BynderWidgetBase
Base class for Bynder Entity browser widgets.

Namespace

Drupal\bynder\Plugin\EntityBrowser\Widget

Code

protected function checkType() {
  if ($this->configuration['media_type']) {

    /** @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;
  }
}