Zend Framework 2 - metoda toRoute() undefined

0

Witajcie,
Mam pytanie odnośnie metody toRoute(), a mianowicie próbuje ją wykorzystać w jednym z formularzy logowania i niestety pojawia się błąd:

Call to udefinied function Users\\Controller\\toRoute()

Sprawdziłem w dokumentacji:
https://framework.zend.com/manual/2.4/en/modules/zend.mvc.plugins.html
w sekcji "Redirect Plugin" jest notatka:

This plugin requires that the controller invoking it implements InjectApplicationEventInterface, and thus has an MvcEvent composed, as it retrieves the router from the event object.

nie bardzo rozumiem jak mam ją zaimplementować. Próbuje w kontrolerze stworzyć klasę implementującą dany interfejs,

class RegisterController extends AbstractActionController implements InjectApplicationEventInterface

ale niestety nadal mam ten sam błąd :(

Poniżej kod:

 
<?php
namespace Users\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Users\Form\RegisterForm;
use Users\Form\RegisterFilter;

use Zend\Mvc\InjectApplicationEventInterface;

class RegisterController extends AbstractActionController implements InjectApplicationEventInterface
//class RegisterController extends AbstractRestfulController
{
  public function indexAction()
  {
    $form = new RegisterForm();
    $viewModel = new ViewModel(array('form' => $form));
    return $viewModel;
  }
  public function confirmAction()
  {
    $viewModel = new ViewModel();
    return $viewModel;
  }
  public function processAction()
  {
    if(!$this->request->isPost()){
     return $this->redirect()->toRoute(NULL,array('controller' => 'register', 'action' => 'index'));
    }
    $post = $this->request->getPost();
    $form = new RegisterForm();
    $inputFilter = new RegisterFilter();
    $form->setInputFilter($inputFilter);
    $form->setData($post);
    if(!$form->isValid()){
     $model = new ViewModel(array('error' => true, 'form' => $form,));
     $model->setTemplate('users/register/index');
     return $model;
    }
    return $this->redirect()-toRoute(NULL,array('controller' => 'register', 'action' => 'confirm'));
  }
}
?>

Czy ktoś miał podobny problem ?

1
 return $this->redirect()-toRoute(NULL,array('controller' => 'register', 'action' => 'confirm'));

Nie brakuje przypadkiem strzałeczki po "redirect()-"

0

Tak :) dzięki za spostrzegawczość

1 użytkowników online, w tym zalogowanych: 0, gości: 1