Tripal
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Drupal\tripal_chado\Services\ChadoFieldDebugger Class Reference
Collaboration diagram for Drupal\tripal_chado\Services\ChadoFieldDebugger:
Collaboration graph
[legend]

Public Member Functions

 __construct (ChadoConnection $connection, \Drupal\Core\Extension\ModuleHandler $module_handler, TripalLogger $logger)
 
 addFieldToDebugger (string $field_name)
 
 reportValues (array $values, string $message)
 
 summarizeChadoStorage (ChadoStorage $chadostorage, $message)
 
 summarizeBuiltRecords (ChadoRecords $records)
 
 reportQuery (object $query, $message)
 
 printHeader (string $process_name)
 
 printText (string $text)
 

Public Attributes

ChadoConnection $chado_connection
 
Drupal Core Extension ModuleHandler $module_handler
 
TripalLogger $logger
 
array $fields2debug = []
 
bool $has_fields2debug = FALSE
 

Protected Member Functions

 cfd_dpm (mixed $variable, string $message='')
 

Protected Attributes

bool NULL $develIsInstalled = NULL
 

Detailed Description

Provides debugging functionality for Chado data loading in fields extending the ChadoFieldItemBase that use properties to automatically load the data.

THIS SERVICE SHOULD ONLY BE CALLED BY CHADO STORAGE.

If you are a developer of a field looking for debugging information, you should set the $debug variable to TRUE in your field type class.

This variable will be used by ChadoStorage to tell the ChadoFieldDebugger service to display debugging information. All you need to do as a developer is set this variable to TRUE in your field and debuggin information will be displayed on the screen and in the drupal logs when you create, edit, and load content that has you field attached.

For nicely formatted debugging information, installing the drupal/devel module is recommended. If that module is not installed, then we fall back to slightly more primitive print_r output.

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal_chado\Services\ChadoFieldDebugger::__construct ( ChadoConnection  $connection,
\Drupal\Core\Extension\ModuleHandler  $module_handler,
TripalLogger  $logger 
)

Object constructor for the Chado Field debugger

Parameters
Drupal

tripal_chado\Database\ChadoConnection The chado connection used to query chado.

Parameters
Drupal

Core\Extension\ModuleHandler The drupal module handler service.

Parameters
Drupal

tripal\Services\TripalLogger The logger class to use to providing our debugging messages to the developer.

Member Function Documentation

◆ addFieldToDebugger()

Drupal\tripal_chado\Services\ChadoFieldDebugger::addFieldToDebugger ( string  $field_name)

A way for ChadoStorage to tell this service which fields should be debugged.

◆ cfd_dpm()

Drupal\tripal_chado\Services\ChadoFieldDebugger::cfd_dpm ( mixed  $variable,
string  $message = '' 
)
protected

A wrapper for the devel module dpm() function. If that module is not installed and enabled, we will do slightly more primitive output with print_r statements.

Parameters
mixed$variableThe variable to print out, can be any type.
string$messageAn optional message to display with the variable.
Returns
void

◆ printHeader()

Drupal\tripal_chado\Services\ChadoFieldDebugger::printHeader ( string  $process_name)

Print some sort of header to make reading all the output easier ;-p

◆ printText()

Drupal\tripal_chado\Services\ChadoFieldDebugger::printText ( string  $text)

Print random debugging text.

◆ reportQuery()

Drupal\tripal_chado\Services\ChadoFieldDebugger::reportQuery ( object  $query,
  $message 
)

This function will print out the query generated by the query builder. It is expected that this function will be called right before query->execute() is called in all the ChadoStorage::*ChadoRecord() methods.

Parameters
object$queryThis is the object built by the dynamic query builder. For example, if you are generating a select query then this is the object created by ChadoConnection::select() after all fields, conditions and joins have been added to it.
string$messageThis is a simple string to indicate who called this method.

We would like to complete print out the query with subbed in parameters but it's driving me crazy.

Usually we would use $query->arguments() to get the arguments with placeholders but there are a number of bugs here:

  • in Drupal 10 $insertQuery->arguments() provides a scope error.
  • $updateQuery->arguments() only provides the conditional arguments, not those being updated (facepalm; see Drupal Issue #2005626)

$quoted = []; foreach ((array) $query->arguments() as $index => $val) { $key = 'db_placeholder_' . $index; $quoted[$key] = is_null($val) ? 'NULL' : $this->chado_connection->quote($val); } $sql = strtr($sql, $quoted);

◆ reportValues()

Drupal\tripal_chado\Services\ChadoFieldDebugger::reportValues ( array  $values,
string  $message 
)

Prints out the values array in a readable manner for debuggin purposes. This is called by ChadoStorage::buildChadoRecords().

◆ summarizeBuiltRecords()

Drupal\tripal_chado\Services\ChadoFieldDebugger::summarizeBuiltRecords ( ChadoRecords  $records)

This will summarize the results of ChadoStorage::buildChadoRecords().

Parameters
array$recordsThis is an instance of the TripalStorage ChadoRecords class which contains all the information of records to be inserted/modifiedin chado. generated using the Drupal Query Builder in the ChadoStorage::*Values() methods.

◆ summarizeChadoStorage()

Drupal\tripal_chado\Services\ChadoFieldDebugger::summarizeChadoStorage ( ChadoStorage  $chadostorage,
  $message 
)

Summarize the current state of chadostorage.

Parameters
ChadoStorage$chadostorageThe current chadostorage object for interrogation.
string$messageA short message describing where this method was called from.

Member Data Documentation

◆ $chado_connection

ChadoConnection Drupal\tripal_chado\Services\ChadoFieldDebugger::$chado_connection

The chado connection used to query chado.

◆ $develIsInstalled

bool NULL Drupal\tripal_chado\Services\ChadoFieldDebugger::$develIsInstalled = NULL
protected

Store status so it only needs to be looked up once

◆ $fields2debug

array Drupal\tripal_chado\Services\ChadoFieldDebugger::$fields2debug = []

An array of field names to enable debugging information for.

Note: This will be set by chado storage based on the field annotation.

◆ $has_fields2debug

bool Drupal\tripal_chado\Services\ChadoFieldDebugger::$has_fields2debug = FALSE

A simple flag to indicate if there are any fields to be debugged for performances sake.

◆ $logger

TripalLogger Drupal\tripal_chado\Services\ChadoFieldDebugger::$logger

The logger class to use to providing our debugging messages to the developer.

◆ $module_handler

Drupal Core Extension ModuleHandler Drupal\tripal_chado\Services\ChadoFieldDebugger::$module_handler

The module handler class, used to check if devel module is enabled.


The documentation for this class was generated from the following file: