Problem/Motivation

PHP Fatal error: Declaration of Drupal\\doi_datacite\\Plugin\\Action\\MintDataCiteDoiAction::buildPreConfigurationForm(array $form, array $values, Drupal\\Core\\Form\\FormStateInterface $form_state) must be compatible with Drupal\\views_bulk_operations\\Action\\ViewsBulkOperationsPreconfigurationInterface::buildPreConfigurationForm(array $element, array $values, Drupal\\Core\\Form\\FormStateInterface $form_state): array

Steps to reproduce

Enable datacite minting for a bundle, visit admin content.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dahousecat created an issue. See original summary.

dahousecat’s picture

velmir_taky made their first commit to this issue’s fork.

velmir_taky’s picture

Status: Active » Needs review

Fixed the method signature in MintDataCiteDoiAction to match the ViewsBulkOperationsPreconfigurationInterface. Also fixed submitConfigurationForm() missing : void return type — same fatal error.

Cleaned up coding standards along the way and added a basic unit test.

dahousecat’s picture

Hi, love your work - glad to see this module is actively maintained :)

Since you brought up coding standards, would it be possible to add type hinting to the services?

For example:

$minter = \Drupal::service('doi_datacite.minter.datacitedois');

$persister = \Drupal::service($persister_id);

Becomes:

/** @var \Drupal\persistent_identifiers\MinterInterface $minter */
$minter = \Drupal::service('doi_datacite.minter.datacitedois');

/** @var \Drupal\persistent_identifiers\PersisterInterface $persister */
$persister = \Drupal::service($persister_id);

The reason I think this is so great is that then I can ctrl click on mint in $minter->mint($node, $conf); and it takes me straight to the method definition.

dahousecat’s picture

All other changes look good - happy to put my RTBC status on it.

velmir_taky’s picture

Added PHPDoc type hints for service variables as suggested in #6 — good idea, thanks @dahousecat!

  - /** @var \Drupal\persistent_identifiers\MinterInterface $minter */ in execute() and buildConfigurationForm()                                                                                                                                                                          
  - /** @var \Drupal\persistent_identifiers\PersisterInterface $persister */ in execute()    

PHPCS clean.

dahousecat’s picture

Looks good to me