Loading media_fotoweb.info.yml +1 −1 Original line number Diff line number Diff line name: 'Media Fotoweb' type: module description: 'Integrates media with the digital asset management from fotoware.com' core_version_requirement: ^8.7.7 || ^9 core_version_requirement: ^9.3 || ^10 package: 'Media' configure: media_fotoweb.settings Loading src/Plugin/media/Source/Fotoweb.php +18 −7 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Utility\Token; use Drupal\file\FileInterface; use Drupal\file\FileRepositoryInterface; use Drupal\media\MediaSourceBase; use Drupal\media\MediaTypeInterface; use Drupal\media\MediaInterface; Loading Loading @@ -49,6 +50,13 @@ class Fotoweb extends MediaSourceBase { */ protected $fileSystem; /** * File repository service. * * @var \Drupal\file\FileRepositoryInterface */ protected $fileRepository; /** * The token service. * Loading Loading @@ -78,19 +86,21 @@ class Fotoweb extends MediaSourceBase { * The entity field manager. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type plugin manager service. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory service. * @param \Drupal\Core\File\FileSystemInterface $fileSystem * @param \Drupal\Core\File\FileSystemInterface $file_system * The file system service. * @param \Drupal\file\FileRepositoryInterface $file_repository * The file repository. * @param \Drupal\Core\Utility\Token $token * The token service. * @param \Drupal\media_fotoweb\ImageFetcherManager $image_fetcher_manager * The Image Fetcher Plugin Manager. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ConfigFactoryInterface $configFactory, FileSystemInterface $fileSystem, Token $token, ImageFetcherManager $image_fetcher_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $entity_field_manager, $field_type_manager, $configFactory); $this->configFactory = $configFactory; $this->fileSystem = $fileSystem; public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ConfigFactoryInterface $config_factory, FileSystemInterface $file_system, FileRepositoryInterface $file_repository, Token $token, ImageFetcherManager $image_fetcher_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $entity_field_manager, $field_type_manager, $config_factory); $this->fileSystem = $file_system; $this->fileRepository = $file_repository; $this->token = $token; $this->imageFetcherManager = $image_fetcher_manager; } Loading @@ -108,6 +118,7 @@ class Fotoweb extends MediaSourceBase { $container->get('plugin.manager.field.field_type'), $container->get('config.factory'), $container->get('file_system'), $container->get('file_repository'), $container->get('token'), $container->get('plugin.manager.media_fotoweb.image_fetcher') ); Loading Loading @@ -360,7 +371,7 @@ class Fotoweb extends MediaSourceBase { } } $file = file_save_data($data, $destination_path, $replace); $file = $this->fileRepository->writeData($data, $destination_path, $replace); return $file; } Loading tests/src/Unit/FotowebLoginManagerTest.php +5 −9 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ class FotowebLoginManagerTest extends UnitTestCase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $config_factory = $this Loading @@ -40,17 +40,13 @@ class FotowebLoginManagerTest extends UnitTestCase { $container->set('config.factory', $config_factory); // Create mocks. $fieldItem = $this->getMockBuilder(FieldItemListInterface::class) ->disableOriginalConstructor() ->getMock(); $fieldItem = $this->createMock(FieldItemListInterface::class); $fieldItem->expects($this->any()) ->method('__get') ->with('value') ->willReturn('fotoweb_testuser'); $testUser = $this->getMockBuilder('Drupal\user\Entity\User') ->disableOriginalConstructor() ->getMock(); $testUser = $this->createMock('Drupal\user\Entity\User'); $testUser->expects($this->any()) ->method('hasField') ->with('name') Loading Loading @@ -81,7 +77,7 @@ class FotowebLoginManagerTest extends UnitTestCase { $username = 'fotoweb_testuser'; // The login token uses time based components, so we are only checking // for the expected format. $this->assertRegExp('/^[A-Za-z0-9]{0,130}==$/', $this->fotowebLoginManager->getUserLoginTokenFromUsername($username)); $this->assertMatchesRegularExpression('/^[A-Za-z0-9]{0,130}==$/', $this->fotowebLoginManager->getUserLoginTokenFromUsername($username)); } /** Loading @@ -93,7 +89,7 @@ class FotowebLoginManagerTest extends UnitTestCase { ->method('id') ->will($this->returnValue(1)); $this->assertRegExp('/^[A-Za-z0-9]{0,130}==$/', $this->fotowebLoginManager->getLoginTokenFromAccount($account)); $this->assertMatchesRegularExpression('/^[A-Za-z0-9]{0,130}==$/', $this->fotowebLoginManager->getLoginTokenFromAccount($account)); } } tests/src/Unit/RenditionImageFetcherTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ class RenditionImageFetcherTest extends UnitTestCase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $configFactory = $this Loading tests/src/Unit/RenditionNegotiatorTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class RenditionNegotiatorTest extends UnitTestCase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $configFactory = $this Loading Loading
media_fotoweb.info.yml +1 −1 Original line number Diff line number Diff line name: 'Media Fotoweb' type: module description: 'Integrates media with the digital asset management from fotoware.com' core_version_requirement: ^8.7.7 || ^9 core_version_requirement: ^9.3 || ^10 package: 'Media' configure: media_fotoweb.settings Loading
src/Plugin/media/Source/Fotoweb.php +18 −7 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Utility\Token; use Drupal\file\FileInterface; use Drupal\file\FileRepositoryInterface; use Drupal\media\MediaSourceBase; use Drupal\media\MediaTypeInterface; use Drupal\media\MediaInterface; Loading Loading @@ -49,6 +50,13 @@ class Fotoweb extends MediaSourceBase { */ protected $fileSystem; /** * File repository service. * * @var \Drupal\file\FileRepositoryInterface */ protected $fileRepository; /** * The token service. * Loading Loading @@ -78,19 +86,21 @@ class Fotoweb extends MediaSourceBase { * The entity field manager. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type plugin manager service. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory service. * @param \Drupal\Core\File\FileSystemInterface $fileSystem * @param \Drupal\Core\File\FileSystemInterface $file_system * The file system service. * @param \Drupal\file\FileRepositoryInterface $file_repository * The file repository. * @param \Drupal\Core\Utility\Token $token * The token service. * @param \Drupal\media_fotoweb\ImageFetcherManager $image_fetcher_manager * The Image Fetcher Plugin Manager. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ConfigFactoryInterface $configFactory, FileSystemInterface $fileSystem, Token $token, ImageFetcherManager $image_fetcher_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $entity_field_manager, $field_type_manager, $configFactory); $this->configFactory = $configFactory; $this->fileSystem = $fileSystem; public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ConfigFactoryInterface $config_factory, FileSystemInterface $file_system, FileRepositoryInterface $file_repository, Token $token, ImageFetcherManager $image_fetcher_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $entity_field_manager, $field_type_manager, $config_factory); $this->fileSystem = $file_system; $this->fileRepository = $file_repository; $this->token = $token; $this->imageFetcherManager = $image_fetcher_manager; } Loading @@ -108,6 +118,7 @@ class Fotoweb extends MediaSourceBase { $container->get('plugin.manager.field.field_type'), $container->get('config.factory'), $container->get('file_system'), $container->get('file_repository'), $container->get('token'), $container->get('plugin.manager.media_fotoweb.image_fetcher') ); Loading Loading @@ -360,7 +371,7 @@ class Fotoweb extends MediaSourceBase { } } $file = file_save_data($data, $destination_path, $replace); $file = $this->fileRepository->writeData($data, $destination_path, $replace); return $file; } Loading
tests/src/Unit/FotowebLoginManagerTest.php +5 −9 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ class FotowebLoginManagerTest extends UnitTestCase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $config_factory = $this Loading @@ -40,17 +40,13 @@ class FotowebLoginManagerTest extends UnitTestCase { $container->set('config.factory', $config_factory); // Create mocks. $fieldItem = $this->getMockBuilder(FieldItemListInterface::class) ->disableOriginalConstructor() ->getMock(); $fieldItem = $this->createMock(FieldItemListInterface::class); $fieldItem->expects($this->any()) ->method('__get') ->with('value') ->willReturn('fotoweb_testuser'); $testUser = $this->getMockBuilder('Drupal\user\Entity\User') ->disableOriginalConstructor() ->getMock(); $testUser = $this->createMock('Drupal\user\Entity\User'); $testUser->expects($this->any()) ->method('hasField') ->with('name') Loading Loading @@ -81,7 +77,7 @@ class FotowebLoginManagerTest extends UnitTestCase { $username = 'fotoweb_testuser'; // The login token uses time based components, so we are only checking // for the expected format. $this->assertRegExp('/^[A-Za-z0-9]{0,130}==$/', $this->fotowebLoginManager->getUserLoginTokenFromUsername($username)); $this->assertMatchesRegularExpression('/^[A-Za-z0-9]{0,130}==$/', $this->fotowebLoginManager->getUserLoginTokenFromUsername($username)); } /** Loading @@ -93,7 +89,7 @@ class FotowebLoginManagerTest extends UnitTestCase { ->method('id') ->will($this->returnValue(1)); $this->assertRegExp('/^[A-Za-z0-9]{0,130}==$/', $this->fotowebLoginManager->getLoginTokenFromAccount($account)); $this->assertMatchesRegularExpression('/^[A-Za-z0-9]{0,130}==$/', $this->fotowebLoginManager->getLoginTokenFromAccount($account)); } }
tests/src/Unit/RenditionImageFetcherTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ class RenditionImageFetcherTest extends UnitTestCase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $configFactory = $this Loading
tests/src/Unit/RenditionNegotiatorTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class RenditionNegotiatorTest extends UnitTestCase { /** * {@inheritdoc} */ protected function setUp() { protected function setUp(): void { parent::setUp(); $configFactory = $this Loading