public function MediaHelper::getBundleFromInput in Lightning Media 8.4
Same name and namespace in other branches
- 8 src/MediaHelper.php \Drupal\lightning_media\MediaHelper::getBundleFromInput()
- 8.2 src/MediaHelper.php \Drupal\lightning_media\MediaHelper::getBundleFromInput()
- 8.3 src/MediaHelper.php \Drupal\lightning_media\MediaHelper::getBundleFromInput()
Returns the first media bundle that can accept an input value.
Parameters
mixed $value: The input value.
bool $check_access: (optional) Whether to filter the bundles by create access for the current user. Defaults to TRUE.
string[] $bundles: (optional) A set of media bundle IDs which might match the input. If omitted, all available bundles are checked.
Return value
\Drupal\media\MediaTypeInterface A media bundle that can accept the input value.
Throws
\Drupal\lightning_media\Exception\IndeterminateBundleException If the input value cannot be matched to exactly one media type.
File
- src/
MediaHelper.php, line 91
Class
- MediaHelper
- Provides helper methods for dealing with media entities.
Namespace
Drupal\lightning_mediaCode
public function getBundleFromInput($value, $check_access = TRUE, array $bundles = []) {
$media_types = $this
->getBundlesFromInput($value, $check_access, $bundles);
if (count($media_types) === 1) {
return reset($media_types);
}
throw new IndeterminateBundleException($value, 0, NULL, $media_types);
}