diff --git a/src/Whoops/Handler/PrettyPageHandler.php b/src/Whoops/Handler/PrettyPageHandler.php index 7aa3a2a..1538585 100644 --- a/src/Whoops/Handler/PrettyPageHandler.php +++ b/src/Whoops/Handler/PrettyPageHandler.php @@ -50,6 +50,13 @@ class PrettyPageHandler extends Handler */ private $customCss = null; + /** + * The name of the custom js file. + * + * @var string + */ + private $customJs = null; + /** * @var array[] */ @@ -193,6 +200,10 @@ class PrettyPageHandler extends Handler $customCssFile = $this->getResource($this->customCss); } + if ($this->customJs) { + $customJsFile = $this->getResource($this->customJs); + } + $inspector = $this->getInspector(); $frames = $this->getExceptionFrames(); $code = $this->getExceptionCode(); @@ -252,6 +263,10 @@ class PrettyPageHandler extends Handler $vars["stylesheet"] .= file_get_contents($customCssFile); } + if (isset($customJsFile)) { + $vars["javascript"] .= file_get_contents($customJsFile); + } + // Add extra entries list of data tables: // @todo: Consolidate addDataTable and addDataTableCallback $extraTables = array_map(function ($table) use ($inspector) { @@ -593,6 +608,17 @@ class PrettyPageHandler extends Handler $this->customCss = $name; } + /** + * Adds a custom js file to be loaded. + * + * @param string $name + * @return void + */ + public function addCustomJs($name) + { + $this->customJs = $name; + } + /** * @return array */