PHP code example of rixxi / redirector

1. Go to this page and download the library: Download rixxi/redirector 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/ */

    

rixxi / redirector example snippets




use Rixxi\Application\UI\Presenter\EnableRedirector;


class BasePresenter extends Nette\Application\UI\Presenter
{
	use EnableRedirector;
}



class ExamplePresenter extends BasePresenter
{

	/** @var \Service @ inject */
	public $service;


	public function actionDefault()
	{
		$this->service->onError[] = function () { // redirect back on error
			$this->redirector->redirect('this'); // if you used $presenter->redirect here next events would not execute
		};
		
		$this->service->onError[] = function () { // say something to admin
			$this->reporter->say('I might be sick!');
		};
	}

}