C
C
Cat Anton2014-11-26 19:54:43
Zend Framework
Cat Anton, 2014-11-26 19:54:43

Why do some hints in the ZF2 controller not work and how best to deal with this?

In the controller method, we enter $this->getRequest()->and are not visible in the list of hints, for example, the getHeader method.
To see hints, you have to write like this:

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;

use Zend\Http\PhpEnvironment\Response as HttpResponse;
use Zend\Http\Request as HttpRequest;

/**
 * @method HttpRequest getRequest() Get request object
 * @method HttpResponse getResponse() Get response object
 */
class TestController extends AbstractActionController
{
    public function testAction()
    {
        $this->getRequest()->getHeader('referer'); // подсказки работают
    }
}

Two questions:
1. Maybe there is a better way?
2. Why are tooltips not initially visible? ZF2 code documentation bug or something else?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2014-11-26
@27cm

They have type \Zend\Stdlib\RequestInterface, you have \Zend\Http\Request.
I would call it a design error on their part: the interface should have been extended.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question