-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extension: better URL handling [closes #43]
- Loading branch information
Showing
4 changed files
with
104 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Contributte\Console\Http; | ||
|
||
use Nette\Http\Request; | ||
use Nette\Http\RequestFactory; | ||
use Nette\Http\UrlScript; | ||
|
||
class ConsoleRequestFactory extends RequestFactory | ||
{ | ||
|
||
private string $url; | ||
|
||
public function __construct(string $url) | ||
{ | ||
$this->url = $url; | ||
} | ||
|
||
public function fromGlobals(): Request | ||
{ | ||
return new Request(new UrlScript($this->url)); | ||
} | ||
|
||
public function createHttpRequest(): Request | ||
{ | ||
return $this->fromGlobals(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Fixtures; | ||
|
||
use Nette\Http\Request; | ||
use Nette\Http\RequestFactory; | ||
use Nette\Http\UrlScript; | ||
|
||
class FooRequestFactory extends RequestFactory | ||
{ | ||
|
||
public const CUSTOM_URL = 'http://custom/'; | ||
|
||
public function fromGlobals(): Request | ||
{ | ||
return new Request(new UrlScript(self::CUSTOM_URL)); | ||
} | ||
|
||
public function createHttpRequest(): Request | ||
{ | ||
return $this->fromGlobals(); | ||
} | ||
|
||
} |