projects
/
mdref
/
mdref
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
stub2ref
[mdref/mdref]
/
mdref
/
Action.php
diff --git
a/mdref/Action.php
b/mdref/Action.php
index 7e1307bffff70e85412e45a221a1589777cffa35..3addfa0527fe4880259d57e3f4ab964ff9c04ae2 100644
(file)
--- a/
mdref/Action.php
+++ b/
mdref/Action.php
@@
-31,6
+31,11
@@
class Action {
*/
private $response;
*/
private $response;
+ /**
+ * @var resource
+ */
+ private $output;
+
/**
* @var \http\Url
*/
/**
* @var \http\Url
*/
@@
-39,11
+44,12
@@
class Action {
/**
* Initialize the reference
*/
/**
* Initialize the reference
*/
- public function __construct(Reference $ref, Request $req, Response $res, BaseUrl $baseUrl) {
+ public function __construct(Reference $ref, Request $req, Response $res, BaseUrl $baseUrl
, $output = null
) {
$this->reference = $ref;
$this->request = $req;
$this->response = $res;
$this->baseUrl = $baseUrl;
$this->reference = $ref;
$this->request = $req;
$this->response = $res;
$this->baseUrl = $baseUrl;
+ $this->output = $output;
ob_start($res);
}
ob_start($res);
}
@@
-84,7
+90,11
@@
class Action {
private function serveCanonical(string $cnn) : void {
$this->response->setHeader("Location", $this->baseUrl->mod(["path" => $cnn]));
$this->response->setResponseCode(301);
private function serveCanonical(string $cnn) : void {
$this->response->setHeader("Location", $this->baseUrl->mod(["path" => $cnn]));
$this->response->setResponseCode(301);
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
}
/**
@@
-93,7
+103,11
@@
class Action {
private function serveStylesheet() : void {
$this->response->setHeader("Content-Type", "text/css");
$this->response->setBody(new Body(\fopen(ROOT."/public/index.css", "r")));
private function serveStylesheet() : void {
$this->response->setHeader("Content-Type", "text/css");
$this->response->setBody(new Body(\fopen(ROOT."/public/index.css", "r")));
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
}
/**
@@
-102,7
+116,11
@@
class Action {
private function serveJavascript() : void {
$this->response->setHeader("Content-Type", "application/javascript");
$this->response->setBody(new Body(\fopen(ROOT."/public/index.js", "r")));
private function serveJavascript() : void {
$this->response->setHeader("Content-Type", "application/javascript");
$this->response->setBody(new Body(\fopen(ROOT."/public/index.js", "r")));
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
}
/**
@@
-119,7
+137,11
@@
class Action {
$this->response->setHeader("Content-Type", "application/x-php");
$this->response->setContentDisposition(["attachment" => ["filename" => "$name.stub.php"]]);
$this->response->setBody(new Body(\fopen($stub, "r")));
$this->response->setHeader("Content-Type", "application/x-php");
$this->response->setContentDisposition(["attachment" => ["filename" => "$name.stub.php"]]);
$this->response->setBody(new Body(\fopen($stub, "r")));
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
}
/**
@@
-158,7
+180,14
@@
class Action {
include ROOT."/views/layout.phtml";
$this->response->addHeader("Link", "<" . $this->baseUrl->path . "index.css>; rel=preload; as=style");
$this->response->addHeader("Link", "<" . $this->baseUrl->path . "index.js>; rel=preload; as=script");
include ROOT."/views/layout.phtml";
$this->response->addHeader("Link", "<" . $this->baseUrl->path . "index.css>; rel=preload; as=style");
$this->response->addHeader("Link", "<" . $this->baseUrl->path . "index.js>; rel=preload; as=script");
- $this->response->send();
+ if (isset($exception) && $exception->getCode()) {
+ $this->response->setResponseCode($exception->getCode());
+ }
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
}
/**
@@
-168,10
+197,10
@@
class Action {
try {
$pld = $this->createPayload();
try {
$pld = $this->createPayload();
- if (strlen($pld->ref)) {
+ if (
isset($pld->ref) &&
strlen($pld->ref)) {
$cnn = null;
if (($repo = $this->reference->getRepoForEntry($pld->ref, $cnn))) {
$cnn = null;
if (($repo = $this->reference->getRepoForEntry($pld->ref, $cnn))) {
- if (strlen($cnn)) {
+ if (
isset($cnn) &&
strlen($cnn)) {
/* redirect */
$this->serveCanonical($cnn);
return;
/* redirect */
$this->serveCanonical($cnn);
return;