Commit 5c016a80 authored by Pravin Gaikwad's avatar Pravin Gaikwad
Browse files

Issue #2886457 by Rajeshreeputra, jayesh_makwana, Ruturaj Chaubey, chakkche,...

Issue #2886457 by Rajeshreeputra, jayesh_makwana, Ruturaj Chaubey, chakkche, bruno.bicudo, Shashwat Purav, Deepthi kumari, urvashi_vora, sourabhjain, matheusmaciel, Libbna, jcisio, voleger: Coding Standard issues
parent a47d0e14
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -14,6 +14,9 @@ use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ClientException;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Implementing form SoundcloudForm.
 */
class SoundcloudForm extends AddFormBase {

  /**
@@ -30,6 +33,8 @@ class SoundcloudForm extends AddFormBase {
   *   The entity type manager.
   * @param \Drupal\media_library\MediaLibraryUiBuilder $library_ui_builder
   *   The media library UI builder.
   * @param \GuzzleHttp\ClientInterface $http_client
   *   Http client service.
   * @param \Drupal\media_library\OpenerResolverInterface $opener_resolver
   *   The opener resolver.
   */
@@ -49,6 +54,7 @@ class SoundcloudForm extends AddFormBase {
      $container->get('media_library.opener_resolver')
    );
  }

  /**
   * {@inheritdoc}
   */
@@ -106,7 +112,7 @@ class SoundcloudForm extends AddFormBase {
   *
   * @param array $form
   *   The form.
   * @param FormStateInterface $form_state
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state.
   *
   * @return void|TRUE
@@ -116,11 +122,13 @@ class SoundcloudForm extends AddFormBase {
    if (preg_match('/https?:\/\/(www\.)?soundcloud\.com\/.*/', $url)) {
      try {
        \Drupal::httpClient()->get($url);
      } catch (ClientException $e) {
      }
      catch (ClientException $e) {
        $form_state->setErrorByName('url', $this->t('Could not connect to the track, please make sure that the url is correct.'));
      }

    } else {
    }
    else {
      $form_state->setErrorByName('url', $this->t('Invalid url.'));
    }
  }
@@ -135,7 +143,7 @@ class SoundcloudForm extends AddFormBase {
  /**
   * {@inheritDoc}
   */
  function getFormId() {
  public function getFormId() {
    return 'soundcloud_media_add_form';
  }
}
+6 −3
Original line number Diff line number Diff line
@@ -6,13 +6,14 @@ use Drupal\Component\Serialization\Json;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\media\MediaInterface;
use Drupal\media\MediaSourceBase;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ClientException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;

/**
 * Soundcloud entity media source.
@@ -30,6 +31,8 @@ use Drupal\Core\Field\FieldTypePluginManagerInterface;
 */
class Soundcloud extends MediaSourceBase {

  use StringTranslationTrait;

  /**
   * Soundcloud attributes.
   *
@@ -82,9 +85,9 @@ class Soundcloud extends MediaSourceBase {
    $attributes = [
      'track_id' => $this->t('The track id - not always available'),
      'playlist_id' => $this->t('The playlist (set) id - not always available'),
      'source_id' => t('Compound of source type (track or playlist) and id so that it is unique among all SoundCloud media'),
      'source_id' => $this->t('Compound of source type (track or playlist) and id so that it is unique among all SoundCloud media'),
      'html' => $this->t('HTML embed code'),
      'thumbnail_uri' => t('URI of the thumbnail'),
      'thumbnail_uri' => $this->t('URI of the thumbnail'),
    ];
    return $attributes;
  }
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ class SoundcloudEmbedFormatterTest extends BrowserTestBase {
    parent::setUp();

    // Setup standalone media urls from the settings.
    $this->config('media.settings')->set('standalone_url', true)->save();
    $this->config('media.settings')->set('standalone_url', TRUE)->save();
    $this->refreshVariables();
    // Rebuild routes.
    \Drupal::service('router.builder')->rebuild();