Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/batch upload children, with validation according to default widget #896

Merged
merged 22 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e69d918
Add ctools, prior to using it.
adam-vessey Jul 28, 2022
4792044
Fix up all the dependency references.
adam-vessey Jul 28, 2022
91d508a
Merge remote-tracking branch 'origin/2.x' into fix/batch-upload-children
adam-vessey Aug 3, 2022
71f48ff
Some more together.
adam-vessey Aug 3, 2022
593f175
Decent progress... getting things actually rendering...
adam-vessey Aug 5, 2022
648a598
More worky.
adam-vessey Aug 8, 2022
bbb9fc8
Coding standards, and warning of validation issues.
adam-vessey Aug 8, 2022
dacec85
Pull the batch out to a separate service.
adam-vessey Aug 8, 2022
65bccf0
Something of namespacing the child-specific batch...
adam-vessey Aug 15, 2022
ad1b6ba
All together, I think...
adam-vessey Aug 16, 2022
e4f1b20
It is not necessary to explicitly mark the files as permanent.
adam-vessey Aug 16, 2022
a8f4c03
Further generalizing...
adam-vessey Aug 16, 2022
519c352
Adjust class comment.
adam-vessey Aug 16, 2022
5e6a816
Get rid of the deprecation flags.
adam-vessey Aug 16, 2022
c333c97
Remove unused constant.
adam-vessey Aug 23, 2022
6b65cd4
Pass the renderer along, with the version constraint.
adam-vessey Oct 3, 2022
2c42a35
Add update hook to enable ctools in sites where it may not be.
adam-vessey Oct 3, 2022
a5148f5
Cover ALL the exits.
adam-vessey Oct 3, 2022
636261a
Refine message.
adam-vessey Oct 3, 2022
c2a084a
Excessively long line in comment...
adam-vessey Oct 3, 2022
481582d
Bump spec up to allow ctools 4.
adam-vessey Oct 5, 2022
4d5a063
Fix undefined "count" index.
adam-vessey Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"drupal/token" : "^1.3",
"drupal/flysystem" : "^2.0@alpha",
"islandora/crayfish-commons": "^2",
"drupal/file_replace": "^1.1"
"drupal/file_replace": "^1.1",
"drupal/ctools": "^3.8 || ^4"
},
"require-dev": {
"phpunit/phpunit": "^6",
Expand All @@ -37,7 +38,7 @@
"sebastian/phpcpd": "*"
},
"suggest": {
"drupal/transliterate_filenames": "Sanitizes filenames when they are uploaded so they don't break your repository."
"drupal/transliterate_filenames": "Sanitizes filenames when they are uploaded so they don't break your repository."
},
"license": "GPL-2.0-or-later",
"authors": [
Expand Down
25 changes: 13 additions & 12 deletions islandora.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@ dependencies:
- drupal:text
- drupal:options
- drupal:link
- drupal:jsonld
- drupal:search_api
- drupal:jwt
- jsonld:jsonld
- search_api:search_api
- jwt:jwt
- drupal:rest
- drupal:filehash
- filehash:filehash
- drupal:basic_auth
- drupal:context_ui
- context:context_ui
- drupal:action
- drupal:eva
- eva:eva
- drupal:taxonomy
- drupal:views_ui
- drupal:media
- drupal:prepopulate
- drupal:features_ui
- drupal:migrate_source_csv
- prepopulate:prepopulate
- features:features_ui
- migrate_source_csv:migrate_source_csv
- drupal:content_translation
- drupal:flysystem
- drupal:token
- drupal:file_replace
- flysystem:flysystem
- token:token
- file_replace:file_replace
- ctools:ctools
38 changes: 38 additions & 0 deletions islandora.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* Install/update hook implementations.
*/

use Drupal\Core\Extension\ExtensionNameLengthException;
use Drupal\Core\Extension\MissingDependencyException;
use Drupal\Core\Utility\UpdateException;

/**
* Adds common namespaces to jsonld.settings.
*/
Expand Down Expand Up @@ -174,3 +178,37 @@ function update_jsonld_included_namespaces() {
->warning("Could not find required jsonld.settings to add default RDF namespaces.");
}
}

