Browse Source

more deprecations with upgrade_status 3.x version and more phpcs fixes

d9_islandora
Eli Zoller 4 years ago
parent
commit
d4a51bebe2
  1. 1
      drush.services.yml
  2. 2
      modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php
  3. 10
      modules/islandora_text_extraction/src/Controller/MediaSourceController.php
  4. 2
      modules/islandora_text_extraction/src/Plugin/Field/FieldFormatter/OcrTextFormatter.php
  5. 48
      src/Commands/IslandoraCommands.php
  6. 3
      src/Controller/MediaSourceController.php
  7. 3
      src/Flysystem/Adapter/FedoraAdapter.php
  8. 4
      src/GeminiLookup.php
  9. 2
      src/Plugin/Condition/NodeHasParent.php
  10. 2
      src/Plugin/Field/FieldFormatter/IslandoraImageFormatter.php

1
drush.services.yml

@ -1,5 +1,6 @@
services:
islandora.commands:
class: \Drupal\islandora\Commands\IslandoraCommands
arguments: ['@entity_type.manager', '@current_user', '@account_switcher']
tags:
- { name: drush.command }

2
modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php

@ -41,7 +41,7 @@ class IslandoraIIIFConfigForm extends ConfigFormBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('http_client'),
$container->get('config.factory'),
$container->get('config.factory')
);
}

10
modules/islandora_text_extraction/src/Controller/MediaSourceController.php

