Loading src/Form/SoundcloudForm.php +12 −4 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ClientException; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Implementing form SoundcloudForm. */ class SoundcloudForm extends AddFormBase { /** Loading @@ -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. */ Loading @@ -49,6 +54,7 @@ class SoundcloudForm extends AddFormBase { $container->get('media_library.opener_resolver') ); } /** * {@inheritdoc} */ Loading Loading @@ -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 Loading @@ -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.')); } } Loading @@ -135,7 +143,7 @@ class SoundcloudForm extends AddFormBase { /** * {@inheritDoc} */ function getFormId() { public function getFormId() { return 'soundcloud_media_add_form'; } } src/Plugin/media/Source/Soundcloud.php +6 −3 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -30,6 +31,8 @@ use Drupal\Core\Field\FieldTypePluginManagerInterface; */ class Soundcloud extends MediaSourceBase { use StringTranslationTrait; /** * Soundcloud attributes. * Loading Loading @@ -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; } Loading tests/src/Functional/SoundcloudEmbedFormatterTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading
src/Form/SoundcloudForm.php +12 −4 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\ClientException; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Implementing form SoundcloudForm. */ class SoundcloudForm extends AddFormBase { /** Loading @@ -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. */ Loading @@ -49,6 +54,7 @@ class SoundcloudForm extends AddFormBase { $container->get('media_library.opener_resolver') ); } /** * {@inheritdoc} */ Loading Loading @@ -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 Loading @@ -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.')); } } Loading @@ -135,7 +143,7 @@ class SoundcloudForm extends AddFormBase { /** * {@inheritDoc} */ function getFormId() { public function getFormId() { return 'soundcloud_media_add_form'; } }
src/Plugin/media/Source/Soundcloud.php +6 −3 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -30,6 +31,8 @@ use Drupal\Core\Field\FieldTypePluginManagerInterface; */ class Soundcloud extends MediaSourceBase { use StringTranslationTrait; /** * Soundcloud attributes. * Loading Loading @@ -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; } Loading
tests/src/Functional/SoundcloudEmbedFormatterTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading