Skip to content

Commit

Permalink
Fetch support (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevelacey authored and barryvdh committed Sep 24, 2019
1 parent 2a95c20 commit 6c4277f
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 64 deletions.
26 changes: 26 additions & 0 deletions src/DebugBar/JavascriptRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class JavascriptRenderer

protected $ajaxHandlerClass = 'PhpDebugBar.AjaxHandler';

protected $ajaxHandlerBindToFetch = false;

protected $ajaxHandlerBindToJquery = true;

protected $ajaxHandlerBindToXHR = false;
Expand Down Expand Up @@ -477,6 +479,27 @@ public function getAjaxHandlerClass()
return $this->ajaxHandlerClass;
}

/**
* Sets whether to call bindToFetch() on the ajax handler
*
* @param boolean $bind
*/
public function setBindAjaxHandlerToFetch($bind = true)
{
$this->ajaxHandlerBindToFetch = $bind;
return $this;
}

/**
* Checks whether bindToFetch() will be called on the ajax handler
*
* @return boolean
*/
public function isAjaxHandlerBoundToFetch()
{
return $this->ajaxHandlerBindToFetch;
}

/**
* Sets whether to call bindToJquery() on the ajax handler
*
Expand Down Expand Up @@ -1022,6 +1045,9 @@ protected function getJsInitializationCode()
$this->variableName,
$this->ajaxHandlerAutoShow ? 'true' : 'false'
);
if ($this->ajaxHandlerBindToFetch) {
$js .= sprintf("%s.ajaxHandler.bindToFetch();\n", $this->variableName);
}
if ($this->ajaxHandlerBindToXHR) {
$js .= sprintf("%s.ajaxHandler.bindToXHR();\n", $this->variableName);
} elseif ($this->ajaxHandlerBindToJquery) {
Expand Down
Loading

0 comments on commit 6c4277f

Please sign in to comment.