@ -3,11 +3,13 @@
namespace Drupal\islandora_text_extraction\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\File\FileSystem;
use Drupal\Core\File\FileSystemInterface;
use Drupal\media\Entity\Media;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\File\FileSystem;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Controller for Media Source.
@ -93,10 +95,10 @@ class MediaSourceController extends ControllerBase {
if ($contents) {
$directory = $this->fileSystem->dirname($content_location);
if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
if (!$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable");
}
$file = file_save_data($contents, $content_location, FILE_EXISTS_REPLACE);
$file = file_save_data($contents, $content_location, FileSystemInterface::EXISTS_REPLACE);
if ($media->hasField($destination_field)) {
$media->{$destination_field}->setValue([
'target_id' => $file->id(),

2
modules/islandora_text_extraction/src/Plugin/Field/FieldFormatter/OcrTextFormatter.php

@ -75,7 +75,7 @@ class OcrTextFormatter extends FormatterBase implements ContainerFactoryPluginIn
$configuration['third_party_settings'],
$container->get('renderer'),
$container->get('config.factory'),
$container->get('entity_type.manager'),
$container->get('entity_type.manager')
);
}

48
src/Commands/IslandoraCommands.php

@ -3,8 +3,10 @@
namespace Drupal\islandora\Commands;
use Consolidation\AnnotatedCommand\CommandData;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountProxy;
use Drupal\Core\Session\AccountSwitcherInterface;
use Drupal\Core\Session\UserSession;
use Drupal\user\Entity\User;
use Drush\Commands\DrushCommands;
/**
@ -13,6 +15,35 @@ use Drush\Commands\DrushCommands;
* ... because the --user option was removed from drush 9.
*/
class IslandoraCommands extends DrushCommands {
/**
* Entity type manager object.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Drupal\Core\Session\AccountProxy definition.
*
* @var \Drupal\Core\Session\AccountProxy
*/
protected $currentUser;
/**
* The account switcher service.
*
* @var \Drupal\Core\Session\AccountSwitcherInterface
*/
protected $accountSwitcher;
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, AccountProxy $current_user, AccountSwitcherInterface $account_switcher) {
$this->entityTypeManager = $entity_type_manager;
$this->currentUser = $current_user;
$this->accountSwitcher = $account_switcher;
}
/**
* Add the userid option.
@ -56,7 +87,8 @@ class IslandoraCommands extends DrushCommands {
protected function validateUser(CommandData $commandData) {
$userid = $commandData->input()->getOption('userid');
if ($userid) {
$account = User::load($userid);
$account =
$this->entityTypeManager->getStorage('user')->load($userid);
if (!$account) {
throw new \Exception("User ID does not match an existing user.");
}
@ -87,18 +119,17 @@ class IslandoraCommands extends DrushCommands {
protected function switchUser(CommandData $commandData) {
$userid = $commandData->input()->getOption('userid');
if ($userid) {
$account = User::load($userid);
$accountSwitcher = \Drupal::service('account_switcher');
$account = $this->entityTypeManager->getStorage('user')->load($userid);
$userSession = new UserSession([
'uid' => $account->id(),
'name' => $account->getUsername(),
'roles' => $account->getRoles(),
]);
$accountSwitcher->switchTo($userSession);
$this->accountSwitcher->switchTo($userSession);
$this->logger()->notice(
dt(
'Now acting as user ID @id',
['@id' => \Drupal::currentUser()->id()]
['@id' => $this->currentUser->id()]
)
);
}
@ -127,12 +158,11 @@ class IslandoraCommands extends DrushCommands {
*/
protected function switchUserBack(CommandData $commandData) {
if ($commandData->input()->getOption('userid')) {
$accountSwitcher = \Drupal::service('account_switcher');
$this->logger()->notice(dt(
'Switching back from user @uid.',
['@uid' => \Drupal::currentUser()->id()]
['@uid' => $this->currentUser->id()]
));
$accountSwitcher->switchBack();
$this->accountSwitcher->switchBack();
}
}

3
src/Controller/MediaSourceController.php

@ -5,6 +5,7 @@ namespace Drupal\islandora\Controller;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Connection;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Routing\RouteMatch;
use Drupal\Core\Session\AccountInterface;
use Drupal\media\Entity\Media;
@ -234,7 +235,7 @@ class MediaSourceController extends ControllerBase {
$content_location = $request->headers->get('Content-Location', "");
$contents = $request->getContent();
if ($contents) {
$file = file_save_data($contents, $content_location, FILE_EXISTS_REPLACE);
$file = file_save_data($contents, $content_location, FileSystemInterface::EXISTS_REPLACE);
if ($media->hasField($destination_field)) {
$media->{$destination_field}->setValue([
'target_id' => $file->id(),

3
src/Flysystem/Adapter/FedoraAdapter.php

@ -7,7 +7,6 @@ use League\Flysystem\AdapterInterface;
use League\Flysystem\Adapter\Polyfill\NotSupportingVisibilityTrait;
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
use League\Flysystem\Config;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Header;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\StreamWrapper;
@ -378,7 +377,7 @@ class FedoraAdapter implements AdapterInterface {
$return = NULL;
if ($response->getStatusCode() == 410) {
$return = FALSE;
$link_headers = Psr7\parse_header($response->getHeader('Link'));
$link_headers = Header::parse($response->getHeader('Link'));
if ($link_headers) {
$tombstones = array_filter($link_headers, function ($o) {
return (isset($o['rel']) && $o['rel'] == 'hasTombstone');

4
src/GeminiLookup.php

@ -5,7 +5,7 @@ namespace Drupal\islandora;
use Drupal\Core\Entity\EntityInterface;
use Drupal\islandora\MediaSource\MediaSourceService;
use Drupal\jwt\Authentication\Provider\JwtAuth;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Header;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Islandora\Crayfish\Commons\Client\GeminiClient;
@ -136,7 +136,7 @@ class GeminiLookup {
$urls['fedora'],
['allow_redirects' => FALSE, 'headers' => ['Authorization' => $token]]
);
$links = Psr7\parse_header($head->getHeader("Link"));
$links = Header::parse($head->getHeader("Link"));
foreach ($links as $link) {
if ($link['rel'] == 'describedby') {
return trim($link[0], '<>');

2
src/Plugin/Condition/NodeHasParent.php

@ -93,7 +93,7 @@ class NodeHasParent extends ConditionPluginBase implements ContainerFactoryPlugi
$options = array_combine($node_fields, $node_fields);
$form['parent_reference_field'] = [
'#type' => 'select',
'#title' => $this->('Field that contains reference to parents'),
'#title' => $this->t('Field that contains reference to parents'),
'#options' => $options,
'#default_value' => $this->configuration['parent_reference_field'],
'#required' => TRUE,

2
src/Plugin/Field/FieldFormatter/IslandoraImageFormatter.php

@ -96,7 +96,7 @@ class IslandoraImageFormatter extends ImageFormatter {
$configuration['view_mode'],
$configuration['third_party_settings'],
$container->get('current_user'),
$container->get('entity.manager')->getStorage('image_style'),
$container->get('entity_type.manager')->getStorage('image_style'),
$container->get('islandora.utils')
);
}

Loading…
Cancel
Save