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

add getters to filesystem repository #44

Closed
wants to merge 1 commit into from
Closed

add getters to filesystem repository #44

wants to merge 1 commit into from

Conversation

Gummibeer
Copy link
Contributor

fixes #43

@Gummibeer
Copy link
Contributor Author

👊 poke - this PR is blocking for Astrotomic/stancy#23
Could you please review it? 😊

@sebastiandedeyne
Copy link
Member

Hmm this doesn't really feel right... This is unusable if someone uses a different repository. If you need this information, maybe you're better of extracting it from the configuration?

@Gummibeer
Copy link
Contributor Author

It's not part of the interface. So a simple instance of check is enough.
And is MUCH simpler than extracting myself and doesn't hurt anyone. It's only an additional feature which isn't part of the defined public API for all repositories.

@brendt
Copy link

brendt commented Oct 18, 2019

Can I suggest an alternative?

I want to be able to create a new file in the sheet collection filesystem.

So in essence, you need access to the same filesystem used by the sheets. I would rely on the dependency container to resolve the correct filesystem, eg. something like this:

class SheetsFilesystem extends Filesystem
{
    public function __construct()
    {
        parent::__construct('disk_name');
    }
}

(I haven't checked if this code is correct, but I'm sure you get what I mean)

This way the container is doing what it's supposed to do: managing class instances, and we don't need to add these kinds of shortcuts on the repository class.

I'd even go as far as manually configuring the sheet repository in your AppServiceProvider, manually passing it the SheetsFilesystem, just to be explicit.

Anyway, that's what I would do.

@Gummibeer
Copy link
Contributor Author

Just to know: why don't you want the getters? 🤔

@brendt
Copy link

brendt commented Oct 19, 2019

It's not the repository's responsibility to expose one of its dependencies to the outside world, that's the container's job 🙂

@Gummibeer
Copy link
Contributor Author

Okay, but the container also doesn't expose these two things. Only the config does but this also just optional.
I would also be happy with any public option to get a full merged config. How about a config class that does what the service provider does in protected methods? I'm okay with resolving the service my own. But doing the whole config resolving my own isn't a good solution for me because I have to copy part of this package logic.

@Gummibeer
Copy link
Contributor Author

I've solved it in my package.

@Gummibeer Gummibeer closed this Oct 19, 2019
@brendt
Copy link

brendt commented Oct 21, 2019

How about a config class that does what the service provider does in protected methods?

I was actually about to say the same. Freek already does this in one or two packages, and I think it's a pattern we should use more. Maybe @sebastiandedeyne is open for that idea?

@Gummibeer
Copy link
Contributor Author

Yes, the idea is from facade/ignition. Right now I've done it in two lines in my package. But would still like to adopt the config class or even provide a PR for it.

@Gummibeer
Copy link
Contributor Author

Regarding the repository interface and the package implementation FilesystemRepository.
How am I supposed to configure my own repository? The package implementation is hardcoded in the service provider. No service binding, config value or anything else to inject my own repository.

@Gummibeer Gummibeer reopened this Oct 21, 2019
@Gummibeer
Copy link
Contributor Author

#45 is the follow up for custom repositories.

@Gummibeer Gummibeer closed this Nov 5, 2019
@Gummibeer Gummibeer deleted the ft-filesystem-repository-getter branch November 5, 2019 09:33
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.

allow to access filesystem properties
3 participants