Presenter ako extension – nefunguju flash messages

- Čamo
 - Člen | 798
 
Zdravím,
narazil som na extension pre Nette, ktoré funguje na báze presenterov. Všetko
je ok až na to, že ak nejaký handler zavolá
$this->flashMessage() tak sa nič nezobrazí. Pri action a render sa flashky
zobrazia normálne, iba pri hanlderoch nie. Neviem niekto čím
to môže byť?
Editoval Čamo (9. 4. 2018 16:47)

- David Matějka
 - Moderator | 6445
 
ahoj,
- nechapu, co znamena „extension pre Nette, ktoré funguje na báze presenterov“
 - ukaz, jak vypada ten handle
 

- David Matějka
 - Moderator | 6445
 
je jedno, kde je presenter umisteny. flashky by mely fungovat i tak. i tak ukaz nektery z handleru

- Pavel Kravčík
 - Člen | 1206
 
Určitě to funguje. Stačí upravit mapping a hledání presenterů do nějaké „extension/vendor“ složky. Asi budeš mít špatně udělané předky nebo nalinkované assety.

- Čamo
 - Člen | 798
 
Príklad handlera kde nefungujú flashky:
	public function handleContinueMigration()
	{
		$rightsCount = $this->rightMigrationService->getRightsCount();
		$actionsCount = $this->rightMigrationService->getActionsCount();
		if($this->rightMigrationService->continueMigrations()){
			$this->flashSuccess("Zvládli jsme to :-)");
			$newRightsCount = $this->rightMigrationService->getRightsCount();
			$newActionsCount = $this->rightMigrationService->getActionsCount();
			$rightsDiff = $newRightsCount - $rightsCount;
			$actionsDiff = $newActionsCount - $actionsCount;
			$addedRightsCount = $this->rightMigrationService->getAddedRightsCount();
			$addedActionsCount = $this->rightMigrationService->getAddedActionsCount();
			$deletedRightsCount = $addedRightsCount - $rightsDiff;
			$deletedActionsCount = $addedActionsCount - $actionsDiff;
			if($addedRightsCount){
				$this->flashSuccess("Right: přidáno $addedRightsCount entit.");
			}
			if($deletedRightsCount){
				$this->flashError("Right: odebráno $deletedRightsCount entit.");
			}
			if($renamedRightsCount = $this->rightMigrationService->getRenamedRightsCount()){
				$this->flashInfo("Right: přejmenováno $renamedRightsCount entit.");
			}
			if($addedActionsCount){
				$this->flashSuccess("Action: přidáno $addedActionsCount entit.");
			}
			if($deletedActionsCount){
				$this->flashError("Action: odebráno $deletedActionsCount entit.");
			}
			if($renamedActionsCount = $this->rightMigrationService->getRenamedActionsCount()){
				$this->flashInfo("Action: přejmenováno $renamedActionsCount entit.");
			}
			if(!$addedRightsCount && !$deletedRightsCount && !$addedActionsCount && !$deletedRightsCount && !$renamedRightsCount && !$renamedActionsCount){
				$this->flashInfo("Nebyly přidány, odebrány ani přejmenovány žádné entity.");
			}
		}else{
			$this->flashError("Nezvládli jsme to :-(");
		}
		$this->redirect('this');
	}
					Editoval Čamo (11. 4. 2018 11:13)

- David Matějka
 - Moderator | 6445
 
- co delaji ty tve metody flashError atd? pouze zavolaji flashMessage s prislusnym parametrem?
 - kdyz ve stejnem presenteru zavolas v action nejakou tu flash metodu, tak to funguje?
 

- Čamo
 - Člen | 798
 
@DavidMatějka Ano tak ako píšeš. Metóda flashError() zavolá
flashMessage() a keď zavolám v action metóde tak to funguje.
Zaujímavé ešte je, že keď sa volá flashMessage() v handle a zároveň aj
v action metode tak sa zobrazia obidve flashky správne. Iba keď sa volá
flashMessage v handle samostatne tak sa nezobrazí nič.
Editoval Čamo (11. 4. 2018 12:13)

- David Matějka
 - Moderator | 6445
 
netusim, melo by to fungovat, asi budes muset debugovat (treba obsah session atd)

- Pavel Kravčík
 - Člen | 1206
 
@Čamo: Myslel jsem, jestli to máš správně provázané, jestli
$this není v komponentě a má správný layout, kde je flash.
Plus taky jestli nemáš relativní linkování třeba rozdíl mezi
__DIR__ z app a z vendor. Mrkni do konzole, jestli tam třeba
neskáče chyba, že se něco nenalinkuje.