diff --git a/acquia_connector.module b/acquia_connector.module index 62b46b6..e578625 100644 --- a/acquia_connector.module +++ b/acquia_connector.module @@ -12,6 +12,7 @@ use Drupal\acquia_connector\Subscription; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Drupal\Core\Link; +use Drupal\update\UpdateFetcherInterface; // Version of SPI data format. define('ACQUIA_SPI_DATA_VERSION', 3.1); @@ -181,7 +182,7 @@ function acquia_connector_update_status_alter(&$projects) { unset($projects[$project]['security updates']); } else { - $projects[$project]['status'] = UPDATE_NOT_CHECKED; + $projects[$project]['status'] = UpdateFetcherInterface::NOT_CHECKED; $projects[$project]['reason'] = t('No information available from the Acquia Subscription'); unset($projects[$project]['releases']); unset($projects[$project]['recommended']); @@ -244,7 +245,7 @@ function acquia_connector_has_update_service() { * The Exception message. */ function acquia_connector_report_restapi_error($code, $message) { - drupal_set_message(t('Error: @message (@errno)', array('@message' => $message, '@errno' => $code)), 'error'); + \Drupal::messenger()->addMessage(t('Error: @message (@errno)', array('@message' => $message, '@errno' => $code)), 'error'); } /** @@ -300,7 +301,7 @@ function acquia_connector_connection_error_message($errno) { function acquia_connector_modules_installed($modules) { foreach ($modules as $module) { if (function_exists($module . '_acquia_connector_spi_test')) { - drupal_set_message(t("A new invocation of hook_acquia_connector_spi_test() has been detected in @module.", array('@module' => $module))); + \Drupal::messenger()->addMessage(t("A new invocation of hook_acquia_connector_spi_test() has been detected in @module.", array('@module' => $module))); \Drupal::logger('acquia connector spi test')->info("A new invocation of hook_acquia_connector_spi_test() has been detected in @module.", array('@module' => $module)); } } @@ -360,7 +361,7 @@ function acquia_connector_show_free_tier_promo() { '@settings' => Url::fromRoute('acquia_connector.setup')->toString(), ]); - drupal_set_message($message, 'warning', FALSE); + \Drupal::messenger()->addMessage($message, 'warning', FALSE); } @@ -379,6 +380,6 @@ function acquia_connector_auto_connect() { if ($connected && $user->hasPermission('administer site configuration')) { $url = Url::fromRoute('acquia_connector.setup')->toString(); $text = t('Your site has been automatically connected to Acquia. Change subscription', [':url' => $url]); - drupal_set_message($text, 'status', FALSE); + \Drupal::messenger()->addMessage($text, 'status', FALSE); } } diff --git a/acquia_search/acquia_search.install b/acquia_search/acquia_search.install index 84941e2..706f155 100644 --- a/acquia_search/acquia_search.install +++ b/acquia_search/acquia_search.install @@ -15,8 +15,7 @@ function acquia_search_install() { // This causes an invocation of hook_acquia_subscription_status() which is // implemented in this module to set up the environment. // Rebuild data about all currently available modules. - system_rebuild_module_data(); - + \Drupal::service('extension.list.module')->reset()->getList(); _acquia_search_set_version(); $subscription = new Subscription(); $subscription->update(); @@ -125,7 +124,8 @@ function acquia_search_requirements($phase) { function _acquia_search_set_version() { // Cache the version in a variable so we can send it at not extra cost. $version = \Drupal::config('acquia_search.settings')->get('version'); - $info = system_get_info('module', 'acquia_search'); + $extension_list = \Drupal::service('extension.list.module'); + $info = $extension_list->getExtensionInfo('acquia_search'); // Send the version, or at least the core compatibility as a fallback. $new_version = isset($info['version']) ? (string) $info['version'] : (string) \Drupal::VERSION; if ($version != $new_version) { diff --git a/acquia_search/acquia_search.module b/acquia_search/acquia_search.module index 046db59..67ede64 100644 --- a/acquia_search/acquia_search.module +++ b/acquia_search/acquia_search.module @@ -365,7 +365,7 @@ function acquia_search_form_search_api_index_edit_form_alter(&$form) { */ function acquia_search_server_show_read_only_mode_warning() { $message = acquia_search_get_read_only_mode_warning(); - drupal_set_message($message, 'warning'); + \Drupal::messenger()->addMessage($message, 'warning'); } /** @@ -375,10 +375,10 @@ function acquia_search_server_show_read_only_mode_warning() { */ function acquia_search_get_read_only_mode_warning() { - $msg = t('To protect your data, the Acquia Search module is enforcing - read-only mode on the Search API indexes, because it could not figure out + $msg = t('To protect your data, the Acquia Search module is enforcing + read-only mode on the Search API indexes, because it could not figure out what Acquia-hosted Solr index to connect to. This helps you avoid writing to - a production index if you copy your site to a development or other + a production index if you copy your site to a development or other environment(s).'); $core_service = acquia_search_get_core_service(); diff --git a/acquia_search/src/EventSubscriber/SearchSubscriber.php b/acquia_search/src/EventSubscriber/SearchSubscriber.php index 6104300..8fd26f9 100644 --- a/acquia_search/src/EventSubscriber/SearchSubscriber.php +++ b/acquia_search/src/EventSubscriber/SearchSubscriber.php @@ -12,7 +12,7 @@ use Solarium\Core\Client\Response; use Solarium\Core\Event\Events; use Solarium\Core\Event\preExecuteRequest; use Solarium\Core\Event\postExecuteRequest; -use Solarium\Core\Plugin\Plugin; +use Solarium\Core\Plugin\AbstractPlugin; use Drupal\Component\Utility\Crypt; use Solarium\Exception\HttpException; use Drupal\acquia_connector\CryptConnector; @@ -21,7 +21,7 @@ use Drupal\acquia_search\AcquiaSearchV3ApiClient; /** * Extends Solarium plugin: authenticate, etc. */ -class SearchSubscriber extends Plugin { +class SearchSubscriber extends AbstractPlugin { /** * Solarium client. diff --git a/acquia_search/src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php b/acquia_search/src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php index 59e0246..016adca 100644 --- a/acquia_search/src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php +++ b/acquia_search/src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php @@ -9,6 +9,7 @@ namespace Drupal\acquia_search\Plugin\SolrConnector; use Drupal\acquia_connector\Helper\Storage; use Drupal\Core\Url; +use Drupal\Core\Link; use Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase; use Drupal\Core\Form\FormStateInterface; use Drupal\acquia_search\EventSubscriber\SearchSubscriber; @@ -169,7 +170,7 @@ class SearchApiSolrAcquiaConnector extends SolrConnectorPluginBase { $this->configuration['port'] = ($this->configuration['scheme'] == 'https') ? 443 : 80; $this->configuration['key'] = 'core'; $this->solr->createEndpoint($this->configuration, TRUE); - $this->attachServerEndpoint(); + $this->reloadCore(); $this->eventDispatcher = $this->solr->getEventDispatcher(); $plugin = new SearchSubscriber(); $this->solr->registerPlugin('acquia_solr_search_subscriber', $plugin); @@ -237,8 +238,20 @@ class SearchApiSolrAcquiaConnector extends SolrConnectorPluginBase { */ public function viewSettings() { $uri = Url::fromUri('http://www.acquia.com/products-services/acquia-search', array('absolute' => TRUE)); - drupal_set_message(t("Search is being provided by @as.", array('@as' => \Drupal::l(t('Acquia Search'), $uri)))); + \Drupal::messenger()->addMessage(t("Search is being provided by @as.", array('@as' => Link::fromTextAndUrl(t('Acquia Search'), $uri)->toString()))); return parent::viewSettings(); } + /** + * Reloads the Solr core. + * + * @return bool + * TRUE if successful, FALSE otherwise. + * + * @throws \Drupal\search_api_solr\SearchApiSolrException + */ + public function reloadCore() { + // TODO: Implement reloadCore() method. + } + } diff --git a/acquia_search/src/Tests/AcquiaConnectorSearchOverrideTest.php b/acquia_search/src/Tests/AcquiaConnectorSearchOverrideTest.php index af3e2e4..ea95829 100644 --- a/acquia_search/src/Tests/AcquiaConnectorSearchOverrideTest.php +++ b/acquia_search/src/Tests/AcquiaConnectorSearchOverrideTest.php @@ -3,14 +3,14 @@ namespace Drupal\acquia_search\Tests; use Drupal\acquia_connector\Helper\Storage; -use Drupal\simpletest\WebTestBase; +use Drupal\Tests\BrowserTestBase; /** * Tests the automatic switching behavior of the Acquia Search module. * * @group Acquia search */ -class AcquiaConnectorSearchOverrideTest extends WebTestBase { +class AcquiaConnectorSearchOverrideTest extends BrowserTestBase { protected $strictConfigSchema = FALSE; protected $id; protected $key; diff --git a/acquia_search/src/Tests/AcquiaConnectorSearchTest.php b/acquia_search/src/Tests/AcquiaConnectorSearchTest.php index 1bb3051..898c145 100644 --- a/acquia_search/src/Tests/AcquiaConnectorSearchTest.php +++ b/acquia_search/src/Tests/AcquiaConnectorSearchTest.php @@ -6,15 +6,15 @@ namespace Drupal\acquia_search\Tests; -use Drupal\simpletest\WebTestBase; use Drupal\search_api\Entity\Server; +use Drupal\Tests\BrowserTestBase; /** * Tests the functionality of the Acquia Search module. * * @group Acquia search */ -class AcquiaConnectorSearchTest extends WebTestBase { +class AcquiaConnectorSearchTest extends BrowserTestBase { protected $strictConfigSchema = FALSE; protected $id; protected $key; @@ -193,7 +193,7 @@ class AcquiaConnectorSearchTest extends WebTestBase { $this->drupalGet($settings_path); $this->clickLink('Edit', 1); // Check field data types. - $this->assertText('Data sources', t('The Data types label exist'), 'Acquia Search'); + $this->assertText('Acquia Search'); // Check default selected server. $this->assertFieldChecked('edit-server-acquia-search-server', t('By default selected Acquia Search Server'), 'Acquia Search'); // Check fields used for indexing. diff --git a/acquia_search/tests/modules/acquia_search_test/src/EventSubscriber/AcquiaSearchTestSubscriber.php b/acquia_search/tests/modules/acquia_search_test/src/EventSubscriber/AcquiaSearchTestSubscriber.php index 9ea7eed..bd9b8df 100644 --- a/acquia_search/tests/modules/acquia_search_test/src/EventSubscriber/AcquiaSearchTestSubscriber.php +++ b/acquia_search/tests/modules/acquia_search_test/src/EventSubscriber/AcquiaSearchTestSubscriber.php @@ -23,7 +23,7 @@ class AcquiaSearchTestSubscriber implements EventSubscriberInterface { foreach ($allowed_keys as $key) { $value = $event->getRequest()->query->get($key); if (!empty($value)) { - drupal_set_message('acquia_search_test() module set $_ENV[' . $key . '] to ' . $value); + \Drupal::messenger()->addMessage('acquia_search_test() module set $_ENV[' . $key . '] to ' . $value); $_ENV[$key] = $value; } } diff --git a/acquia_search/tests/src/Kernel/AcquiaSearchOverrideTest.php b/acquia_search/tests/src/Kernel/AcquiaSearchOverrideTest.php index 258fe61..9f98b9c 100644 --- a/acquia_search/tests/src/Kernel/AcquiaSearchOverrideTest.php +++ b/acquia_search/tests/src/Kernel/AcquiaSearchOverrideTest.php @@ -33,12 +33,12 @@ class AcquiaSearchOverrideTest extends KernelTestBase { $this->installConfig(array('acquia_connector')); - $guzzle = $this->getMock('GuzzleHttp\Client'); + $guzzle = $this->getMockBuilder('GuzzleHttp\Client')->getMock(); $guzzle->expects($this->any()) ->method('get') ->will($this->returnValue('')); - $client_factory = $this->getMockBuilder('Drupal\Core\Http\ClientFactory')->disableOriginalConstructor()->getMock(); + $client_factory = $this->getMockBuilder('Drupal\Core\Http\ClientFactory')->disableOriginalConstructor()->getMockBuilder(); $client_factory->expects($this->any()) ->method('fromOptions') ->will($this->returnValue($guzzle)); @@ -214,8 +214,7 @@ class AcquiaSearchOverrideTest extends KernelTestBase { protected function _assertGetUpdateQueryException($solr_connector) { // Set the expectation for exception - $this->setExpectedException('Exception', - 'The Search API Server serving this index is currently in read-only mode.'); + $this->expectExceptionMessage('The Search API Server serving this index is currently in read-only mode.'); // Run the code that should throw the exception. // If exception occurred - test passes. If no exception occurred - test fails. diff --git a/src/Client.php b/src/Client.php index f1139b9..62baa52 100644 --- a/src/Client.php +++ b/src/Client.php @@ -145,7 +145,8 @@ class Client { // Include Acquia Search for Search API module version number. if (\Drupal::moduleHandler()->moduleExists('acquia_search')) { foreach (array('acquia_search', 'search_api', 'search_api_solr') as $name) { - $info = system_get_info('module', $name); + $extension_list = \Drupal::service('extension.list.module'); + $info = $extension_list->getExtensionInfo($name); // Send the version, or at least the core compatibility as a fallback. $body['search_version'][$name] = isset($info['version']) ? (string) $info['version'] : (string) $info['core']; } @@ -164,7 +165,7 @@ class Client { } } catch (ConnectorException $e) { - drupal_set_message(t('Error occurred while retrieving Acquia subscription information. See logs for details.'), 'error'); + \Drupal::messenger()->addMessage(t('Error occurred while retrieving Acquia subscription information. See logs for details.'), 'error'); if ($e->isCustomized()) { \Drupal::logger('acquia connector')->error($e->getCustomMessage() . '. Response data: @data', array('@data' => json_encode($e->getAllCustomMessages()))); } @@ -362,7 +363,7 @@ class Client { * Random base 64 encoded string. */ protected function getNonce() { - return Crypt::hashBase64(uniqid(mt_rand(), TRUE) . Crypt::randomBytes(55)); + return Crypt::hashBase64(uniqid(mt_rand(), TRUE) . random_bytes(55)); } /** diff --git a/src/Controller/SecurityReviewController.php b/src/Controller/SecurityReviewController.php index 2fd6bcb..0081c3c 100644 --- a/src/Controller/SecurityReviewController.php +++ b/src/Controller/SecurityReviewController.php @@ -2,6 +2,8 @@ namespace Drupal\acquia_connector\Controller; +use Drupal\Component\FileSecurity\FileSecurity; +use Drupal\user\UserInterface; use Drupal\views\Views; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Site\Settings; @@ -402,7 +404,7 @@ class SecurityReviewController extends ControllerBase { else { $contents = file_get_contents($directory . '/.htaccess'); // Text from includes/file.inc. - $expected = file_htaccess_lines(FALSE); + $expected = FileSecurity::htaccessLines(FALSE); if ($contents !== $expected) { $result = FALSE; $check_result_value[] = 'incorrect_htaccess'; @@ -461,7 +463,7 @@ class SecurityReviewController extends ControllerBase { */ private function checkInputFormats() { $result = TRUE; - $formats = \Drupal::entityManager() + $formats = \Drupal::entityTypeManager() ->getStorage('filter_format') ->loadByProperties(array('status' => TRUE)); $check_result_value = array(); @@ -541,7 +543,7 @@ class SecurityReviewController extends ControllerBase { protected function checkPhpFilter() { $result = TRUE; $check_result_value = array(); - $formats = \Drupal::entityManager() + $formats = \Drupal::entityTypeManager() ->getStorage('filter_format') ->loadByProperties(array('status' => TRUE)); // Check formats that are accessible by untrusted users. @@ -655,7 +657,7 @@ class SecurityReviewController extends ControllerBase { // Need set default value. $user_register = \Drupal::config('user.settings')->get('register'); // If visitors are allowed to create accounts they are considered untrusted. - if ($user_register != USER_REGISTER_ADMINISTRATORS_ONLY) { + if ($user_register != UserInterface::REGISTER_ADMINISTRATORS_ONLY) { $roles[AccountInterface::AUTHENTICATED_ROLE] = 'authenticated user'; } return $roles; diff --git a/src/Controller/SpiController.php b/src/Controller/SpiController.php index 433c753..3802985 100644 --- a/src/Controller/SpiController.php +++ b/src/Controller/SpiController.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Access\AccessResultAllowed; use Drupal\Core\Access\AccessResultForbidden; use Drupal\Core\Controller\ControllerBase; +use Drupal\node\NodeInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Drupal\Core\Routing\RouteMatch; @@ -354,7 +355,7 @@ class SpiController extends ControllerBase { */ private function getLastUsers() { $last_five_users = array(); - $result = db_select('users_field_data', 'u') + $result = \Drupal::database()->select('users_field_data', 'u') ->fields('u', array('uid', 'name', 'mail', 'created')) ->condition('u.created', REQUEST_TIME - 3600, '>') ->orderBy('created', 'DESC') @@ -384,7 +385,7 @@ class SpiController extends ControllerBase { private function getLastNodes() { $last_five_nodes = array(); if (\Drupal::moduleHandler()->moduleExists('node')) { - $result = db_select('node_field_data', 'n') + $result = \Drupal::database()->select('node_field_data', 'n') ->fields('n', array('title', 'type', 'nid', 'created', 'langcode')) ->condition('n.created', REQUEST_TIME - 3600, '>') ->orderBy('n.created', 'DESC') @@ -416,7 +417,7 @@ class SpiController extends ControllerBase { private function getWatchdogData() { $wd = array(); if (\Drupal::moduleHandler()->moduleExists('dblog')) { - $result = db_select('watchdog', 'w') + $result = \Drupal::database()->select('watchdog', 'w') ->fields('w', array('wid', 'severity', 'type', 'message', 'timestamp')) ->condition('w.severity', array(RfcLogLevel::EMERGENCY, RfcLogLevel::CRITICAL), 'IN') ->condition('w.timestamp', REQUEST_TIME - 3600, '>') @@ -438,7 +439,7 @@ class SpiController extends ControllerBase { */ private function getWatchdogSize() { if (\Drupal::moduleHandler()->moduleExists('dblog')) { - return db_select('watchdog', 'w')->fields('w', array('wid'))->countQuery()->execute()->fetchField(); + return \Drupal::database()->select('watchdog', 'w')->fields('w', array('wid'))->countQuery()->execute()->fetchField(); } } @@ -456,7 +457,7 @@ class SpiController extends ControllerBase { $row = 0; if (\Drupal::moduleHandler()->moduleExists('dblog')) { - $result = db_select('watchdog', 'w') + $result = \Drupal::database()->select('watchdog', 'w') ->fields('w', array('message', 'hostname', 'referer', 'timestamp')) ->condition('w.type', 'page not found', '=') ->condition('w.timestamp', REQUEST_TIME - 3600, '>') @@ -498,7 +499,7 @@ class SpiController extends ControllerBase { $cron_interval = $this->config('acquia_connector.settings')->get('spi.cron_interval'); if (\Drupal::moduleHandler()->moduleExists('dblog')) { - $result = db_select('watchdog', 'w') + $result = \Drupal::database()->select('watchdog', 'w') ->fields('w', array('message', 'variables', 'timestamp')) ->condition('w.message', 'login attempt failed%', 'LIKE') ->condition('w.timestamp', REQUEST_TIME - $cron_interval, '>') @@ -536,9 +537,10 @@ class SpiController extends ControllerBase { private function getSystemStatus() { $data = array(); - $profile = drupal_get_profile(); + $profile = \Drupal::installProfile(); if ($profile != 'standard') { - $info = system_get_info('module', $profile); + $extension_list = \Drupal::service('extension.list.module'); + $info = $extension_list->getExtensionInfo($profile); $data['install_profile'] = array( 'title' => 'Install profile', 'value' => sprintf('%s (%s-%s)', $info['name'], $profile, $info['version']), @@ -612,7 +614,7 @@ class SpiController extends ControllerBase { * Whether UID 0 is present. */ private function getUidZerroIsPresent() { - $count = db_query("SELECT uid FROM {users} WHERE uid = 0")->fetchAll(); + $count = \Drupal::database()->query("SELECT uid FROM {users} WHERE uid = 0")->fetchAll(); return (boolean) $count; } @@ -638,7 +640,7 @@ class SpiController extends ControllerBase { if (!empty($roles_name)) { $roles_name_unique = array_unique($roles_name); - $query = db_select('user__roles', 'ur'); + $query = \Drupal::database()->select('user__roles', 'ur'); $query->fields('ur', array('entity_id')); $query->condition('ur.bundle', 'user', '='); $query->condition('ur.deleted', '0', '='); @@ -656,7 +658,7 @@ class SpiController extends ControllerBase { * 1 if the super user has a weak name, 0 otherwise. */ private function getSuperName() { - $result = db_query("SELECT name FROM {users_field_data} WHERE uid = 1 AND (name LIKE '%admin%' OR name LIKE '%root%') AND CHAR_LENGTH(name) < 15")->fetchAll(); + $result = \Drupal::database()->query("SELECT name FROM {users_field_data} WHERE uid = 1 AND (name LIKE '%admin%' OR name LIKE '%root%') AND CHAR_LENGTH(name) < 15")->fetchAll(); return (int) $result; } @@ -671,7 +673,7 @@ class SpiController extends ControllerBase { // http://en.wikipedia.org/wiki/File_system_permissions. $writes = array('2', '3', '6', '7'); $settings_file = './' . DrupalKernel::findSitePath(\Drupal::request(), TRUE) . '/settings.php'; - $permissions = Unicode::substr(sprintf('%o', fileperms($settings_file)), -4); + $permissions = mb_substr(sprintf('%o', fileperms($settings_file)), -4); foreach ($writes as $bit) { if (strpos($permissions, $bit)) { @@ -893,7 +895,7 @@ class SpiController extends ControllerBase { */ private function getModules() { // @todo Only do a full rebuild of the module cache every 1 at the most - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->reset()->getList(); uasort($modules, 'system_sort_modules_by_info_name'); $result = array(); @@ -925,15 +927,15 @@ class SpiController extends ControllerBase { if (\Drupal::moduleHandler()->moduleExists('node')) { // Get only published nodes. - $quantum['nodes'] = db_select('node_field_data', 'n')->fields('n', array('nid'))->condition('n.status', NODE_PUBLISHED)->countQuery()->execute()->fetchField(); + $quantum['nodes'] = \Drupal::database()->select('node_field_data', 'n')->fields('n', array('nid'))->condition('n.status', NodeInterface::PUBLISHED)->countQuery()->execute()->fetchField(); } // Get only active users. - $quantum['users'] = db_select('users_field_data', 'u')->fields('u', array('uid'))->condition('u.status', 1)->countQuery()->execute()->fetchField(); + $quantum['users'] = \Drupal::database()->select('users_field_data', 'u')->fields('u', array('uid'))->condition('u.status', 1)->countQuery()->execute()->fetchField(); if (\Drupal::moduleHandler()->moduleExists('comment')) { // Get only active comments. - $quantum['comments'] = db_select('comment_field_data', 'c')->fields('c', array('cid'))->condition('c.status', 1)->countQuery()->execute()->fetchField(); + $quantum['comments'] = \Drupal::database()->select('comment_field_data', 'c')->fields('c', array('cid'))->condition('c.status', 1)->countQuery()->execute()->fetchField(); } return $quantum; @@ -955,7 +957,7 @@ class SpiController extends ControllerBase { if ($this->checkEnvironmentChange()) { \Drupal::logger('acquia spi')->error('SPI data not sent, site environment change detected.'); - drupal_set_message(t('SPI data not sent, site environment change detected. Please indicate how you wish to proceed.', array( + \Drupal::messenger()->addMessage(t('SPI data not sent, site environment change detected. Please indicate how you wish to proceed.', array( '@environment_change' => Url::fromRoute('acquia_connector.environment_change')->toString(), )), 'error'); return FALSE; @@ -1022,23 +1024,23 @@ class SpiController extends ControllerBase { */ public function spiProcessMessages($response) { if (empty($response['body'])) { - drupal_set_message($this->t('Error sending SPI data. Consult the logs for more information.'), 'error'); + \Drupal::messenger()->addMessage($this->t('Error sending SPI data. Consult the logs for more information.'), 'error'); return; } $message_type = 'status'; if (isset($response['body']['spi_data_received']) && $response['body']['spi_data_received'] === TRUE) { - drupal_set_message($this->t('SPI data sent.')); + \Drupal::messenger()->addMessage($this->t('SPI data sent.')); } if (!empty($response['body']['nspi_messages'])) { - drupal_set_message($this->t('Acquia Subscription returned the following messages. Further information may be in the logs.')); + \Drupal::messenger()->addMessage($this->t('Acquia Subscription returned the following messages. Further information may be in the logs.')); foreach ($response['body']['nspi_messages'] as $nspi_message) { if (!empty($response['body']['spi_error'])) { $message_type = $response['body']['spi_error']; } - drupal_set_message(Html::escape($nspi_message), (string) $message_type); + \Drupal::messenger()->addMessage(Html::escape($nspi_message), (string) $message_type); } } diff --git a/src/Controller/StartController.php b/src/Controller/StartController.php index 6eb78b7..972ed63 100644 --- a/src/Controller/StartController.php +++ b/src/Controller/StartController.php @@ -4,6 +4,7 @@ namespace Drupal\acquia_connector\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Url; +use Drupal\Core\Link; /** * Class StartController. @@ -29,7 +30,7 @@ class StartController extends ControllerBase { ), ); $uri = Url::fromRoute('acquia_connector.setup', array(), array('absolute' => TRUE))->toString(); - $banner = \Drupal::l($banner, Url::fromUri($uri, array('html' => TRUE))); + $banner = Link::fromTextAndUrl($banner, Url::fromUri($uri, array('html' => TRUE)))->toString(); $output = '