Skip to content

Commit

Permalink
changed class & namespace names in framework. BC break, more info: ht…
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Apr 13, 2011
1 parent 539fdec commit 1667379
Show file tree
Hide file tree
Showing 168 changed files with 1,540 additions and 1,523 deletions.
48 changes: 24 additions & 24 deletions Nette/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class Application extends Nette\Object
/** @var array of function(Application $sender, \Exception $e = NULL); Occurs before the application shuts down */
public $onShutdown;

/** @var array of function(Application $sender, PresenterRequest $request); Occurs when a new request is ready for dispatch */
/** @var array of function(Application $sender, Request $request); Occurs when a new request is ready for dispatch */
public $onRequest;

/** @var array of function(Application $sender, IPresenterResponse $response); Occurs when a new response is received */
/** @var array of function(Application $sender, IResponse $response); Occurs when a new response is received */
public $onResponse;

/** @var array of function(Application $sender, \Exception $e); Occurs when an unhandled exception occurs in the application */
Expand All @@ -49,13 +49,13 @@ class Application extends Nette\Object
/** @var array of string */
public $allowedMethods = array('GET', 'POST', 'HEAD', 'PUT', 'DELETE');

/** @var array of PresenterRequest */
/** @var array of Request */
private $requests = array();

/** @var Presenter */
/** @var IPresenter */
private $presenter;

/** @var Nette\IContext */
/** @var Nette\DI\IContext */
private $context;


