-
-
Notifications
You must be signed in to change notification settings - Fork 115
Router: Have a routes collection interface & support in Tracy router panel #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Nette Framework (http://nette.org) | ||
| * Copyright (c) 2004 David Grudl (http://davidgrudl.com) | ||
| */ | ||
|
|
||
| namespace Nette\Application; | ||
|
|
||
| use Nette; | ||
|
|
||
|
|
||
| /** | ||
| * Routes collection. | ||
| */ | ||
| interface IRouteList extends \IteratorAggregate | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not extend Traversable?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not extend
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User-land code can't extend Traversable directly.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interface can extend, but class can't implement.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is funny: this works: interface A extends Traversable {} class B implements IteratorAggregate, A { function getIterator() {} } this triggers Fatal error: Class B must implement interface Traversable as part of either Iterator or IteratorAggregate: interface A extends Traversable {} class B implements A, IteratorAggregate { function getIterator() {} }
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have encountered this (the need to have interfaces in the correct order) when developing the PR and it is exactly the reason I won't implement it using Traversable.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is documented http://php.net/class.traversable |
||
| { | ||
| /** | ||
| * @return string | ||
| */ | ||
| function getModule(); | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Nette Framework (http://nette.org) | ||
| * Copyright (c) 2004 David Grudl (http://davidgrudl.com) | ||
| */ | ||
|
|
||
| namespace Nette\Application\Responses; | ||
|
|
||
| use Nette; | ||
|
|
||
|
|
||
| /** | ||
| * Callback response. | ||
| */ | ||
| class CallbackResponse extends Nette\Object implements Nette\Application\IResponse | ||
| { | ||
| /** @var callable */ | ||
| private $callback; | ||
|
|
||
|
|
||
| public function __construct(callable $callback) | ||
| { | ||
| $this->callback = $callback; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Sends response to output. | ||
| * @return void | ||
| */ | ||
| public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse) | ||
| { | ||
| call_user_func($this->callback, $httpRequest, $httpResponse); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Test: Nette\Application\Responses\CallbackResponse. | ||
| */ | ||
|
|
||
| use Nette\Application\Responses\CallbackResponse; | ||
| use Nette\Http; | ||
| use Tester\Assert; | ||
|
|
||
|
|
||
| require __DIR__ . '/../bootstrap.php'; | ||
|
|
||
|
|
||
| test(function () { | ||
| $response = new CallbackResponse(function (Http\IRequest $request, Http\IResponse $response) use (& $ok) { | ||
| $ok = TRUE; | ||
| }); | ||
| $response->send(new Http\Request(new Http\UrlScript), new Http\Response); | ||
| Assert::true($ok); | ||
| }); |