Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Config] Allow nonexistent file resources#20836

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@julienfalque
Copy link
Contributor

QA
Branch?master
Bug fix?yes?
New feature?yes?
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

UpdatesFileResource to also evaluate freshness against file existence.

Currently,FileResource assumes that the file always exists. I have a use case where this is not necessarily true: for tests purposes, I create aTestKernel class that usesMicroKernelTrait to define all the configs directly, except some values that are defined inphpunit.xml andphpunit.xml.dist files. Since the tests can pass with the default values fromphpunit.xml.dist, creating thephpunit.xml file is not required. So inTestKernel I have to do this:

if (file_exists('phpunit.xml')) {$container->addResource(newFileResource('phpunit.xml'));}else {$container->addResource(newFileExistenceResource('phpunit.xml'));}

Maybe it should be a new class instead, WDYT?

@julienfalquejulienfalque changed the titleFile resource[Config] Allow nonexistent file resourcesDec 8, 2016
@nicolas-grekasnicolas-grekas added this to the3.x milestoneDec 9, 2016
@xabbuh
Copy link
Member

Not sure if we need this feature. But in this case I'd prefer a new parameter instead of a new resource type.

@julienfalque
Copy link
ContributorAuthor

I'm not sure about adding a parameter.

The current behavior is to check that the file still exists before evaluating freshness and returnfalse if it doesn't. So it already detects when a file is removed, despite being more of a side-effect than something truly desired, I guess. A parameter would toggle the detection of the file creation, but would have no effect on the detection of its removal because we can't evaluate freshness against a missing file anyway.

Or maybeFileResource should throw an exception (or deprecation notice to keep BC) when the file is removed and said parameter does not allow it, but I'm not sure such strictness would make sense.

@sstok
Copy link
Contributor

Maybe aCombined[File]Resource (or a better name) where you can add multiple[File]Resources and check until one gives false.

Combined[File]Resource([newFileExistenceResource('phpunit.xml'),newFileResource('phpunit.xml')]);

@julienfalque
Copy link
ContributorAuthor

That would still require changes toFileResource as it currently throws an exception if the file does not exist.

Furthermore, having such resource class to combine other resources would be superfluous: the container is recompiled as soon as at least one of its resources is updated, we can simply add both resources from your example to the container directly.

@nicolas-grekas
Copy link
Member

Closing in favor of#21408 which wraps the required logic and should be the way to go now.
Thanks for the PR.

@julienfalquejulienfalque deleted the file-resource branchFebruary 14, 2017 13:53
@nicolas-grekasnicolas-grekas modified the milestones:3.x,3.3Mar 24, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

5 participants

@julienfalque@xabbuh@sstok@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp