Skip to content

Commit 6c4277f

Browse files
stevelaceybarryvdh
authored andcommitted
Fetch support (php-debugbar#422)
1 parent 2a95c20 commit 6c4277f

File tree

2 files changed

+134
-64
lines changed

2 files changed

+134
-64
lines changed

src/DebugBar/JavascriptRenderer.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class JavascriptRenderer
7070

7171
protected $ajaxHandlerClass = 'PhpDebugBar.AjaxHandler';
7272

73+
protected $ajaxHandlerBindToFetch = false;
74+
7375
protected $ajaxHandlerBindToJquery = true;
7476

7577
protected $ajaxHandlerBindToXHR = false;
@@ -477,6 +479,27 @@ public function getAjaxHandlerClass()
477479
return $this->ajaxHandlerClass;
478480
}
479481

482+
/**
483+
* Sets whether to call bindToFetch() on the ajax handler
484+
*
485+
* @param boolean $bind
486+
*/
487+
public function setBindAjaxHandlerToFetch($bind = true)
488+
{
489+
$this->ajaxHandlerBindToFetch = $bind;
490+
return $this;
491+
}
492+
493+
/**
494+
* Checks whether bindToFetch() will be called on the ajax handler
495+
*
496+
* @return boolean
497+
*/
498+
public function isAjaxHandlerBoundToFetch()
499+
{
500+
return $this->ajaxHandlerBindToFetch;
501+
}
502+
480503
/**
481504
* Sets whether to call bindToJquery() on the ajax handler
482505
*
@@ -1022,6 +1045,9 @@ protected function getJsInitializationCode()
10221045
$this->variableName,
10231046
$this->ajaxHandlerAutoShow ? 'true' : 'false'
10241047
);
1048+
if ($this->ajaxHandlerBindToFetch) {
1049+
$js .= sprintf("%s.ajaxHandler.bindToFetch();\n", $this->variableName);
1050+
}
10251051
if ($this->ajaxHandlerBindToXHR) {
10261052
$js .= sprintf("%s.ajaxHandler.bindToXHR();\n", $this->variableName);
10271053
} elseif ($this->ajaxHandlerBindToJquery) {

0 commit comments

Comments
 (0)