Expand All @@ -73,7 +73,7 @@ public function run()
if ($this->allowedMethods) {
$method = $httpRequest->getMethod();
if (!in_array($method, $this->allowedMethods, TRUE)) {
$httpResponse->setCode(Nette\Web\IHttpResponse::S501_NOT_IMPLEMENTED);
$httpResponse->setCode(Nette\Http\IResponse::S501_NOT_IMPLEMENTED);
$httpResponse->setHeader('Allow', implode(',', $this->allowedMethods));
echo '<h1>Method ' . htmlSpecialChars($method) . ' is not implemented</h1>';
return;
Expand Down Expand Up @@ -102,10 +102,10 @@ public function run()
$router = $this->getRouter();

// enable routing debuggger
Nette\Debug::addPanel(new RoutingDebugger($router, $httpRequest));
Nette\Diagnostics\Debugger::addPanel(new Diagnostics\RoutingPanel($router, $httpRequest));

$request = $router->match($httpRequest);
if (!$request instanceof PresenterRequest) {
if (!$request instanceof Request) {
$request = NULL;
throw new BadRequestException('No route for HTTP request.');
}
Expand Down Expand Up @@ -135,11 +135,11 @@ public function run()
$this->onResponse($this, $response);

// Send response
if ($response instanceof ForwardingResponse) {
if ($response instanceof Responses\ForwardResponse) {
$request = $response->getRequest();
continue;

} elseif ($response instanceof IPresenterResponse) {
} elseif ($response instanceof IResponse) {
$response->send($httpRequest, $httpResponse);
}
break;
Expand All @@ -163,16 +163,16 @@ public function run()

if (!$repeatedError && $this->errorPresenter) {
$repeatedError = TRUE;
if ($this->presenter instanceof Presenter) {
if ($this->presenter instanceof UI\Presenter) {
try {
$this->presenter->forward(":$this->errorPresenter:", array('exception' => $e));
} catch (AbortException $foo) {
$request = $this->presenter->getLastCreatedRequest();
}
} else {
$request = new PresenterRequest(
$request = new Request(
$this->errorPresenter,
PresenterRequest::FORWARD,
Request::FORWARD,
array('exception' => $e)
);
}
Expand All @@ -183,7 +183,7 @@ public function run()
$code = $e->getCode();
} else {
$code = 500;
Nette\Debug::log($e, Nette\Debug::ERROR);
Nette\Diagnostics\Debugger::log($e, Nette\Diagnostics\Debugger::ERROR);
}
require __DIR__ . '/templates/error.phtml';
break;
Expand All @@ -198,7 +198,7 @@ public function run()

/**
* Returns all processed requests.
* @return array of PresenterRequest
* @return array of Request
*/
final public function getRequests()
{
Expand All @@ -209,7 +209,7 @@ final public function getRequests()

/**
* Returns current presenter.
* @return Presenter
* @return IPresenter
*/
final public function getPresenter()
{
Expand All @@ -226,7 +226,7 @@ final public function getPresenter()
* Sets the context.
* @return Application provides a fluent interface
*/
public function setContext(Nette\IContext $context)
public function setContext(Nette\DI\IContext $context)
{
$this->context = $context;
return $this;
Expand All @@ -236,7 +236,7 @@ public function setContext(Nette\IContext $context)

/**
* Gets the context.
* @return Nette\IContext
* @return Nette\DI\IContext
*/
final public function getContext()
{
Expand Down Expand Up @@ -294,7 +294,7 @@ public function getPresenterFactory()


/**
* @return Nette\Web\IHttpRequest
* @return Nette\Http\IRequest
*/
protected function getHttpRequest()
{
Expand All @@ -304,7 +304,7 @@ protected function getHttpRequest()


/**
* @return Nette\Web\IHttpResponse
* @return Nette\Http\IResponse
*/
protected function getHttpResponse()
{
Expand All @@ -314,7 +314,7 @@ protected function getHttpResponse()


/**
* @return Nette\Web\Session
* @return Nette\Http\Session
*/
protected function getSession($namespace = NULL)
{
Expand All @@ -337,7 +337,7 @@ public function storeRequest($expiration = '+ 10 minutes')
{
$session = $this->getSession('Nette.Application/requests');
do {
$key = Nette\String::random(5);
$key = Nette\StringUtils::random(5);
} while (isset($session[$key]));

$session[$key] = end($this->requests);
Expand All @@ -358,8 +358,8 @@ public function restoreRequest($key)
if (isset($session[$key])) {
$request = clone $session[$key];
unset($session[$key]);
$request->setFlag(PresenterRequest::RESTORED, TRUE);
$this->presenter->sendResponse(new ForwardingResponse($request));
$request->setFlag(Request::RESTORED, TRUE);
$this->presenter->sendResponse(new Responses\ForwardResponse($request));
}
}

Expand Down
23 changes: 12 additions & 11 deletions Nette/Application/Diagnostics/RoutingPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
* the file license.txt that was distributed with this source code.
*/

namespace Nette\Application;
namespace Nette\Application\Diagnostics;

use Nette;
use Nette,
Nette\Application\Routers;



Expand All @@ -20,23 +21,23 @@
*
* @author David Grudl
*/
class RoutingDebugger extends Nette\DebugPanel
class RoutingPanel extends Nette\Diagnostics\Panel
{
/** @var IRouter */
/** @var Nette\Application\IRouter */
private $router;

/** @var Nette\Web\IHttpRequest */
/** @var Nette\Http\IRequest */
private $httpRequest;

/** @var array */
private $routers = array();

/** @var PresenterRequest */
/** @var Nette\Application\Request */
private $request;



public function __construct(IRouter $router, Nette\Web\IHttpRequest $httpRequest)
public function __construct(Nette\Application\IRouter $router, Nette\Http\IRequest $httpRequest)
{
$this->router = $router;
$this->httpRequest = $httpRequest;
Expand Down Expand Up @@ -70,12 +71,12 @@ public function renderPanel()

/**
* Analyses simple route.
* @param IRouter
* @param Nette\Application\IRouter
* @return void
*/
private function analyse($router)
{
if ($router instanceof MultiRouter) {
if ($router instanceof Routers\RouteList) {
foreach ($router as $subRouter) {
$this->analyse($subRouter);
}
Expand All @@ -92,8 +93,8 @@ private function analyse($router)
$this->routers[] = array(
'matched' => $matched,
'class' => get_class($router),
'defaults' => $router instanceof Route || $router instanceof SimpleRouter ? $router->getDefaults() : array(),
'mask' => $router instanceof Route ? $router->getMask() : NULL,
'defaults' => $router instanceof Routers\Route || $router instanceof Routers\SimpleRouter ? $router->getDefaults() : array(),
'mask' => $router instanceof Routers\Route ? $router->getMask() : NULL,
'request' => $request,
);
}
Expand Down
12 changes: 7 additions & 5 deletions Nette/Application/Diagnostics/templates/RoutingPanel.panel.phtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace Nette\Application;
namespace Nette\Application\Diagnostics;

use Nette;
use Nette,
Nette\Application\UI\Presenter,
Nette\Diagnostics\Debugger;

?>
<style>
Expand Down Expand Up @@ -51,7 +53,7 @@ use Nette;
<?php foreach ($params as $key => $value): ?>
<tr>
<td><code><?php echo htmlSpecialChars($key) ?></code></td>
<td><?php if (is_string($value)):?><code><?php echo htmlSpecialChars($value) ?></code><?php else: echo Nette\Debug::dump($value, TRUE); endif ?></td>
<td><?php if (is_string($value)):?><code><?php echo htmlSpecialChars($value) ?></code><?php else: echo Debugger::dump($value, TRUE); endif ?></td>
</tr>
<?php endforeach ?>
</tbody>
Expand Down Expand Up @@ -88,7 +90,7 @@ use Nette;

<td><code>
<?php foreach ($router['defaults'] as $key => $value): ?>
<?php echo htmlSpecialChars($key), "&nbsp;=&nbsp;", is_string($value) ? htmlSpecialChars($value) : str_replace("\n</pre", '</pre', Nette\Debug::dump($value, TRUE)) ?><br />
<?php echo htmlSpecialChars($key), "&nbsp;=&nbsp;", is_string($value) ? htmlSpecialChars($value) : str_replace("\n</pre", '</pre', Debugger::dump($value, TRUE)) ?><br />
<?php endforeach ?>
</code></td>

Expand All @@ -97,7 +99,7 @@ use Nette;
<strong><?php echo htmlSpecialChars($router['request']->getPresenterName() . ':' . (isset($params[Presenter::ACTION_KEY]) ? $params[Presenter::ACTION_KEY] : Presenter::DEFAULT_ACTION)) ?></strong><br />
<?php unset($params[Presenter::ACTION_KEY]) ?>
<?php foreach ($params as $key => $value): ?>
<?php echo htmlSpecialChars($key), "&nbsp;=&nbsp;", is_string($value) ? htmlSpecialChars($value) : str_replace("\n</pre", '</pre', Nette\Debug::dump($value, TRUE)) ?><br />
<?php echo htmlSpecialChars($key), "&nbsp;=&nbsp;", is_string($value) ? htmlSpecialChars($value) : str_replace("\n</pre", '</pre', Debugger::dump($value, TRUE)) ?><br />
<?php endforeach ?>
</code><?php endif ?></td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Nette\Application;
namespace Nette\Application\Diagnostics;

use Nette;
use Nette,
Nette\Application\UI\Presenter;

?>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJHSURBVDjLlZPNi81hFMc/z7137p1mTCFvNZfGSzLIWNjZKRvFRoqNhRCSYm8xS3+AxRRZ2JAFJWJHSQqTQkbEzYwIM+6Yid/znJfH4prLXShOnb6r8/nWOd8Tcs78bz0/f+KMu50y05nK/wy+uHDylbutqS5extvGcxaWqtoGDA8PZ3dnrs2srQc2Zko41UXLmLdyDW5OfvsUkUgbYGbU63UAQggdmvMzFmzZCgTi7CQmkZwdEaX0JwDgTnGbTCaE0G4zw80omhPI92lcEtkNkdgJCCHwJX7mZvNaB0A14SaYJlwTrpHsTkoFlV1nt2c3x5YYo1/vM9A/gKpxdfwyu/v3teCayKq4JEwT5EB2R6WgYmrs2bYbcUNNUVfEhIfFYy69uci+1fuRX84mkawFSxd/4nVWUopUVIykwlQxRTJBTIDA4Pp1jBZPuNW4wUAPmCqWIn29X1k4f5Ku8g9mpKCkakRLVEs1auVuauVuyqHMo8ejNCe+sWPVTkQKXCMmkeZUmUZjETF1tc6ooly+fgUVw9So1/tRN6YnZji46QghBFKKuAouERNhMlbAHZFE6e7pB+He8MMw+GGI4xtOMf1+lsl3TQ4NHf19BSlaO1DB9BfMHdX0O0iqSgiBbJkjm491hClJbA1LxCURgpPzXwAHhg63necAIi3XngXLcRU0fof8ETMljIyM5LGxMcbHxzvy/6fuXdWgt6+PWncv1e4euqo1ZmabvHs5+jn8yzufO7hiiZmuNpNBM13rbvVSpbrXJE7/BMkHtU9jFIC/AAAAAElFTkSuQmCC"
Expand Down
8 changes: 4 additions & 4 deletions Nette/Application/IPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@


/**
* Presenter converts PresenterRequest to IPresenterResponse.
* Presenter converts Request to IResponse.
*
* @author David Grudl
*/
interface IPresenter
{

/**
* @param PresenterRequest
* @return IPresenterResponse
* @param Request
* @return IResponse
*/
function run(PresenterRequest $request);
function run(Request $request);

}
4 changes: 2 additions & 2 deletions Nette/Application/IResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
*
* @author David Grudl
*/
interface IPresenterResponse
interface IResponse
{

/**
* Sends response to output.
* @return void
*/
function send(Nette\Web\IHttpRequest $httpRequest, Nette\Web\IHttpResponse $httpResponse);
function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse);

}
16 changes: 8 additions & 8 deletions Nette/Application/IRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ interface IRouter
const SECURED = 2;

/**
* Maps HTTP request to a PresenterRequest object.
* @param Nette\Web\IHttpRequest
* @return PresenterRequest|NULL
* Maps HTTP request to a Request object.
* @param Nette\Http\IRequest
* @return Request|NULL
*/
function match(Nette\Web\IHttpRequest $httpRequest);
function match(Nette\Http\IRequest $httpRequest);

/**
* Constructs absolute URL from PresenterRequest object.
* @param PresenterRequest
* @param Nette\Web\Uri referential URI
* Constructs absolute URL from Request object.
* @param Request
* @param Nette\Http\Url referential URI
* @return string|NULL
*/
function constructUrl(PresenterRequest $appRequest, Nette\Web\Uri $refUri);
function constructUrl(Request $appRequest, Nette\Http\Url $refUri);

}

0 comments on commit 1667379

Please sign in to comment.