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

Refactor internal configuration and public properties #294

Merged
merged 10 commits into from
May 11, 2015
Merged

Refactor internal configuration and public properties #294

merged 10 commits into from
May 11, 2015

Conversation

shadowhand
Copy link
Member

  • all properties in AbstractProvider made protected
  • many config properties removed in favor of protected methods that can be overloaded
  • modified header, scope, redirects, etc handling
  • tests updated

Add `getState` for external access to authorization state.
*/
protected function getScopeSeparator()
{
return ',';
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 thought about making this a class constant.

Public interface is not modified, but internally headers are now generated by
using `getDefaultHeaders` and `getAuthorizationHeaders` methods, the latter
only be called when a token is passed into `getHeaders`.

This replaces the `$authorizationHeader` property and makes the internal
interface more flexible for custom authentication schemes.
Remove `getScopes` and `setScopes` from provider interface, as we can now
overload scopes using authorization options. Remove `$scopes` and `$scopeSeparator`
properties in favor of `getDefaultScopes` method and `SCOPE_SEPARATOR` constant
that can be overloaded by providers.
*/
public $state;
const SCOPE_SEPARATOR = ',';
Copy link
Member Author

Choose a reason for hiding this comment

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

Converted the constant value to... constants.

@rtheunissen
Copy link
Contributor

This looks good to me. As long as we keep getHeaders public as well (as it is), I'm all for it.

@ramsey
Copy link
Contributor

ramsey commented May 11, 2015

All looks great to me. Looks like you said you needed to remove/change some things. Is it all good to merge, or should I wait?

@shadowhand
Copy link
Member Author

shadowhand commented May 11, 2015 via email

@rtheunissen
Copy link
Contributor

What are your thoughts on making provider configuration immutable?

@rtheunissen
Copy link
Contributor

Actually nevermind I just had a closer look. :)

ramsey added a commit that referenced this pull request May 11, 2015
Refactor internal configuration and public properties
@ramsey ramsey merged commit 9ba7b83 into thephpleague:1.0 May 11, 2015
@shadowhand shadowhand deleted the feature/protected-properties branch May 12, 2015 14:23
*/
public $redirectUri = '';
const RESPONSE_TYPE = 'json';
Copy link
Member

Choose a reason for hiding this comment

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

Having the response type as a constant is problematic for the Facebook provider. In Graph v2.2 and below the response type was "string" and starting in v2.3 the response type was "json". See how the Facebook provider was dealing with this issue. Any way we can revert this change for the response type?

Also - although I like constants, there's no guarantee that any of these constants will be consistent across all versions of a provider's API (as in the response type example). Perhaps we should revert all of them to be on the safe side? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

@philsturgeon
Copy link
Member

Make it method and shove it in the interface then?

@rtheunissen
Copy link
Contributor

Perhaps we should revert all of them to be on the safe side? :)

So have protected methods return the default, and be overridden where necessary? That's how I've always done things as it has all the benefits of the property not being accessible outside of the class (and its descendants), having a default value present, and being flexible for extending classes. You can then return a response type based on the value of something else, eg. Graph API version.

No need to have these in the interface as extending classes would only override if required to do so.

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.

5 participants