Browse Source

Read streams without constructor

main
astanley 7 months ago
parent
commit
e4f64d9be4
  1. 4
      src/Controller/InstructionsController.php
  2. 12
      src/Form/CreateMediaFromFileForm.php

4
src/Controller/InstructionsController.php

@ -27,11 +27,11 @@ class InstructionsController extends ControllerBase {
<p>The destination directory will exist within the Drupal file system. The path is relative, and the folder will be created within the file system <p>The destination directory will exist within the Drupal file system. The path is relative, and the folder will be created within the file system
if it does not already exist. The user must have permissions to create folders and write files in the selected file system.</p> if it does not already exist. The user must have permissions to create folders and write files in the selected file system.</p>
<p> The filesystem is defined within the Media Types definitions. The uploaded files will be stored <p> The filesystem is defined within the Media Types definitions. The uploaded files will be stored
in that system unless another file system is selected. in that system unless another file system is selected. <em>n.b</em>. If your installation only uses one file system this choice is irrelevant
<p> <p>
<p>File ownership is normally <strong>www-data:www-data</strong> on Apache systems and <strong>nginx:nginx</strong> for <p>File ownership is normally <strong>www-data:www-data</strong> on Apache systems and <strong>nginx:nginx</strong> for
a Docker based Islandora installation. The default value is normally fine, but confirm with your systems administrator a Docker based Islandora installation. The default value is normally fine, but confirm with your systems administrator
if you are unsure. <em>n.b</em>. If your installation only uses one file system this choice is irrelevant. if you are unsure.
</p>"; </p>";
return [ return [
'#type' => 'markup', '#type' => 'markup',

12
src/Form/CreateMediaFromFileForm.php

@ -107,18 +107,20 @@ final class CreateMediaFromFileForm extends FormBase {
$file_system_options = []; $file_system_options = [];
$file_system_options['default'] = $this->t("File system defined in media type"); $file_system_options['default'] = $this->t("File system defined in media type");
$unwanted = ['temporary', 'assets']; $unwanted = ['temporary', 'assets', 'temporary', 'library-definitions', 'asset', 'php-file'];
foreach ($wrappers as $scheme => $wrapper_info) { foreach ($wrappers as $scheme => $wrapper_info) {
if (in_array($scheme, $unwanted)) { if (in_array($scheme, $unwanted)) {
continue; continue;
} }
$class = $wrapper_info['class']; try {
if (is_a($class, StreamWrapperInterface::class, TRUE) && class_exists($class)) { $instance = $this->streamWrapperManager->getViaScheme($scheme);
$instance = new $class();
$instance->setUri($scheme . '://');
$file_system_options[$scheme] = $instance->getName() ?: $scheme; $file_system_options[$scheme] = $instance->getName() ?: $scheme;
} }
catch (\Exception $e) {
// Log or ignore missing/broken stream wrapper
}
} }
$media_types = $this->entityTypeManager->getStorage('media_type')->loadMultiple(); $media_types = $this->entityTypeManager->getStorage('media_type')->loadMultiple();

Loading…
Cancel
Save