/**
* Ensure that ctools is enabled.
*/
function islandora_update_8007() {
$module_handler = \Drupal::moduleHandler();
if ($module_handler->moduleExists('ctools')) {
return t('The "@module_name" module is already enabled, no action necessary.', [
'@module_name' => 'ctools',
]);
}

/** @var \Drupal\Core\Extension\ModuleInstallerInterface $installer */
$installer = \Drupal::service('module_installer');

try {
if ($installer->install(['ctools'], TRUE)) {
return t('The "@module_name" module was enabled successfully.', [
'@module_name' => 'ctools',
]);
}
}
catch (ExtensionNameLengthException | MissingDependencyException $e) {
throw new UpdateException('Failed; ensure that the ctools module is available in the Drupal installation.', 0, $e);
}
catch (\Exception $e) {
throw new UpdateException('Failed; encountered an exception while trying to enable ctools.', 0, $e);
}

// Theoretically impossible to hit, as ModuleInstaller::install() only returns
// TRUE (or throws/propagates an exception), but... probably a good idea to
// have the here, just in case?
throw new UpdateException('Failed; hit the end of the update hook implementation, which is not expected.');
}
14 changes: 8 additions & 6 deletions islandora.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ islandora.add_member_to_node_page:
_entity_create_any_access: 'node'

islandora.upload_children:
path: '/node/{node}/members/upload'
path: '/node/{node}/members/upload/{step}'
defaults:
_form: '\Drupal\islandora\Form\AddChildrenForm'
_wizard: '\Drupal\islandora\Form\AddChildrenWizard\ChildForm'
_title: 'Upload Children'
step: 'type_selection'
options:
_admin_route: 'TRUE'
requirements:
_custom_access: '\Drupal\islandora\Form\AddChildrenForm::access'
_custom_access: '\Drupal\islandora\Form\AddChildrenWizard\Access::childAccess'

islandora.add_media_to_node_page:
path: '/node/{node}/media/add'
Expand All @@ -58,14 +59,15 @@ islandora.add_media_to_node_page:
_entity_create_any_access: 'media'

islandora.upload_media:
path: '/node/{node}/media/upload'
path: '/node/{node}/media/upload/{step}'
defaults:
_form: '\Drupal\islandora\Form\AddMediaForm'
_wizard: '\Drupal\islandora\Form\AddChildrenWizard\MediaForm'
_title: 'Add media'
step: 'type_selection'
options:
_admin_route: 'TRUE'
requirements:
_custom_access: '\Drupal\islandora\Form\AddMediaForm::access'
_custom_access: '\Drupal\islandora\Form\AddChildrenWizard\Access::mediaAccess'

islandora.media_source_update:
path: '/media/{media}/source'
Expand Down
16 changes: 16 additions & 0 deletions islandora.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,19 @@ services:
arguments: ['@jwt.authentication.jwt']
tags:
- { name: event_subscriber }
islandora.upload_children.batch_processor:
class: Drupal\islandora\Form\AddChildrenWizard\ChildBatchProcessor
arguments:
- '@entity_type.manager'
- '@database'
- '@current_user'
- '@messenger'
- '@date.formatter'
islandora.upload_media.batch_processor:
class: Drupal\islandora\Form\AddChildrenWizard\MediaBatchProcessor
arguments:
- '@entity_type.manager'
- '@database'
- '@current_user'
- '@messenger'
- '@date.formatter'
2 changes: 1 addition & 1 deletion src/Form/AddChildrenForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function buildNodeFinished($success, $results, $operations) {
* @param \Drupal\Core\Routing\RouteMatch $route_match
* The current routing match.
*
* @return \Drupal\Core\Access\AccessResultAllowed|\Drupal\Core\Access\AccessResultForbidden
* @return \Drupal\Core\Access\AccessResultInterface
* Whether we can or can't show the "thing".
*/
public function access(RouteMatch $route_match) {
Expand Down
Loading