Skip to content

Drupal 11 support #19

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,3 @@ Required: Add an additional Service with the title “Help” and put text in e
* Check out our production implementation at https://finder.research.cornell.edu
* You will need to configure the SMTP module to allow the Finder module to send mail.
* Installation works only at a root site, not if installed in a subdirectory.

## Drupal 9 changes

Here are some notes that may be useful if you wish to use this module with Drupal 9.

```
src/Controller/StorageController.php line 231: Call to deprecated method entityManager() of class Drupal. Use Drupal::entityTypeManager() instead in most cases.If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service.
The corrected line 231 is:
$field_config = \Drupal::entityTypeManager()->getStorage('field_config')->load("paragraph" . '.' . "service_paragraphs" . '.' . $machine_name)->toArray();
```

```
src/Controller/StorageController.php lines 364, 368:
Call to deprecated function drupal_set_message().
Use Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
Line 364: \Drupal::messenger()->addMessage($this->t('There was a problem sending your message and it was not sent.'), 'error');
Line 368: \Drupal::messenger()->addMessage($this->t('Your message has been sent.'));
```

``
storage.info.yml: Add core_version_requirement: ^8 || ^9
``

```
For PHP 8: same file, at/nearline 361: implode($facets,",") . becomes implode(",",$facets) .
```
10 changes: 5 additions & 5 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions finder.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package: Custom

type: module
core: 8.x
core_version_requirement: ^8 || ^9 || ^10 || ^11
dependencies:
- paragraphs:paragraphs
libraries:
Expand Down
1 change: 1 addition & 0 deletions finder.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ finder:
js:
js/mustache.js: {}
js/jquery.mustache.js: {}
js/contrib/bootstrap.min.js: {}
js/contrib/jquery.ba-throttle-debounce.min.js: {}
js/contrib/jquery.detect_swipe.js: {}
js/app.js: {}
Expand Down
2 changes: 1 addition & 1 deletion finder.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ email_address: [email protected]
email_name: Example
main_header: Main Header
button_select_all: Select All
button_clear_selections: Clear Selections
button_clear_selections: Clear Selections
20 changes: 11 additions & 9 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
<li>\
<div class='question-wrapper'>\
<h4 id='question-{{id}}'>{{question}}</h4>\
<a aria-haspopup='true' class='popup' data-hidden='true' href='#explanation-{{id}}''>\
<span class='fa fa-info-circle' aria-hidden='true'></span>\
<span class='sr-only'>More info about {{question}}</span>\
<a class='control-indicator' data-bs-toggle='collapse' href='#explanation-{{id}}' role='button' aria-expanded='false' aria-controls='explanation-{{id}}'>\
<span class='sr-only'>Expand {{question}}</span>\
</a>\
</div>\
<div class='help' id='explanation-{{id}}'><h3>{{question}}</h3><p>{{{description}}}</p></div>\
<div class='collapse' id='explanation-{{id}}'>\
<div class='explanation'>{{{description}}}</div>\
</div>\
<fieldset aria-labelledby='question-{{id}}'>\
{{#choices}}\
<div class='checkbox' facetid='{{id}}'>\
Expand Down Expand Up @@ -100,7 +101,7 @@

// read the data from JSON endpoints

$.getJSON( "/rest/finder_settings", function( response ) {
$.getJSON( drupalSettings.path.baseUrl + "rest/finder_settings", function( response ) {
//alert(JSON.stringify(response));
$('#pagetitle').html(response.title.replace(/(?:\r\n|\r|\n)/g, '<br />'));
$('#pagesubtitle').html(response.subtitle.replace(/(?:\r\n|\r|\n)/g, '<br />'));
Expand All @@ -109,6 +110,7 @@
$('#pagechartheader').html(response.chart_header.replace(/(?:\r\n|\r|\n)/g, '<br />'));
$('#pageemailformheader').html(response.email_form_header.replace(/(?:\r\n|\r|\n)/g, '<br />'));
//$('#pageemailaddress').html(response.data.email_address);
contact_email = response.email_address;
//$('#pageemailname').html(response.data.email_name);
//$('#pageemailbody').html(response.email_body.replace(/(?:\r\n|\r|\n)/g, '<br />'));
$('#pagemainheader').html(response.main_header.replace(/(?:\r\n|\r|\n)/g, '<br />'));
Expand All @@ -117,7 +119,7 @@
});


$.getJSON( "/rest/facettree", function( response ) {
$.getJSON( drupalSettings.path.baseUrl + "rest/facettree", function( response ) {

// JSON responses are automatically parsed.

Expand Down Expand Up @@ -208,7 +210,7 @@


// load the services
$.getJSON( "/rest/servicelist", function( responseb ) {
$.getJSON( drupalSettings.path.baseUrl + "rest/servicelist", function( responseb ) {
services = responseb;
//servicelist = responseb.data;

Expand Down Expand Up @@ -569,11 +571,11 @@ function validateEmail(Email) {
emailaddresses.push(email);
}
if ($("#emailtordmsg").prop("checked")) {
emailaddresses.push("[email protected]"); // [email protected]
emailaddresses.push(contact_email);
}
if (emailaddresses.length > 0) {
var csrf_token;
$.getJSON( "/rest/session/token", function( response ) {
$.getJSON( drupalSettings.path.baseUrl + "rest/session/token", function( response ) {
csrf_token = response.data;
});

Expand Down
7 changes: 7 additions & 0 deletions js/contrib/bootstrap.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/jquery.mustache.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$.error('TemplateName: ' + templateName + ' is already mapped.');
return;
}
templateMap[templateName] = $.trim(templateHtml);
templateMap[templateName] = templateHtml.trim();
}

/**
Expand Down Expand Up @@ -207,4 +207,4 @@
});
};

}(jQuery, window));
}(jQuery, window));
8 changes: 4 additions & 4 deletions src/Controller/FinderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private function createtestservicelist() {
}


$field_config = \Drupal::entityManager()->getStorage('field_config')->load("paragraph" . '.' . "service_paragraphs" . '.' . $machine_name)->toArray();
$field_config = \Drupal::entityTypeManager()->getStorage('field_config')->load("paragraph" . '.' . "service_paragraphs" . '.' . $machine_name)->toArray();

$field_data["label"] = $field_config["label"];
$field_data["weight"] = $pdcontent[$machine_name]["weight"];
Expand Down Expand Up @@ -279,7 +279,7 @@ public function send_email() {
"with your criteria already selected: " .
\Drupal::request()->getSchemeAndHttpHost() .
"/finder?facets=" .
implode($facets,",") .
implode(",", $facets) .
"\r\n\r\n" .
"If you have any further questions or need more information about " .
"Finder services, please contact the helpdesk to set up a consultation, ".
Expand All @@ -306,11 +306,11 @@ public function send_email() {
$result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);

if ($result['result'] !== true) {
drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
Drupal::messenger()->addMessage($this->t('There was a problem sending your message and it was not sent.'), 'error');
return new JsonResponse("problem");
}
else {
drupal_set_message(t('Your message has been sent.'));
Drupal::messenger()->addMessage($this->t('Your message has been sent.'));
return new JsonResponse("success");
}

Expand Down