zf-fr / zfr-rest

A module for Zend Framework 2 that aims to simplify RESTful
81 stars 31 forks source link

ResourceGraphRoute capturing undefined routes #176

Closed Thinkscape closed 9 years ago

Thinkscape commented 10 years ago

Given route:

'entity'         => [
    'type'    => 'ResourceGraphRoute',
    'options' => [
        'route'    => '/entity',
        'resource' => 'App\Model\Entity'
    ]
],

I can now access the following urls:

Weird :-)

Thinkscape commented 10 years ago

I think it's this part of ResourceGraphRoute.php that needs refactoring...

        // If the URI does not begin by the route, we can stop immediately
        if (substr($path, 0, strlen($this->route)) !== $this->route) {
            return null;
        }

        // If we have only one segment (for instance "users"), then the next path to analyze is in fact
        // an empty string, hence the ternary condition
        $pathParts = explode('/', trim($path, '/'), 2);
        $subPath   = count($pathParts) === 1 ? '' : end($pathParts);
bakura10 commented 10 years ago

Oh. Yeah, definitely not good!

Can you submit a PR ? :D

bakura10 commented 9 years ago

Did you have some time to fix this issue @Thinkscape ?

bakura10 commented 9 years ago

@Thinkscape that will be fixed in 0.3.5