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

allow to use a custom repository #45

Merged
merged 2 commits into from Nov 13, 2019
Merged

allow to use a custom repository #45

merged 2 commits into from Nov 13, 2019

Conversation

Gummibeer
Copy link
Contributor

@Gummibeer Gummibeer commented Oct 29, 2019

This is an idea - the unittest isn't perfect (two classes in one file) and the whole could be breaking if someone tries to create the FileSystemRepository by his own. The documented API keeps intakt and isn't breaking.
This line is the key part of the whole PR:

$this->app->make($config['repository'], compact('factory', 'config'));

It utilizes the container to create the repository class and passes in the factory and the whole config array. This way the repository can use every container service binding in its construct and access every config key. So custom repositories could also add custom keys - like spreadsheet access data to pull data from a Google Spreadsheet or Contentful credentials or whatever the user wants to use as the base of his repository.

It's again part of my Stancy project to allow the users switch to any other common service as data/content storage. At the end it could even use an API in the background to retrieve weather data or whatever.

PS: I've run StyleCI over the whole repo - that's why some files are changed which aren't part of the original commit.

@Gummibeer
Copy link
Contributor Author

👊 poke

@sebastiandedeyne
Copy link
Member

I heavily prefer this solution over your previous PR, thanks 😍

@sebastiandedeyne sebastiandedeyne merged commit 052f06b into spatie:master Nov 13, 2019
@Gummibeer Gummibeer deleted the ft-custom-repository branch November 13, 2019 10:54
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