You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You will need to copy sites/example.settings.local.php to sites/default/settings.local.php (and ensure settings.php includes settings.local.php) or put this in your settings.php file: $settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';.
// This function exists in core/includes/bootstrap.inc.
// Just need to add lines 6-8 to it.
function _drupal_error_handler($error_level, $message, $filename, $line, $context) {
require_once DRUPAL_ROOT . '/includes/errors.inc';
require_once DRUPAL_ROOT . '/modules/contrib/devel/kint/kint.module';
$d = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
ksm($message, $d);
_drupal_error_handler_real($error_level, $message, $filename, $line, $context);
}
Debugging search API solr queries:
// You can output the Request object using kint/kpm, but it can be hard
// to figure out where to set the debugging code. The best place is in
// the executeRequest function in the following file:
// search_api_solr/src/SolrConnector/SolrConnectorPluginBase.php
Starting point for debugging ElasticSearch stuff, in the file
// src/ElasticSearch/Parameters/Builder/SearchBuilder.php:
// Add ksm at the end of build() and getSearchQueryOptions()
$file = \Drupal\file\Entity\File::load(1007);
OR
$file = \Drupal::entityTypeManager()->getStorage('file')->load(1007);
Working with file entities
// Get the URI (including wrapper, such as public://).
$uri = $file->getFileUri();
// Get the full URL path.
$url = file_create_url($file->getFileUri());
// Get relative path of the URL (w/o domain).
$path = file_url_transform_relative($url);
// Libraries is an array of the library data.
// Extension is 'core' or the module/theme that defined the libraries.
function hook_library_info_alter(&$libraries, $extension)
// Remove the prepareUpdate() section if you just want a normal import.
// To rollback just change 'import' to 'rollback'.
$migration = \Drupal::service('plugin.manager.migration')->createInstance('machine_name');
$migration->getIdMap()->prepareUpdate();
$executable = new \Drupal\migrate_tools\MigrateExecutable($migration, new \Drupal\migrate\MigrateMessage());
$executable->import();
// MigrateExecutable takes an optional third argument where you can provide options including
// limit to limit the number of migrations to perform, and idlist to only migrate certain source
// IDs.
// Example: ['limit' => 10, 'idlist' => '1,2,3']
Trigger select entities to be re-indexed through the Search API.
// This is for Title Record entities, but any entity will do.
use Drupal\search_api\Plugin\search_api\datasource\ContentEntity;
use Drupal\omega_hub\Entity\TitleRecord;
$entity_ids = [507863, 509240, 513703, 515100, 536124, 537058, 541569];
$combine_id = function ($entity_id) {
return $entity_id . ':und';
};
$update_ids = array_map($combine_id, $entity_ids);
$entity = TitleRecord::load(507863);
$indexes = ContentEntity::getIndexesForEntity($entity);
foreach ($indexes as $index) {
$index->trackItemsUpdated('entity:title_record', $update_ids);
}
use Drupal\views\Views;
$view = Views::getView('my_view');
$view->setDisplay('my_display');
$view->preExecute();
$view->execute();
$view->render();
Get various IDs and objects.
// Get query object (only after executing the view).
$query = $view->query;
// Get view ID.
$view->id();
// Get current display.
$view->current_display();
// Get results (after execution).
$view->result;