chomenko / presenter-factory-listener
PresenterFactory listener from Nette framework
Installs: 117
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:extension
Requires
- php: >=7.2
- kdyby/events: ^3.1
- nette/di: ^2.4 || ^3.0
This package is auto-updated.
Last update: 2024-10-15 19:15:48 UTC
README
Temporary solution.
This extension allows you to extend presenter factory
Required
Install
composer require chomenko/presenter-factory-listener
Configure
in config.neon
extensions: events: Kdyby\Events\DI\EventsExtension presenterFactoryListener: Chomenko\PresenterFactoryListener\DI\PresenterFactoryListenerExtension
Use
Events
- onGetPresenter
- onFormatPresenterClass
- onUnFormatPresenterClass
<?php namespace App\Listener; use Kdyby\Events\Subscriber; use Chomenko\PresenterFactoryListener\EventArgsGetPresenter; use Chomenko\PresenterFactoryListener\PresenterFactory as ExtendPresenter; class PresenterFactory implements Subscriber { /** * @return array */ public function getSubscribedEvents() { return [ ExtendPresenter::class . "::onGetPresenter" => "onGetPresenter", ]; } /** * @param EventArgsGetPresenter $eventArgs */ public function onGetPresenter(EventArgsGetPresenter $eventArgs) { $presenter = $eventArgs->getName(); $exp = explode(":", $presenter); if (isset($exp[0]) && $exp[0] == "Special") { //specialModule $eventArgs->setPresenter("special class name"); //special class } } }