1. Go to this page and download the library: Download dakujem/nette-wires library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dakujem / nette-wires example snippets
namespace App\Presenters;
use Dakujem\WireGenieTrait;
use Nette;
abstract class BasePresenter extends Nette\Application\UI\Presenter
{
use WireGenieTrait;
}
protected function createComponentFoobarForm()
{
return $this->wire(InputFactory::class, 'model.repository.text')
->invoke(function (...$deps) {
return (new FoobarFormFactory)->create(
$this->localDependency,
$this->getParameter('id'),
...$deps
);
});
}
namespace App\Presenters;
use Dakujem\WireGenieTrait;
use Nette;
abstract class BasePresenter extends Nette\Application\UI\Presenter
{
use WireGenieTrait;
}
protected function createComponentFoobarForm()
{
$factory = function (InputFactory $inputs, TextRepository $textRepo) {
$form = new Form();
$form->addComponent(
$inputs->create('stuff', $textRepo->getAllUnread()),
'unread_stuff'
);
// ...
return $form;
};
// with explicit dependencies
return $this->wire(InputFactory::class, 'model.repository.text')->invoke($factory);
// with automatic dependency resolution (autowiring)
return $this->wire()->invoke($factory);
}
protected function createComponentFoobarForm()
{
return $this->wire(InputFactory::class, 'model.repository.text')
->invoke(function (...$deps) {
return (new FoobarFormFactory)->create(
$this->localDependency,
$this->getParameter('id'),
...$deps
);
});
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.