Comments (14)
Thanks for reporting this. It sounds like a bug. I am gonna work on fix and update this issue when done.
from zf2-restful-module-skeleton.
Awesome, thank you. Is there anything I can provide to help replicate?
from zf2-restful-module-skeleton.
Nah, I think what is happening is clear. But I will let you know if it becomes unclear :)
from zf2-restful-module-skeleton.
@aramonc I have a feeling this is not a bug. Try setting the priority for the "errorProcess" method to something lower (lower than your other error listeners, ie -999). To do that go to Module.php and change method "onBootstrap"; you will see the listener attachment code somewhere in the end of that method.
Let me know.
from zf2-restful-module-skeleton.
@scaraveos, on my side i tried to change the priority of the listener calling errorProcess
to -999 but i still get thrown exceptions showing up as json :(
from zf2-restful-module-skeleton.
@jhuet do you have anything else listening to the same event?
from zf2-restful-module-skeleton.
@scaraveos I think this is working as you described. I need to run a couple more tests to be sure, but I think this can be closed & just added to the documentation.
from zf2-restful-module-skeleton.
Thanks for confirming @aramonc, I will add some more comments on that file.
from zf2-restful-module-skeleton.
@scaraveos I'm also having problems with the errorProcess taking over despite having set the priority to -999. I'm just getting into ZF2, so my solution is just a hack:
add
public function errorProcess(MvcEvent $e)
{
$routeMatch = $e->getRouteMatch();
if (!$routeMatch) {
return null;
}
....
I am using the ZF2 skeleton app and changed the route
in module/Main/config/module.config.php
to '/rest/:controller[.:formatter][/:id]'
. Thanks for you work!
from zf2-restful-module-skeleton.
@chris-- Do you have anything else listening to the "MvcEvent::EVENT_DISPATCH_ERROR" event? If not then "errorProcess" will always handle that event.
from zf2-restful-module-skeleton.
@scaraveos that makes sense. Is there any way to have it do the default other than what @chris-- did?
from zf2-restful-module-skeleton.
@scaraveos I dont really understand how the error delegation works in the zf skeleton but I dont think there is anything listening on that event.
from zf2-restful-module-skeleton.
@aramonc if I understood you correctly; essentially what @chris-- did is handled at line 129 in Module.php in a different way though.
from zf2-restful-module-skeleton.
I tried all of the work arounds listed in this thread and nothing worked for me. I decided to check the headers for Accept text/html. If it finds that header it will return null out of the errorProcess function and display HTML view model. Here is the commit https://github.com/UNOIS/RestfulApiModule/commit/8bbcd4c54a28492a60b92d3f6efb4eb674de3a91
from zf2-restful-module-skeleton.
Related Issues (16)
- How to write unit test for a controller HOT 4
- Missing instance/object for parameter route for Zend\Mvc\Router... HOT 1
- Extra data when issueing Status Code HOT 1
- Support for longer (or more complex) URLs HOT 7
- This module does not work with ZendDeveloperTools HOT 3
- not composer friendly
- Do we have Unit tests for this module?
- multiple get method HOT 2
- getVariables() method issue HOT 1
- Service with name "json-pp" could not be created. HOT 1
- The requested URL could not be matched by routing HOT 4
- Fatal error HOT 2
- Question about posible reason not function HOT 2
- unable to fetch or create an instance for info HOT 3
- Response format in URI HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zf2-restful-module-skeleton.