public function createFromInput($value, array $bundles = []) {
    /** @var \Drupal\media\MediaInterface $entity */
    $entity = $this->entityTypeManager
      ->getStorage('media')
      ->create([
        'bundle' => $this->getBundleFromInput($value, TRUE, $bundles)->id(),
      ]);

    $field = static::getSourceField($entity);
    if ($field) {
      $field->setValue($value);
    }
    return $entity;
  }
public function createFromInput($value, array $bundles = []) {
    /** @var \Drupal\media\MediaInterface $entity */
    $entity = $this->entityTypeManager
      ->getStorage('media')
      ->create([
        'bundle' => $this->getBundleFromInput($value, TRUE, $bundles)->id(),
      ]);

    $field = static::getSourceField($entity);
    if ($field) {
      $field->setValue($value);
    }
    return $entity;
  }
public function createFromInput ( $ value , array $ bundles = [ ] ) { /** @var \Drupal\media\MediaInterface $entity */ $ entity = $ this -> entityTypeManager -> getStorage ( 'media' ) -> create ( [ 'bundle' => $ this -> getBundleFromInput ( $ value , TRUE , $ bundles ) -> id ( ) , ] ) ; $ field = static :: getSourceField ( $ entity ) ; if ( $ field ) { $ field -> setValue ( $ value ) ; } return $ entity ; }
Creates a media entity from an input value.

@param mixed $value
The input value.
@param string[] $bundles
(optional) A set of media bundle IDs which might match the input value.
If omitted, all bundles to which the user has create access are checked.

@return \Drupal\media\MediaInterface
The unsaved media entity.
Creates a media entity from an input value .