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

Output format plugin #129

Closed
wants to merge 34 commits into from

Conversation

e0ipso
Copy link
Member

@e0ipso e0ipso commented Aug 29, 2014

This is early work. I just wanted you to have a peek to the direction this is turning into.

Mateu Aguiló Bosch added 22 commits June 24, 2014 14:37
…put-format-plugin

Conflicts:
	restful.module
@amitaibu
Copy link
Member

The approach makes sense. I saw some minor stuff, but I'll wait to review once it's ready.

One thing though, is that I think the FormatterBase class could be our Json+HAL, instead of an unused one.

@e0ipso
Copy link
Member Author

e0ipso commented Aug 30, 2014

Makes sense

Mateu Aguiló Bosch added 5 commits September 1, 2014 10:27
Conflicts:
	modules/restful_token_auth/tests/RestfulTokenAuthenticationTestCase.test
	plugins/restful/RestfulEntityBase.php
	plugins/restful/RestfulEntityBaseMultipleBundles.php
	plugins/restful/RestfulFilesUpload.php
	restful.info
	tests/RestfulEntityAndPropertyAccessTestCase.test
	tests/RestfulEntityUserAccessTestCase.test
	tests/RestfulGetHandlersTestCase.test
	tests/RestfulHookMenuTestCase.test
	tests/RestfulListEntityMultipleBundlesTestCase.test
	tests/RestfulListTestCase.test
	tests/RestfulRenderCacheTestCase.test
	tests/RestfulViewEntityTestCase.test
@e0ipso
Copy link
Member Author

e0ipso commented Sep 1, 2014

@amitaibu this is ready to be reviewed now. I realized in the way that dealing with the special case of one item not being an array is a pain of if/else both in the back-end and in the front-end. So everything is an array now inside of 'data'.

->getQueryCount()
->execute();
$entity_type = $this->getEntityType();
if (!empty($count_results[$entity_type])) {
Copy link
Member

Choose a reason for hiding this comment

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

count() will return 0 or the number, so this can be

return $this
  ->getQueryCount()
  ->execute();

In that case maybe we can deprecate getQueryCount() and move logic here.

@amitaibu
Copy link
Member

amitaibu commented Sep 2, 2014

Really great PR, fun to review! :)

@amitaibu amitaibu mentioned this pull request Sep 2, 2014
@e0ipso
Copy link
Member Author

e0ipso commented Sep 3, 2014

Tests are green again.


/**
* @file
* Contains RestfulExampleArticlesResource__1_5.
Copy link
Member

Choose a reason for hiding this comment

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

RestfulExampleArticlesResource__1_5 => RestfulExampleArticlesResource__1_6

@e0ipso
Copy link
Member Author

e0ipso commented Sep 4, 2014

@amitaibu I think this is ready to be merged.

}
}
else {
$formatter_name = variable_get('restful_default_output_formatter', 'hal_json');
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/Gizra/restful/pull/129/files#r17127841

Something like this:

else {
  // Use a simple JSON formatter, for non RESTful handler calls, such as a CSRF token.
  $formatter_name = variable_get('restful_default_output_formatter', 'json');
}

Copy link
Member

Choose a reason for hiding this comment

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

or instead, for simplicity, just keep the delivery callback from CSRF token as it was with restful_json_output?

Seems simpler :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd rather not. It makes no sense to have YAML for everything but csrf tokens. It forces clients to support JSON, and that is against the spirit of this pr.

I'll have a custom delivery that skips the prepare method.

Copy link
Member

Choose a reason for hiding this comment

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

I'll have a custom delivery that skips the prepare method.

Or maybe in the plugin we can have "formatter_skip_prepare"?

@amitaibu
Copy link
Member

amitaibu commented Sep 7, 2014

@mateu-aguilo-bosch Seems ready. Can I merge, or still in work?

amitaibu added a commit that referenced this pull request Sep 7, 2014
@e0ipso
Copy link
Member Author

e0ipso commented Sep 7, 2014

Mergeable.

@amitaibu
Copy link
Member

amitaibu commented Sep 7, 2014

@mateu-aguilo-bosch I see something wrong here -- I query for a single entity ID and I get a count and _links:

local_d7_dev_api_v1_articles_73-3

@e0ipso
Copy link
Member Author

e0ipso commented Sep 7, 2014

Merged by ce02e44.

Created a follow up for the count and _links issue.

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