-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call to undefined method Phalcon\Mvc\Micro\Collection::setName() #1868
Comments
It is meant to return Phalcon\Mvc\Micro\CollectionInterface, not Phalcon\Mvc\RouterInterface: https://github.com/phalcon/cphalcon/blob/1.3.0/ext/mvc/micro/collection.c#L251 Looks like a bug in the IDE stubs. |
@sjinks but then how is it possible to name the routes? |
Why? Phalcon\Mvc\Micro\Collection is not Phalcon\Mvc\Router\Route, they are completely different entities. Internally, Collection is an array of arrays: $this->_handlers = array(
array('GET', '/route_pattern1/', 'Handler1'),
array('POST', '/route_pattern2/', 'Handler2'),
// etc
); Routes are created much later, when you call |
@sjinks To keep the interface consistent with micro application + mvc, it is possble to configure the routes and the names for the routes in the same place. For example look at micro without collection: http://docs.phalconphp.com/en/latest/reference/routing.html#parameters-with-names Both the config for the routes and the names for the routes are in the same location, it does not seem logical for a collection to configure the routes, but set the names for them in the router itself. What the object is internally does not really matter when it creates the actual router it could still have another array key to set the name there too to example: array('GET', '/route_pattern1/', 'Handler1', 'name'), |
@mech7 PR submitted, however, the syntax will differ: Instead of $collection->get('/media', 'index')->setName('home'); there will be $collection->get('/media', 'index', 'home'); because the collection returns |
@sjinks 👍 cool thx for the pull request |
This has been merged into 1.3.0, could you pleas check and close this bug if everything works for you? |
It is not possible to name micro collection routes, autocomplete ide does have a method setName
The problem is it returns itself " \Phalcon\Mvc\Micro\Collection" instead of the "\Phalcon\Mvc\Router\RouteInterface"
The text was updated successfully, but these errors were encountered: