1. Go to this page and download the library: Download chomenko/modal 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/ */
chomenko / modal example snippets
namespace App;
use Chomenko\Modal\IWrappedModal;
abstract class BasePresenter extends Presenter
/**
* @var IWrappedModal @inject
*/
public $modalFactory;
public function createComponentModal()
{
/** @var WrappedModal $wrapped */
$wrapped = $this->modalFactory->create();
return $wrapped;
}
}
namespace App\Components;
use Chomenko\AutoInstall\AutoInstall;
use Chomenko\AutoInstall\Config;
use Chomenko\Modal\ModalHtml;
use Chomenko\Modal\WrappedHtml;
use Chomenko\Modal\ModalControl;
use Chomenko\Modal\ModalFactory;
use Chomenko\Modal\AccessAction;
use Nette\Http\Url;
/**
* @Config\Tag({"modal.factory"})
*/
class HelloWorldModal extends ModalControl implements AutoInstall
{
/**
* @var $id
*/
private $id;
/**
* @param int $id
*/
public function create($id)
{
$this->id = $id;
}
/**
* @param ModalFactory $factory
* @param Url $url
* @param array $parameters
* @throws \Exception
*/
public static function onCreateUrl(ModalFactory $factory, Url $url, array $parameters = [])
{
}
/**
* @param AccessAction $accessAction
* @return bool
*/
public function access(AccessAction $accessAction): bool
{
return $accessAction->getUser()->isLoggedIn();
}
/**
* @return string
*/
public function getTitle() :string
{
return "Hello World";
}
/**
* @param WrappedHtml $wrappedHtml
*/
public function renderBody(WrappedHtml $wrappedHtml, ModalHtml $body)
{
$this->template->id = $this->id;
$this->template->setFile(__DIR__ . "/body.latte");
$this->template->render();
}
}
namespace App\Components;
interface IHelloWorldModal
{
/**
* @return HelloWorldModal
*/
public function create();
}
namespace App\Components;
use Chomenko\AutoInstall\AutoInstall;
use Chomenko\AutoInstall\Tag;
use Chomenko\Modal\AccessAction;
use Chomenko\Modal\Events\Subscriber;
use Chomenko\Modal\ModalControl;
/**
* @Tag({"modal.events"})
*/
class ModalEvent extends Subscriber implements AutoInstall
{
public function getSubscribedEvents(): array
{
return [
Subscriber::ACCESS
];
}
public function access(ModalControl $modalControl, AccessAction $accessAction): bool
{
return TRUE;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.