-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
91 additions
and
0 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
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,38 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nette Framework (https://nette.org) | ||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nette\Forms; | ||
|
||
use Nette; | ||
|
||
|
||
/** | ||
* Creates form. | ||
*/ | ||
final class FormFactory | ||
{ | ||
use Nette\StaticClass; | ||
|
||
/** @var Nette\Http\IRequest */ | ||
private $httpRequest; | ||
|
||
|
||
public function __construct(Nette\Http\IRequest $httpRequest) | ||
{ | ||
$this->httpRequest = $httpRequest; | ||
} | ||
|
||
|
||
public function createForm(string $name = null): Form | ||
{ | ||
$form = new Form($name); | ||
$form->setHttpRequest($this->httpRequest); | ||
return $form; | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\Forms\Form; | ||
use Nette\Forms\FormFactory; | ||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
$request = (new Nette\Http\RequestFactory)->fromGlobals(); | ||
$factory = new FormFactory($request); | ||
$form = $factory->createForm(); | ||
Assert::type(Form::class, $form); | ||
|
||
|
||
$form = $factory->createForm('foo'); | ||
Assert::same('foo', $form->getName()); |