function DevelDumperManager::debug

Same name in other branches
  1. 4.x src/DevelDumperManager.php \Drupal\devel\DevelDumperManager::debug()

Overrides DevelDumperManagerInterface::debug

File

src/DevelDumperManager.php, line 137

Class

DevelDumperManager
Manager class for DevelDumper.

Namespace

Drupal\devel

Code

public function debug($input, $name = NULL, $plugin_id = NULL) {
    $output = $this->createInstance($plugin_id)
        ->export($input, $name) . "\n";
    // The temp directory does vary across multiple simpletest instances.
    $file = $this->config
        ->get('debug_logfile');
    if (empty($file)) {
        $file = 'temporary://drupal_debug.txt';
    }
    if (file_put_contents($file, $output, FILE_APPEND) === FALSE && $this->hasAccessToDevelInformation()) {
        $this->messenger
            ->addError($this->t('Devel was unable to write to %file.', [
            '%file' => $file,
        ]));
        return FALSE;
    }
}