Browse Source

remove depracated module_load_include and replace with moduleHandler calls

9.x-3.0
Paul Pound 1 week ago
parent
commit
a232bbf226
  1. 6
      includes/rapidill.inc
  2. 6
      includes/relais.inc
  3. 10
      src/Form/RoblibIllLoanForm.php
  4. 2
      upei_roblib_ill.module

6
includes/rapidill.inc

@ -18,7 +18,7 @@ use RapidIll\RequestType;
*
* Usage (from the form submit handler):
* @code
* module_load_include('inc', 'upei_roblib_ill', 'includes/rapidill');
* \Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/rapidill');
* $handler = new RapidIllRequestHandler();
* $response = $handler->submitRequest($form_state);
* @endcode
@ -214,8 +214,8 @@ class RapidIllRequestHandler {
* optionally a 'RequestNumber' key on success.
*/
public function submitRequest(FormStateInterface $form_state): array {
module_load_include('inc', 'upei_roblib_ill', 'includes/db');
module_load_include('inc', 'upei_roblib_ill', 'includes/utilities');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/db');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/utilities');
// Build the Relais-style array for logging purposes.
$relais_arr = upei_roblib_ill_build_relais_arr($form_state);

6
includes/relais.inc

@ -29,8 +29,8 @@ function upei_roblib_ill_get_pub_type($genre) {
* @return array|mixed
*/
function upei_roblib_ill_add_request($form_state, $aid) {
module_load_include('inc', 'upei_roblib_ill', 'includes/db');
module_load_include('inc', 'upei_roblib_ill', 'includes/utilities');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/db');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/utilities');
$config = \Drupal::config('upei_roblib_ill.settings');
$url = trim($config->get('ill_add_url'));
$relais_arr = upei_roblib_ill_build_relais_arr($form_state);
@ -69,7 +69,7 @@ function upei_roblib_ill_add_request($form_state, $aid) {
* @return array
*/
function upei_roblib_ill_build_relais_arr($form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/utilities');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/utilities');
$storage = $form_state->getStorage();
$ill_request = $storage['request'];
$values = $form_state->getValues();

10
src/Form/RoblibIllLoanForm.php

@ -33,7 +33,7 @@ class RoblibIllLoanForm extends FormBase {
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/relais');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/relais');
$values = $form_state->getValues();
if ($form_state->get('step') == 2) {
$is_valid_email = \Drupal::service('email.validator')->isValid($values['DeliveryAddress']);
@ -54,7 +54,7 @@ class RoblibIllLoanForm extends FormBase {
$form_state->setErrorByName('Surname', $aid['Problem']['Message']);
// Log invalid requests, we need to build the full array here to log it, even though we won't send it yet as auth has failed.
//$form_state->set('upei_roblib_ill_auth_form_storage') = $form_state->getValues();
module_load_include('inc', 'upei_roblib_ill', 'includes/db');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/db');
$arr = upei_roblib_ill_build_relais_arr($form_state);
upei_roblib_ill_log_request($arr, $aid);
}
@ -127,7 +127,7 @@ class RoblibIllLoanForm extends FormBase {
}
public function doiCallback(array &$form, FormStateInterface $form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/doi');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/doi');
$doi = $form_state->getValue('doi');
$form = upei_roblib_ill_doi_get_data($form, $doi);
return $form;
@ -145,7 +145,7 @@ class RoblibIllLoanForm extends FormBase {
* An array representing the bibliographic form.
*/
function ill_request_form($form, &$form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/utilities');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/utilities');
$config = \Drupal::config('upei_roblib_ill.settings');
$form['#prefix'] = '<div id="upei-roblib-ill-request-form">';
$form['#suffix'] = '<div class="roblib-required">* = Required Field</div></div>';
@ -359,7 +359,7 @@ class RoblibIllLoanForm extends FormBase {
* An array representing the bibliographic form.
*/
function ill_auth_form($form, &$form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/utilities');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/utilities');
$form['#prefix'] = upei_roblib_format_biblio_info($form_state);
$form['#suffix'] = '<div class="roblib-required">* = Required Field</div>
<div class="roblib-FOIPP"><strong>Protection of Privacy</strong> - The personal information requested

2
upei_roblib_ill.module

@ -9,7 +9,7 @@
* @return array
*/
function upei_roblib_ill_doi_callback($form, &$form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/doi');
\Drupal::moduleHandler()->loadInclude('upei_roblib_ill', 'inc', 'includes/doi');
$form = upei_roblib_ill_doi_get_data($form, $form_state['values']['doi']);
return $form;
}

Loading…
Cancel
Save