diff --git a/web/modules/custom/nerdcustom/nerdcustom.services.yml b/web/modules/custom/nerdcustom/nerdcustom.services.yml index 8e77a3d4e..74325b9e9 100644 --- a/web/modules/custom/nerdcustom/nerdcustom.services.yml +++ b/web/modules/custom/nerdcustom/nerdcustom.services.yml @@ -2,13 +2,3 @@ services: nerdcustom.clipcreator: class: Drupal\nerdcustom\ClipCreator arguments: ["@entity.manager"] - stream_wrapper.http: - class: Drupal\nerdcustom\StreamWrapper\CachedHttpStreamWrapper - arguments: ['@http_client'] - tags: - - { name: stream_wrapper, scheme: http } - stream_wrapper.https: - class: Drupal\nerdcustom\StreamWrapper\CachedHttpStreamWrapper - arguments: ['@http_client'] - tags: - - { name: stream_wrapper, scheme: https } diff --git a/web/modules/custom/nerdcustom/src/NerdcustomServiceProvider.php b/web/modules/custom/nerdcustom/src/NerdcustomServiceProvider.php deleted file mode 100644 index 689a532bc..000000000 --- a/web/modules/custom/nerdcustom/src/NerdcustomServiceProvider.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -namespace Drupal\nerdcustom; - -use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\Core\DependencyInjection\ServiceProviderBase; - -/** - * Swaps services. - */ -class NerdCustomServiceProvider extends ServiceProviderBase { - - /** - * {@inheritdoc} - */ - public function alter(ContainerBuilder $container) { - $definition = $container->getDefinition('stream_wrapper.http'); - $definition->setClass('\Drupal\nerdcustom\StreamWrapper\CachedHttpStreamWrapper'); - $definition = $container->getDefinition('stream_wrapper.https'); - $definition->setClass('\Drupal\nerdcustom\StreamWrapper\CachedHttpStreamWrapper'); - } - -} diff --git a/web/modules/custom/nerdcustom/src/StreamWrapper/CachedHttpStreamWrapper.php b/web/modules/custom/nerdcustom/src/StreamWrapper/CachedHttpStreamWrapper.php deleted file mode 100644 index a05dde44a..000000000 --- a/web/modules/custom/nerdcustom/src/StreamWrapper/CachedHttpStreamWrapper.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php - -/** - * @file - * Statically cache file sizes during a migration. - */ - -// phpcs:ignoreFile -namespace Drupal\nerdcustom\StreamWrapper; - -use Drupal\Core\StreamWrapper\StreamWrapperInterface; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\ClientException; -use GuzzleHttp\Exception\ServerException; -use Drupal\remote_stream_wrapper\StreamWrapper\HttpStreamWrapper; -use Drupal\Core\Database\Database; - -// @todo, https://github.com/stevector/nerdologues-d8/issues/173 -// these manual require statements should not be necessary. -// Something about the autoloader is failing. -require_once 'modules/contrib/remote_stream_wrapper/src/StreamWrapper/HttpStreamWrapper.php'; -require_once 'modules/contrib/remote_stream_wrapper/src/StreamWrapper/RemoteStreamWrapperInterface.php'; -/** - * HTTP(s) stream wrapper. - */ -class CachedHttpStreamWrapper extends HttpStreamWrapper { - - /** - * {@inheritdoc} - */ - public function stream_stat() { - // @see https://github.com/guzzle/psr7/blob/master/src/StreamWrapper.php - $stat = [ - 'dev' => 0, // device number - 'ino' => 0, // inode number - 'mode' => 0100000 | 0444, // inode protection (regular file + read only) - 'nlink' => 0, // number of links - 'uid' => 0, // userid of owner - 'gid' => 0, // groupid of owner - 'rdev' => 0, // device type, if inode device * - 'size' => 0, // size in bytes - 'atime' => 0, // time of last access (Unix timestamp) - 'mtime' => 0, // time of last modification (Unix timestamp) - 'ctime' => 0, // time of last inode change (Unix timestamp) - 'blksize' => 0, // blocksize of filesystem IO - 'blocks' => 0, // number of blocks allocated - ]; - $files = &drupal_static(__METHOD__, array()); - - if (empty($files) && function_exists('drush_print') && !empty(Database::getConnectionInfo('drupal_7'))) { - drush_print("Loading all files from Drupal 7 database"); - $files = []; - $results = Database::getConnection('default', 'drupal_7') - ->select('file_managed') - ->fields('file_managed')->execute(); - - foreach ($results as $result) { - $files[$result->uri] = [ - 'size' => $result->filesize, - 'mtime' => $result->timestamp - ]; - } - } - - if (!empty($files[$this->uri])) { - $stat = $files[$this->uri] + $stat; - return $stat; - } - else { - return parent::stream_stat(); - } - } -}