You are here

public function IndeterminateBundleException::__construct in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 src/Exception/IndeterminateBundleException.php \Drupal\lightning_media\Exception\IndeterminateBundleException::__construct()
  2. 8 src/Exception/IndeterminateBundleException.php \Drupal\lightning_media\Exception\IndeterminateBundleException::__construct()
  3. 8.2 src/Exception/IndeterminateBundleException.php \Drupal\lightning_media\Exception\IndeterminateBundleException::__construct()

IndeterminateBundleException constructor.

Parameters

mixed $value: The input value.

int $code: (optional) The error code.

\Exception $previous: (optional) The previous exception, if any.

\Drupal\media\MediaTypeInterface[] $types: (optional) The media types which matched the input value.

File

src/Exception/IndeterminateBundleException.php, line 32

Class

IndeterminateBundleException
Thrown if no single media type can be determined from an input value.

Namespace

Drupal\lightning_media\Exception

Code

public function __construct($value, $code = 0, \Exception $previous = NULL, array $types = []) {
  $message = sprintf($types ? 'Input matched multiple media types: %s' : 'Input did not match any media types: %s', $value instanceof EntityInterface ? $value
    ->label() : var_export($value, TRUE));

  /** @var \Drupal\media\MediaTypeInterface $media_type */
  foreach ($types as $media_type) {
    $key = $media_type
      ->id();
    $this->types[$key] = $media_type;
  }
  parent::__construct($message, $code, $previous);
}