Comments

stBorchert created an issue. See original summary.

stborchert’s picture

Status: Active » Needs review
StatusFileSize
new3.77 KB

The patch simply updates the configuration form of FileMatcher so one can limit the results to some extensions.

anon’s picture

Version: 8.x-4.x-dev » 8.x-5.x-dev
Status: Needs review » Needs work

I totally agree with you.

Can you re-roll this against the 8.x-5.x version? A test with this would also be very welcomed.

stborchert’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
StatusFileSize
new3.77 KB

Rerolled agains 8.x-5.x. Test will follow ...

anon’s picture

Status: Needs review » Needs work

The patch works fine, thanks.

Now we only need a test that tests this.

stborchert’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new6.57 KB

I finally had the time to look into this again.
Unfortunately I had some problems using the matcher on files uploaded during the test (which are obviously all temporary) so I had to add a hidden configuration to the FileMatcher. Using this, the test is able to find the temporary files.

Btw.: automated testing is disabled for 8.x-5.x ;)

anon’s picture

Thanks! Awesome patch.

Just a few questions.

  1. +++ b/src/Plugin/Linkit/Matcher/FileMatcher.php
    @@ -23,26 +23,32 @@ class FileMatcher extends EntityMatcher {
    -    $summery = parent::getSummary();
    +    $summary = parent::getSummary();
    ...
    -    $summery[] = $this->t('Show image thumbnail: @show_image_thumbnail', [
    +    $summary[] = $this->t('Show image thumbnail: @show_image_thumbnail', [
    ...
    -        $summery[] = $this->t('Thumbnail style: @thumbnail_style', [
    +        $summary[] = $this->t('Thumbnail style: @thumbnail_style', [
    ...
    -    return $summery;
    +    return $summary;
    

    Is this line brake changes? Can't find any other explanation.

  2. +++ b/src/Plugin/Linkit/Matcher/FileMatcher.php
    @@ -50,6 +56,8 @@ class FileMatcher extends EntityMatcher {
    +      'status' => FILE_STATUS_PERMANENT,
    
    @@ -135,7 +155,18 @@ class FileMatcher extends EntityMatcher {
    -    $query->condition('status', FILE_STATUS_PERMANENT);
    +    if (isset($this->configuration['status'])) {
    +      $query->condition('status', $this->configuration['status']);
    +    }
    

    Why change this?

stborchert’s picture

Q 1
I corrected a small typo: "summery" vs. "summary".
Q 2
This is a hack needed to make the test work. If you upload files in tests, the files have the status 0 ("temporary"). FileMatcher queries for permanent files only, so I added the (hidden) option to filter the query for temporary files.

  • anon committed 15045e6 on 8.x-5.x authored by stBorchert
    Issue #2700365 by stBorchert, anon: Allow limiting FileMatcher to...
anon’s picture

Status: Needs review » Fixed
StatusFileSize
new6.54 KB
new1.36 KB

Thanks.

I made a small change to the comments to follow code standards.

  • anon committed f3d8104 on 8.x-5.x
    Revert "Issue #2700365 by stBorchert, anon: Allow limiting FileMatcher...
anon’s picture

Status: Fixed » Needs work

Dang! I totally forgot about the schema config changes.

We need to update the schema, and maybe create an update hook (5.x is only alpha so no update hook needed).

I have reverted the commit.

anon’s picture

StatusFileSize
new7.28 KB
new6.58 KB

Patch that updates the schema version.

I have renamed extensions to file_extensions where suitable, and added a new test that tests the file matcher with multiple file extensions.

And I guess we can do:

+++ b/src/Plugin/Linkit/Matcher/FileMatcher.php
@@ -135,7 +155,18 @@ class FileMatcher extends EntityMatcher {
+    if (isset($this->configuration['status'])) {
+      $query->condition('status', $this->configuration['status']);
+    }

to $query->condition('status', $this->configuration['status']); as it will always be set by defaultConfiguration().

anon’s picture

Status: Needs work » Needs review
stborchert’s picture

Status: Needs review » Reviewed & tested by the community

wohoo :)

  • anon committed 9b39660 on 8.x-5.x
    Issue #2700365 by stBorchert, anon: Allow limiting FileMatcher to...
anon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for alla help stBorchert,

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.