diff --git a/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php b/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php index a4809dd..6af5b75 100644 --- a/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php +++ b/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php @@ -9,7 +9,7 @@ namespace Drupal\search_api_db_defaults\Tests; use Drupal\comment\Entity\CommentType; use Drupal\comment\Tests\CommentTestTrait; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\Config\UnmetDependenciesException; use Drupal\search_api\Entity\Index; use Drupal\search_api\Entity\Server; @@ -66,7 +66,7 @@ class IntegrationTest extends WebTestBase { $this->rebuildContainer(); // Assert if the module was successfully enabled. - $this->assertTrue($success, SafeMarkup::format('Enabled search_api_db_defaults, including its dependencies: %modules', array('%modules' => implode(', ', $dependencies)))); + $this->assertTrue($success, new FormattableString('Enabled search_api_db_defaults, including its dependencies: %modules', array('%modules' => implode(', ', $dependencies)))); } catch (UnmetDependenciesException $e) { // The exception message has all the details. diff --git a/search_api_db/src/Plugin/search_api/backend/Database.php b/search_api_db/src/Plugin/search_api/backend/Database.php index 9d2fc88..f400e89 100644 --- a/search_api_db/src/Plugin/search_api/backend/Database.php +++ b/search_api_db/src/Plugin/search_api/backend/Database.php @@ -7,8 +7,8 @@ namespace Drupal\search_api_db\Plugin\search_api\backend; +use Drupal\Component\Utility\FormattableString; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Database\Database as CoreDatabase; @@ -682,7 +682,7 @@ class Database extends BackendPluginBase { return array('type' => 'int', 'size' => 'tiny'); default: - throw new SearchApiException(SafeMarkup::format('Unknown field type @type. Database search module might be out of sync with Search API.', array('@type' => $type))); + throw new SearchApiException(new FormattableString('Unknown field type @type. Database search module might be out of sync with Search API.', array('@type' => $type))); } } @@ -960,7 +960,7 @@ class Database extends BackendPluginBase { */ public function indexItems(IndexInterface $index, array $items) { if (!$this->getIndexDbInfo($index)) { - throw new SearchApiException(SafeMarkup::format('No field settings for index with id @id.', array('@id' => $index->id()))); + throw new SearchApiException(new FormattableString('No field settings for index with id @id.', array('@id' => $index->id()))); } $indexed = array(); foreach ($items as $id => $item) { @@ -1278,7 +1278,7 @@ class Database extends BackendPluginBase { return strtotime($value); default: - throw new SearchApiException(SafeMarkup::format('Unknown field type @type. Database search module might be out of sync with Search API.', array('@type' => $type))); + throw new SearchApiException(new FormattableString('Unknown field type @type. Database search module might be out of sync with Search API.', array('@type' => $type))); } } @@ -1337,7 +1337,7 @@ class Database extends BackendPluginBase { $db_info = $this->getIndexDbInfo($index); if (!isset($db_info['field_tables'])) { - throw new SearchApiException(SafeMarkup::format('Unknown index @id.', array('@id' => $index->id()))); + throw new SearchApiException(new FormattableString('Unknown index @id.', array('@id' => $index->id()))); } $fields = $this->getFieldInfo($index); @@ -1381,7 +1381,7 @@ class Database extends BackendPluginBase { } if (!isset($fields[$field_name])) { - throw new SearchApiException(SafeMarkup::format('Trying to sort on unknown field @field.', array('@field' => $field_name))); + throw new SearchApiException(new FormattableString('Trying to sort on unknown field @field.', array('@field' => $field_name))); } $alias = $this->getTableAlias(array('table' => $db_info['index_table']), $db_query); $db_query->orderBy($alias . '.' . $fields[$field_name]['column'], $order); @@ -1458,12 +1458,12 @@ class Database extends BackendPluginBase { $fulltext_field_information = array(); foreach ($fulltext_fields as $name) { if (!isset($fields[$name])) { - throw new SearchApiException(SafeMarkup::format('Unknown field @field specified as search target.', array('@field' => $name))); + throw new SearchApiException(new FormattableString('Unknown field @field specified as search target.', array('@field' => $name))); } if (!Utility::isTextType($fields[$name]['type'])) { $types = $this->getDataTypePluginManager()->getDataTypeDefinitions(); $type = $types[$fields[$name]['type']]['label']; - throw new SearchApiException(SafeMarkup::format('Cannot perform fulltext search on field @field of type @type.', array('@field' => $name, '@type' => $type))); + throw new SearchApiException(new FormattableString('Cannot perform fulltext search on field @field of type @type.', array('@field' => $name, '@type' => $type))); } $fulltext_field_information[$name] = $fields[$name]; } @@ -1840,7 +1840,7 @@ class Database extends BackendPluginBase { continue; } if (!isset($fields[$f[0]])) { - throw new SearchApiException(SafeMarkup::format('Unknown field in filter clause: @field.', array('@field' => $f[0]))); + throw new SearchApiException(new FormattableString('Unknown field in filter clause: @field.', array('@field' => $f[0]))); } $field = $fields[$f[0]]; // Fields have their own table, so we have to check for NULL values in @@ -2083,7 +2083,7 @@ class Database extends BackendPluginBase { $index = $query->getIndex(); $db_info = $this->getIndexDbInfo($index); if (empty($db_info['field_tables'])) { - throw new SearchApiException(SafeMarkup::format('Unknown index @id.', array('@id' => $index->id()))); + throw new SearchApiException(new FormattableString('Unknown index @id.', array('@id' => $index->id()))); } $fields = $this->getFieldInfo($index); diff --git a/search_api_db/src/Tests/BackendTest.php b/search_api_db/src/Tests/BackendTest.php index 4a781aa..5e1b27b 100644 --- a/search_api_db/src/Tests/BackendTest.php +++ b/search_api_db/src/Tests/BackendTest.php @@ -7,7 +7,7 @@ namespace Drupal\search_api_db\Tests; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\Database\Database; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -117,8 +117,8 @@ class BackendTest extends EntityUnitTestBase { $this->assertTrue(\Drupal::database()->schema()->tableExists($normalized_storage_table), 'Normalized storage table exists'); foreach ($field_tables as $field_table) { - $this->assertTrue(\Drupal::database()->schema()->tableExists($field_table['table']), SafeMarkup::format('Field table %table exists', array('%table' => $field_table['table']))); - $this->assertTrue(\Drupal::database()->schema()->fieldExists($normalized_storage_table, $field_table['column']), SafeMarkup::format('Field column %column exists', array('%column' => $field_table['column']))); + $this->assertTrue(\Drupal::database()->schema()->tableExists($field_table['table']), new FormattableString('Field table %table exists', array('%table' => $field_table['table']))); + $this->assertTrue(\Drupal::database()->schema()->fieldExists($normalized_storage_table, $field_table['column']), new FormattableString('Field column %column exists', array('%column' => $field_table['column']))); } } @@ -866,7 +866,7 @@ class BackendTest extends EntityUnitTestBase { $this->assertEqual($db_info, array(), 'The index was successfully removed from the server.'); $this->assertFalse(Database::getConnection()->schema()->tableExists($normalized_storage_table), 'The index tables were deleted.'); foreach ($field_tables as $field_table) { - $this->assertFalse(\Drupal::database()->schema()->tableExists($field_table['table']), SafeMarkup::format('Field table %table exists', array('%table' => $field_table['table']))); + $this->assertFalse(\Drupal::database()->schema()->tableExists($field_table['table']), new FormattableString('Field table %table exists', array('%table' => $field_table['table']))); } // Re-add the index to see if the associated tables are also properly @@ -880,7 +880,7 @@ class BackendTest extends EntityUnitTestBase { $this->assertEqual($db_info, array(), 'The index was successfully removed from the server.'); $this->assertFalse(Database::getConnection()->schema()->tableExists($normalized_storage_table), 'The index tables were deleted.'); foreach ($field_tables as $field_table) { - $this->assertFalse(\Drupal::database()->schema()->tableExists($field_table['table']), SafeMarkup::format('Field table %table exists', array('%table' => $field_table['table']))); + $this->assertFalse(\Drupal::database()->schema()->tableExists($field_table['table']), new FormattableString('Field table %table exists', array('%table' => $field_table['table']))); } // Uninstall the module. diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index 1ebc1ff..2748399 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Controller; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\Controller\ControllerBase; use Drupal\search_api\IndexInterface; @@ -51,7 +51,7 @@ class IndexController extends ControllerBase { * The page title. */ public function pageTitle(IndexInterface $search_api_index) { - return SafeMarkup::format('@title', array('@title' => $search_api_index->label())); + return new FormattableString('@title', array('@title' => $search_api_index->label())); } /** diff --git a/src/Controller/ServerController.php b/src/Controller/ServerController.php index 6014c82..38ea99e 100644 --- a/src/Controller/ServerController.php +++ b/src/Controller/ServerController.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Controller; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\Controller\ControllerBase; use Drupal\search_api\ServerInterface; @@ -54,7 +54,7 @@ class ServerController extends ControllerBase { * The page title. */ public function pageTitle(ServerInterface $search_api_server) { - return SafeMarkup::format('@title', array('@title' => $search_api_server->label())); + return new FormattableString('@title', array('@title' => $search_api_server->label())); } /** diff --git a/src/Entity/Index.php b/src/Entity/Index.php index 9ef351f..b021e18 100644 --- a/src/Entity/Index.php +++ b/src/Entity/Index.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Entity; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\Cache\Cache; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\EntityInterface; @@ -357,7 +357,7 @@ class Index extends ConfigEntityBase implements IndexInterface { if (empty($datasources[$datasource_id])) { $args['@datasource'] = $datasource_id; $args['%index'] = $this->label(); - throw new SearchApiException(SafeMarkup::format('The datasource with ID "@datasource" could not be retrieved for index %index.', $args)); + throw new SearchApiException(new FormattableString('The datasource with ID "@datasource" could not be retrieved for index %index.', $args)); } return $datasources[$datasource_id]; } @@ -417,7 +417,7 @@ class Index extends ConfigEntityBase implements IndexInterface { if (!($this->trackerPlugin = \Drupal::service('plugin.manager.search_api.tracker')->createInstance($this->getTrackerId(), $tracker_plugin_configuration))) { $args['@tracker'] = $this->tracker; $args['%index'] = $this->label(); - throw new SearchApiException(SafeMarkup::format('The tracker with ID "@tracker" could not be retrieved for index %index.', $args)); + throw new SearchApiException(new FormattableString('The tracker with ID "@tracker" could not be retrieved for index %index.', $args)); } } @@ -454,7 +454,7 @@ class Index extends ConfigEntityBase implements IndexInterface { if (!$this->serverInstance) { $args['@server'] = $this->server; $args['%index'] = $this->label(); - throw new SearchApiException(SafeMarkup::format('The server with ID "@server" could not be retrieved for index %index.', $args)); + throw new SearchApiException(new FormattableString('The server with ID "@server" could not be retrieved for index %index.', $args)); } } @@ -631,7 +631,7 @@ class Index extends ConfigEntityBase implements IndexInterface { if ($this->unmappedFields) { $vars['@fields'] = array(); foreach ($this->unmappedFields as $type => $fields) { - $vars['@fields'][] = implode(', ', $fields) . ' (' . SafeMarkup::format('type @type', array('@type' => $type)) . ')'; + $vars['@fields'][] = implode(', ', $fields) . ' (' . new FormattableString('type @type', array('@type' => $type)) . ')'; } $vars['@fields'] = implode('; ', $vars['@fields']); $vars['%index'] = $this->label(); @@ -997,10 +997,10 @@ class Index extends ConfigEntityBase implements IndexInterface { return array(); } if (!$this->status) { - throw new SearchApiException(SafeMarkup::format("Couldn't index values on index %index (index is disabled)", array('%index' => $this->label()))); + throw new SearchApiException(new FormattableString("Couldn't index values on index %index (index is disabled)", array('%index' => $this->label()))); } if (empty($this->options['fields'])) { - throw new SearchApiException(SafeMarkup::format("Couldn't index values on index %index (no fields selected)", array('%index' => $this->label()))); + throw new SearchApiException(new FormattableString("Couldn't index values on index %index (no fields selected)", array('%index' => $this->label()))); } /** @var \Drupal\search_api\Item\ItemInterface[] $items */ diff --git a/src/Entity/Server.php b/src/Entity/Server.php index e737946..12193d2 100644 --- a/src/Entity/Server.php +++ b/src/Entity/Server.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Entity; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\search_api\SearchApiException; @@ -134,7 +134,7 @@ class Server extends ConfigEntityBase implements ServerInterface { if (!($this->backendPlugin = $backend_plugin_manager->createInstance($this->getBackendId(), $config))) { $args['@backend'] = $this->getBackendId(); $args['%server'] = $this->label(); - throw new SearchApiException(SafeMarkup::format('The backend with ID "@backend" could not be retrieved for server %server.', $args)); + throw new SearchApiException(new FormattableString('The backend with ID "@backend" could not be retrieved for server %server.', $args)); } } return $this->backendPlugin; @@ -260,7 +260,7 @@ class Server extends ConfigEntityBase implements ServerInterface { return $this->getBackend()->indexItems($index, $items); } $args['%index'] = $index->label(); - throw new SearchApiException(SafeMarkup::format('Could not index items on index %index because pending server tasks could not be executed.', $args)); + throw new SearchApiException(new FormattableString('Could not index items on index %index because pending server tasks could not be executed.', $args)); } /** @@ -344,7 +344,7 @@ class Server extends ConfigEntityBase implements ServerInterface { '%server' => $this->label(), '@indexes' => implode(', ', $failed), ); - $message = SafeMarkup::format('Deleting all items from server %server failed for the following (write-enabled) indexes: @indexes.', $args); + $message = new FormattableString('Deleting all items from server %server failed for the following (write-enabled) indexes: @indexes.', $args); throw new SearchApiException($message, 0, $e); } return $this; diff --git a/src/Form/IndexProcessorsForm.php b/src/Form/IndexProcessorsForm.php index f26eacb..53a9571 100644 --- a/src/Form/IndexProcessorsForm.php +++ b/src/Form/IndexProcessorsForm.php @@ -7,8 +7,8 @@ namespace Drupal\search_api\Form; +use Drupal\Component\Utility\FormattableString; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; diff --git a/src/IndexBatchHelper.php b/src/IndexBatchHelper.php index c46bf06..b3861d0 100644 --- a/src/IndexBatchHelper.php +++ b/src/IndexBatchHelper.php @@ -7,7 +7,7 @@ namespace Drupal\search_api; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\StringTranslation\TranslationInterface; /** @@ -103,7 +103,7 @@ class IndexBatchHelper { '%limit' => $limit, '%name' => $index->label(), ); - throw new SearchApiException(SafeMarkup::format('Failed to create a batch with batch size %size and limit %limit for index %name', $args)); + throw new SearchApiException(new FormattableString('Failed to create a batch with batch size %size and limit %limit for index %name', $args)); } } diff --git a/src/Item/FieldTrait.php b/src/Item/FieldTrait.php index 42426ec..7e48e50 100644 --- a/src/Item/FieldTrait.php +++ b/src/Item/FieldTrait.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Item; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\search_api\Entity\Index; use Drupal\search_api\SearchApiException; use Drupal\search_api\IndexInterface; @@ -388,7 +388,7 @@ trait FieldTrait { if (!isset($definitions[$this->propertyPath])) { $args['@field'] = $this->fieldIdentifier; $args['%index'] = $this->index->label(); - throw new SearchApiException(SafeMarkup::format('Could not retrieve data definition for field "@field" on index %index.', $args)); + throw new SearchApiException(new FormattableString('Could not retrieve data definition for field "@field" on index %index.', $args)); } $this->dataDefinition = $definitions[$this->propertyPath]; } diff --git a/src/Plugin/views/argument/SearchApiDate.php b/src/Plugin/views/argument/SearchApiDate.php index bf9b656..f017a7e 100644 --- a/src/Plugin/views/argument/SearchApiDate.php +++ b/src/Plugin/views/argument/SearchApiDate.php @@ -7,8 +7,8 @@ namespace Drupal\search_api\Plugin\views\argument; +use Drupal\Component\Utility\FormattableString; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeMarkup; /** * Defines a contextual filter for conditions on date fields. @@ -153,7 +153,7 @@ class SearchApiDate extends SearchApiArgument { */ protected function abort() { $variables['@field'] = $this->definition['group'] . ': ' . $this->definition['title']; - $this->query->abort(SafeMarkup::format('Illegal argument passed to @field contextual filter.', $variables)); + $this->query->abort(new FormattableString('Illegal argument passed to @field contextual filter.', $variables)); } } diff --git a/src/Plugin/views/display/FacetsBlock.php b/src/Plugin/views/display/FacetsBlock.php index 220e6f2..3348112 100644 --- a/src/Plugin/views/display/FacetsBlock.php +++ b/src/Plugin/views/display/FacetsBlock.php @@ -7,8 +7,8 @@ namespace Drupal\search_api\Plugin\views\display; +use Drupal\Component\Utility\FormattableString; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Xss; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; @@ -188,7 +188,7 @@ class FacetsBlock extends Block { if (!$index) { $views_data = Views::viewsData($table); $table = empty($views_data['table']['base']['title']) ? $table : $views_data['table']['base']['title']; - throw new SearchApiException(SafeMarkup::format('The "Facets block" display cannot be used with a view for @base_table. Please only use this display with base tables representing Search API indexes.', array('@base_table' => $table))); + throw new SearchApiException(new FormattableString('The "Facets block" display cannot be used with a view for @base_table. Please only use this display with base tables representing Search API indexes.', array('@base_table' => $table))); } $this->field_options = array(); foreach ($index->getFields() as $key => $field) { diff --git a/src/Plugin/views/query/SearchApiQuery.php b/src/Plugin/views/query/SearchApiQuery.php index 8261ad8..d0d4b54 100644 --- a/src/Plugin/views/query/SearchApiQuery.php +++ b/src/Plugin/views/query/SearchApiQuery.php @@ -7,8 +7,8 @@ namespace Drupal\search_api\Plugin\views\query; +use Drupal\Component\Utility\FormattableString; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; @@ -137,7 +137,7 @@ class SearchApiQuery extends QueryPluginBase { $this->fields = array(); $this->index = self::getIndexFromTable($view->storage->get('base_table')); if (!$this->index) { - $this->abort(SafeMarkup::format('View %view is not based on Search API but tries to use its query plugin.', array('%view' => $view->storage->label()))); + $this->abort(new FormattableString('View %view is not based on Search API but tries to use its query plugin.', array('%view' => $view->storage->label()))); } $this->query = $this->index->query(array( 'parse mode' => $this->options['parse_mode'], diff --git a/src/Plugin/views/row/SearchApiRow.php b/src/Plugin/views/row/SearchApiRow.php index 1babdda..97ec351 100644 --- a/src/Plugin/views/row/SearchApiRow.php +++ b/src/Plugin/views/row/SearchApiRow.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Plugin\views\row; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Logger\LoggerChannelInterface; @@ -122,7 +122,7 @@ class SearchApiRow extends RowPluginBase { $base_table = $view->storage->get('base_table'); $this->index = SearchApiQuery::getIndexFromTable($base_table, $this->getEntityManager()); if (!$this->index) { - throw new \InvalidArgumentException(SafeMarkup::format('View %view is not based on Search API but tries to use its row plugin.', array('%view' => $view->storage->label()))); + throw new \InvalidArgumentException(new FormattableString('View %view is not based on Search API but tries to use its row plugin.', array('%view' => $view->storage->label()))); } } diff --git a/src/Query/Query.php b/src/Query/Query.php index 14957dc..b231d0d 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Query; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\search_api\SearchApiException; use Drupal\search_api\IndexInterface; @@ -111,12 +111,12 @@ class Query implements QueryInterface { */ public function __construct(IndexInterface $index, ResultsCacheInterface $results_cache, array $options = array()) { if (!$index->status()) { - throw new SearchApiException(SafeMarkup::format("Can't search on index %index which is disabled.", array('%index' => $index->label()))); + throw new SearchApiException(new FormattableString("Can't search on index %index which is disabled.", array('%index' => $index->label()))); } if (isset($options['parse mode'])) { $modes = $this->parseModes(); if (!isset($modes[$options['parse mode']])) { - throw new SearchApiException(SafeMarkup::format('Unknown parse mode: @mode.', array('@mode' => $options['parse mode']))); + throw new SearchApiException(new FormattableString('Unknown parse mode: @mode.', array('@mode' => $options['parse mode']))); } } $this->index = $index; @@ -242,7 +242,7 @@ class Query implements QueryInterface { public function setFulltextFields(array $fields = NULL) { $fulltext_fields = $this->index->getFulltextFields(); foreach (array_diff($fields, $fulltext_fields) as $field_id) { - throw new SearchApiException(SafeMarkup::format('Trying to search on field @field which is no indexed fulltext field.', array('@field' => $field_id))); + throw new SearchApiException(new FormattableString('Trying to search on field @field which is no indexed fulltext field.', array('@field' => $field_id))); } $this->fields = $fields; return $this; @@ -274,7 +274,7 @@ class Query implements QueryInterface { 'search_api_id' => array('type' => 'integer'), ); if (empty($fields[$field])) { - throw new SearchApiException(SafeMarkup::format('Trying to sort on unknown field @field.', array('@field' => $field))); + throw new SearchApiException(new FormattableString('Trying to sort on unknown field @field.', array('@field' => $field))); } $order = strtoupper(trim($order)) == 'DESC' ? 'DESC' : 'ASC'; $this->sorts[$field] = $order; diff --git a/src/Tests/LanguageIntegrationUnitTest.php b/src/Tests/LanguageIntegrationUnitTest.php index 0876de2..4de6752 100644 --- a/src/Tests/LanguageIntegrationUnitTest.php +++ b/src/Tests/LanguageIntegrationUnitTest.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Tests; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\entity_test\Entity\EntityTestMul; use Drupal\search_api\Entity\Index; use Drupal\search_api\Entity\Server; @@ -93,8 +93,8 @@ class LanguageIntegrationUnitTest extends EntityLanguageTestBase { 'user_id' => $this->container->get('current_user')->id(), )); $entity_1->save(); - $this->assertEqual($entity_1->language()->getId(), 'en', SafeMarkup::format('%entity_type: Entity language set to site default.', array('%entity_type' => $this->testEntityTypeId))); - $this->assertFalse($entity_1->getTranslationLanguages(FALSE), SafeMarkup::format('%entity_type: No translations are available', array('%entity_type' => $this->testEntityTypeId))); + $this->assertEqual($entity_1->language()->getId(), 'en', new FormattableString('%entity_type: Entity language set to site default.', array('%entity_type' => $this->testEntityTypeId))); + $this->assertFalse($entity_1->getTranslationLanguages(FALSE), new FormattableString('%entity_type: No translations are available', array('%entity_type' => $this->testEntityTypeId))); $entity_2 = EntityTestMul::create(array( 'id' => 2, @@ -102,8 +102,8 @@ class LanguageIntegrationUnitTest extends EntityLanguageTestBase { 'user_id' => $this->container->get('current_user')->id(), )); $entity_2->save(); - $this->assertEqual($entity_2->language()->getId(), 'en', SafeMarkup::format('%entity_type: Entity language set to site default.', array('%entity_type' => $this->testEntityTypeId))); - $this->assertFalse($entity_2->getTranslationLanguages(FALSE), SafeMarkup::format('%entity_type: No translations are available', array('%entity_type' => $this->testEntityTypeId))); + $this->assertEqual($entity_2->language()->getId(), 'en', new FormattableString('%entity_type: Entity language set to site default.', array('%entity_type' => $this->testEntityTypeId))); + $this->assertFalse($entity_2->getTranslationLanguages(FALSE), new FormattableString('%entity_type: No translations are available', array('%entity_type' => $this->testEntityTypeId))); // Test that the datasource returns the correct item IDs. $datasource = $this->index->getDatasource('entity:' . $this->testEntityTypeId); @@ -125,8 +125,8 @@ class LanguageIntegrationUnitTest extends EntityLanguageTestBase { $default_langcode = $this->langcodes[0]; $entity_1->get('langcode')->setValue($default_langcode); $entity_1->save(); - $this->assertEqual($entity_1->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), SafeMarkup::format('%entity_type: Entity language retrieved.', array('%entity_type' => $this->testEntityTypeId))); - $this->assertFalse($entity_1->getTranslationLanguages(FALSE), SafeMarkup::format('%entity_type: No translations are available', array('%entity_type' => $this->testEntityTypeId))); + $this->assertEqual($entity_1->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), new FormattableString('%entity_type: Entity language retrieved.', array('%entity_type' => $this->testEntityTypeId))); + $this->assertFalse($entity_1->getTranslationLanguages(FALSE), new FormattableString('%entity_type: No translations are available', array('%entity_type' => $this->testEntityTypeId))); // Test that the datasource returns the correct item IDs. $datasource_item_ids = $datasource->getItemIds(); @@ -147,7 +147,7 @@ class LanguageIntegrationUnitTest extends EntityLanguageTestBase { $translation->save(); $translation = $entity_1->getTranslation($this->langcodes[2]); $translation->save(); - $this->assertTrue($entity_1->getTranslationLanguages(FALSE), SafeMarkup::format('%entity_type: Translations are available', array('%entity_type' => $this->testEntityTypeId))); + $this->assertTrue($entity_1->getTranslationLanguages(FALSE), new FormattableString('%entity_type: Translations are available', array('%entity_type' => $this->testEntityTypeId))); $datasource_item_ids = $datasource->getItemIds(); sort($datasource_item_ids); diff --git a/src/Tests/ServerTaskUnitTest.php b/src/Tests/ServerTaskUnitTest.php index 319c2c1..21d77d3 100644 --- a/src/Tests/ServerTaskUnitTest.php +++ b/src/Tests/ServerTaskUnitTest.php @@ -7,7 +7,7 @@ namespace Drupal\search_api\Tests; -use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\FormattableString; use Drupal\search_api\Entity\Index; use Drupal\search_api\Entity\Server; use Drupal\search_api\SearchApiException; @@ -217,7 +217,7 @@ class ServerTaskUnitTest extends KernelTestBase { } catch (SearchApiException $e) { $args['%index'] = $this->index->label(); - $expected_message = SafeMarkup::format('Could not index items on index %index because pending server tasks could not be executed.', $args); + $expected_message = new FormattableString('Could not index items on index %index because pending server tasks could not be executed.', $args); $this->assertEqual($e->getMessage(), $expected_message, 'Pending server tasks prevented indexing of items.'); } $this->assertEqual($this->getCalledServerMethods(), array(), 'indexItems was not executed.');