The Drago Extension is a package built on top of the Nette Framework, designed to provide several useful components for your web applications. Below are the classes in the extension and how you can use them.
- PHP >= 8.3
- Nette Framework
- Composer
- Bootstrap
- Naja
composer require drago-ex/application
File copying is handled automatically by drago-ex/project-installer,
which must be installed in your project. Without it, copy the files manually according to the copy section
in this package's composer.json. To skip this package, set "skip": true under
extra.drago-project.packages.<package-name> in your root composer.json.
$this->getSignal();Shorter method in control.
$this->isAjax();$form = $this['factory'];
$submitButton = $this->getFormComponent($form, 'submit');
$submitButton->setCaption('Edit');Use Drago\Application\UI\Factory when you want a typed factory for another form class, for example ExtraForms from drago-ex/form.
use Drago\Form\ExtraForms;
/**
* @extends \Drago\Application\UI\Factory<ExtraForms>
*/
readonly class Factory extends \Drago\Application\UI\Factory
{
protected function createForm(): ExtraForms
{
return new ExtraForms;
}
}It is used in the bow of presenters or control
/**
* @property-read Drago\Application\UI\ExtraTemplate $template
*/
class Presenter {}In Latte, we will use these macros to insert into the template, which will tell us the variables and types that can be used by default in the template.
{templateType Drago\Application\UI\ExtraTemplate}
{varType Drago\Application\UI\Flashes[] $flashes}
<div n:foreach="$flashes as $flash" n:class="flash, $flash->type">{$flash->message}</div>Since the package is installed via Composer, add the following to your package.json:
{
"type": "module",
"dependencies": {
"drago-application": "file:vendor/drago-ex/application"
}
}Then run npm install.
import ToastHandler from 'drago-application/bootstrap-toast';{include 'path/to/@toast.latte', flashes => $flashes}