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

Feature/rest crud #60

Merged
merged 70 commits into from Jun 28, 2015
Merged

Feature/rest crud #60

merged 70 commits into from Jun 28, 2015

Conversation

artstorm
Copy link
Contributor

No description provided.

zakhenry and others added 30 commits June 10, 2015 11:51
* feature/api-transformers:
  Added failing tests to postman.
  Added test entity model, migration, seeder and routes
…t-crud

* remotes/origin/master: (53 commits)
  Implements collection() and item() base methods to handle response transformation
  Declares the basecontroller as abstract
  Adds @todo entry to the relevant docblocks
  Removes the trait as it is now available in Lumen framework
  Removes teardown to close the Mockery, as that is now handled by Lumen
  Implements temporary fix for Mockery bug in Lumen 5.1.0
  Adds back the lock file
  Update bootstrap for 5.1
  Update dependencies for Lumen framework 5.1
  Restores the method names
  Adds initial tests for the Test Entity Repository
  Adds mockery as a development dependency
  Removes hard coded entity_id from the test
  Inject the Application instead over using Facade to prevent command line problems
  Fixed integration test expectation
  Switched over to using angular material
  Dropped unneeded zombiejs dependency, updated dependencies
  Add the traits in the base test class
  Implements a CrawlerTrait
  Implements additional assertions.
  ...

# Conflicts:
#	api/postman/spira.json.postman_collection
use Illuminate\Support\MessageBag;
use Illuminate\Http\Exception\HttpResponseException;

class ValidationException extends HttpResponseException
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ValidationException should probably implemenent Symfony\Component\HttpKernel\Exception\HttpExceptionInterface as the error handler (spira/api/app/Http/Controllers/BaseController.php:renderException) method checks if $e instanceof HttpExceptionInterface and sets the response code with $e->getStatusCode(). We are using the Symfony\Component\HttpKernel\Exception elsewhere so we should probably implement their interface for consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I've been checking that out now. So if I understand correctly, we'll need to add handling in BaseController.php:renderException that injects the invalid object into the response. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiphiaz 95bfdc0 adds this change. I added a call to ValidationException from BaseController.php:renderException that modifies the response so we get the invalid key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiphiaz I made a small tweak in dd31da5 to not hardcode it against ValidationException but to allow any custom exception class to override the response if needing to add more keys.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artstorm i think it is better practice to make the check if ($e instanceof HttpExceptionInterface) if you want to check for the presence of the getResponse method. As the ValidationException needs the getResponse method and the getStatusCode method of HttpExceptionInterface I think the ValidationException should be defined as

use Illuminate\Http\Exception\HttpResponseException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

ValidationException extends HttpResponseException implements HttpExceptionInterface

so that both methods are available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiphiaz By having ValidationException extending HttpResponseException it actually already inherits the HttpExceptionInterface from the parent class, so it makes no practical difference to duplicate the implements again in the extending class. I'll add it to the code base though.

And I'll move the check to be inside the if ($e instanceof HttpExceptionInterface).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiphiaz Done in 0095401

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artstorm ah I think you misunderstood - see in the use commands in the example above - there is two different namespaces - one from Illuminate the other from Symfony. It is the Illuminate\Http\Exception\HttpResponseException that has the getResponse method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiphiaz I'm not sure I completely follow along now? Haha. But I think we have it implemented correctly now, or do I need to adjust anything?

@zakhenry
Copy link
Collaborator

@artstorm comment #60 (comment) is being swallowed by the outdated diff in case you miss it.

@zakhenry
Copy link
Collaborator

@artstorm ok on closer inspection it looks like laravel catches and returns the responses with 200OK when a HttpResponseException is thrown. That is not what we are after, so your approach is better. I'm creating a patch for a related issue at the moment so in that I'll tidy the redundant implements in that.

@zakhenry
Copy link
Collaborator

@artstorm tidyup added in c14a731 which is included in PR #61

@artstorm
Copy link
Contributor Author

@xiphiaz I think #60 might be done now, or do you see anything else that needs tweaking/adding/fixing?

(Edit: Checking #61 now...)

@artstorm artstorm assigned zakhenry and unassigned artstorm Jun 28, 2015
@zakhenry
Copy link
Collaborator

@artstorm one last thing - can you review and merge #61 as it is a patch for #60 .

Other than that we are good to go.

@artstorm
Copy link
Contributor Author

@xiphiaz I just reviewed and merged #61, looked super to me.

@zakhenry
Copy link
Collaborator

@artstorm awesome, I'll wait for the travis builds to pass then merge.

zakhenry added a commit that referenced this pull request Jun 28, 2015
@zakhenry zakhenry merged commit 7157d80 into master Jun 28, 2015
@zakhenry zakhenry deleted the feature/rest-crud branch July 3, 2015 00:54
zakhenry added a commit that referenced this pull request Dec 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants