vojtech-dobes / nette-signals-trait
Learn any of your Nette components to understand signals!
Installs: 2 466
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.4
- nette/nette: ~2.0
This package is not auto-updated.
Last update: 2024-11-09 15:56:31 UTC
README
Learn any of your components to understand signals!
License
New BSD
Dependencies
- PHP 5.4
- Nette 2.0.0
Installation
Get the source code from Github or via Composer (vojtech-dobes/nette-signals-trait
).
Usage
1.. Make your component (implementation of Nette\ComponentModel\IComponent
) implement Nette\Application\UI\ISignalReceiver
interface.
class AutocompleteField extends Nette\Forms\Controls\TextInput implements Nette\Application\UI\ISignalReceiver
2.. Use Nextras\Signals\Receiver
trait in your component .
use Nextras\Signals\Receiver;
3.. Register signals:
public function __construct() { $this->__signals()->addSignal('autocomplete', function (Nette\Application\UI\Presenter $presenter, $phrase) { $presenter->sendJson( ... ); }); }
Now the component supports signal autocomplete
, in same way as handleAutocomplete()
method would work in your component inheriting Nette\Application\UI\Control
.
You will probably also need to create link to it:
$this->__signals()->createLink('autocomplete', 'testPhrase');