Skip to content

Commit

Permalink
allow adding the output buffer to a short circuited response
Browse files Browse the repository at this point in the history
  • Loading branch information
maglnet committed Apr 29, 2016
1 parent 2219273 commit 9ca1733
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/magl-legacyapp.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
'get' => true, // should $_GET be filled with variables from route match?
'request' => true, // should $_GET be filled with variables from route match?
),
// when short circuiting a response, it could be needed to prepend the output buffer to the response,
// enable this to prepend the output buffer
'prepend_output_buffer_to_response' => false,
),
);
3 changes: 3 additions & 0 deletions src/MaglLegacyApplication/Controller/LegacyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ private function runScript($scriptFileName)

$result = $this->getEventManager()->trigger(MaglLegacy::EVENT_SHORT_CIRCUIT_RESPONSE, $this);
if ($result->stopped()) {
if($this->options->getPrependOutputBufferToResponse()) {
$result->last()->setContent($output . $result->last()->getContent());
}
return $result->last();
}

Expand Down
20 changes: 20 additions & 0 deletions src/MaglLegacyApplication/Options/LegacyControllerOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class LegacyControllerOptions extends \Zend\Stdlib\AbstractOptions
'request' => true,
);

private $prependOutputBufferToResponse = false;

public function getDocRoot()
{
return reset($this->docRoot);
Expand Down Expand Up @@ -62,4 +64,22 @@ public function setIndexFiles($indexFiles)
{
$this->indexFiles = $indexFiles;
}

/**
* @return boolean
*/
public function getPrependOutputBufferToResponse()
{
return $this->prependOutputBufferToResponse;
}

/**
* @param boolean $prependOutputBufferToResponse
*/
public function setPrependOutputBufferToResponse($prependOutputBufferToResponse)
{
$this->prependOutputBufferToResponse = $prependOutputBufferToResponse;
}


}

0 comments on commit 9ca1733

Please sign in to comment.