cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[BUG] Micro collections not returning Router

Open iamtgray opened this issue 13 years ago • 7 comments

Hi Folks

I am writing some custom collections for my routes so I can seperate them into reasonable groups under a controller, and I have found a bug in the software.

The documentation states that the collection's get, put, post and delete methods will return an object implementing the Phalcon\Mvc\Router\RouteInterface interface, however after doing the following code the methods return null (or void).

$collection->setHandler('Controller\Entity\Customer', true);

$getReturn = $collection->get('/customer/{id}', 'get');
$putReturn = $collection->put('/customer/{id}', 'put');
$deleteReturn = $collection->delete('/customer/{id}', 'delete');
$postReturn = $collection->post('/customer', 'post');

var_dump($getReturn, $putReturn, $deleteReturn, $postReturn);

This then returns:

NULL
NULL
NULL
NULL

Discovered this while trying to use the setName() method on the return of these route aditions.

iamtgray avatar Aug 21 '13 16:08 iamtgray

I think it is wrong document.

dreamsxin avatar Aug 23 '13 03:08 dreamsxin

Hi Dreamsxin what do you mean by wrong document?

iamtgray avatar Aug 27 '13 18:08 iamtgray

What I mean is that it should not return values. I view the Phalcon\Mvc\Micro\Collection source code, Did not return to the operating, And get\put\delete\post These methods do not require the second argument.

dreamsxin avatar Aug 27 '13 23:08 dreamsxin

This is a bug. It is not really a problem if your are using get,put,delete, and post method, but it become a problem when using map. If the map can return Router interface, it can be called as $collection->map(...)->via(['POST','PUT']);

I have reported similiar BUG in: https://github.com/phalcon/cphalcon/issues/1037

jeffreycahyono avatar Aug 29 '13 19:08 jeffreycahyono

Any chance anyone can look at this?

Slyvampy avatar Sep 24 '13 19:09 Slyvampy

This is the bug in the documentation — the methods should return Phalcon\Mvc\Micro\CollectionInterface, not Phalcon\Mvc\Router\RouteInterface

ghost avatar Sep 24 '13 19:09 ghost

This is fixed in 1.2.4/1.3.0

ghost avatar Sep 24 '13 21:09 ghost