private function ExportCommand::exportSingle in Devel 8
Same name and namespace in other branches
- 8.3 webprofiler/src/Command/ExportCommand.php \Drupal\webprofiler\Command\ExportCommand::exportSingle()
- 8.2 webprofiler/src/Command/ExportCommand.php \Drupal\webprofiler\Command\ExportCommand::exportSingle()
- 4.x webprofiler/src/Command/ExportCommand.php \Drupal\webprofiler\Command\ExportCommand::exportSingle()
Exports a single profile.
Parameters
\Drupal\webprofiler\Profiler\Profiler $profiler:
int $id:
string $directory:
Return value
string
Throws
\Exception
1 call to ExportCommand::exportSingle()
- ExportCommand::execute in webprofiler/
src/ Command/ ExportCommand.php - Executes the current command.
File
- webprofiler/
src/ Command/ ExportCommand.php, line 76
Class
- ExportCommand
- Class ExportCommand
Namespace
Drupal\webprofiler\CommandCode
private function exportSingle(Profiler $profiler, $id, $directory) {
$profile = $profiler
->loadProfile($id);
if ($profile) {
$data = $profiler
->export($profile);
$filename = $directory . DIRECTORY_SEPARATOR . $id . '.txt';
if (file_put_contents($filename, $data) === FALSE) {
throw new \Exception(sprintf($this
->trans('commands.webprofiler.export.messages.error_writing'), $filename));
}
}
else {
throw new \Exception(sprintf($this
->trans('commands.webprofiler.export.messages.error_no_profile'), $id));
}
return $filename;
}