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

File::setModel(): Switch from class_uses() to duck test #4748

Closed
lukasbestle opened this issue Oct 3, 2022 · 1 comment · Fixed by #4750
Closed

File::setModel(): Switch from class_uses() to duck test #4748

lukasbestle opened this issue Oct 3, 2022 · 1 comment · Fixed by #4750
Assignees
Milestone

Comments

@lukasbestle
Copy link
Member

The following lines cause a regression when a model class is extended in a plugin (because class_uses() does not check parents):

if ($model !== null && in_array(IsFile::class, class_uses($model)) !== true) {
throw new InvalidArgumentException('The model object must use the "Kirby\Filesystem\IsFile" trait');
}

Instead we want to check for the existence of the root() and url() methods.

See mullema/k3-image-clip#25 for the original discussion.

@lukasbestle lukasbestle added this to the 3.8.0 milestone Oct 3, 2022
afbora added a commit that referenced this issue Oct 4, 2022
Co-Authored-By: Lukas Bestle <1595007+lukasbestle@users.noreply.github.com>
afbora added a commit that referenced this issue Oct 4, 2022
Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-Authored-By: Lukas Bestle <1595007+lukasbestle@users.noreply.github.com>
afbora added a commit that referenced this issue Oct 4, 2022
Co-Authored-By: Nico Hoffmann  ෴. <3788865+distantnative@users.noreply.github.com>
Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-Authored-By: Lukas Bestle <1595007+lukasbestle@users.noreply.github.com>
@afbora afbora linked a pull request Oct 4, 2022 that will close this issue
5 tasks
@bastianallgeier
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants