Skip to content
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

[Bug] 1.3.0 - adding routes to micro collection #1520

Closed
Cinderella-Man opened this issue Nov 5, 2013 · 5 comments
Closed

[Bug] 1.3.0 - adding routes to micro collection #1520

Cinderella-Man opened this issue Nov 5, 2013 · 5 comments
Labels
not a bug Reported issue is not a bug

Comments

@Cinderella-Man
Copy link
Contributor

Hi,

When adding routes to micro collection, object implementing RouteInterface should be returned but instead of that method returns collection object.

Testcase:

$handler = new RestHandler($this);
$app = new \Phalcon\Mvc\Micro();

$collection = new \Phalcon\Mvc\Micro\Collection();
$collection->setHandler($handler);

$collection->get('/api/siteA', 'find');
$collection->post('/api/siteB', 'save')->setName ('saveRoute');

$app->mount($collection);

$_SERVER['REQUEST_METHOD'] = 'GET';
$_GET['_url'] = '/api/siteA';

$app->handle();

$this->assertTrue($app->getRouter()->wasMatched());
$this->assertEquals(null, $app->getRouter()->getMatchedRoute()->getName());

$_SERVER['REQUEST_METHOD'] = 'POST';
$_GET['_url'] = '/api/siteB';

$app->handle();

$this->assertTrue($app->getRouter()->wasMatched());
$this->assertEquals('saveRoute', $app->getRouter()->getMatchedRoute()->getName());

Thanks in advance for fixing that,

Kamil

@dreamsxin
Copy link
Contributor

Phalcon\Mvc\Micro\Collection::map\get\post is return this.

See #1130 and #1037

@ghost
Copy link

ghost commented Jan 27, 2014

When you add routes to the micro collection, those routes are added to that collection and not to the router. Strictly speaking they are not routes — they are just a mapping between the URL and the handler.

@ghost
Copy link

ghost commented Jan 30, 2014

@phalcon what do we do with this case?

@phalcon
Copy link
Collaborator

phalcon commented Jan 30, 2014

Your explanation is right, the routes aren't being added to the router so they can't be named.

@ghost
Copy link

ghost commented Jan 30, 2014

I'd suggest to close this then :-)

@phalcon phalcon closed this as completed Jan 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug Reported issue is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants