RegexDirectoryIterator can extend RegexIterator

Created on 31 January 2021, over 3 years ago
Updated 20 February 2023, over 1 year ago

Problem/Motivation

I was working on #3195568: [PP-1] Support recursive discovery for migration plugins β†’ and noticed we're using a custom Drupal\Component\FileSystem\RegexDirectoryIterator to iterate over the directory files and apply the regex filter.


new \RegexIterator(new \FilesystemIterator($path), 'pattern');

Actually, that's not true, because the \FilesystemIterator() will iterate over SplFileInfo objects, which returns full path name in toString() method. It makes it harder to set a regular expression for the file name. For example, '/^\d/' pattern won't match 1.yml file.

I think what we can do here - change the base class of RegexDirectoryIterator to simplify the class. Instead of \FilterIterator, we can use \RegexIterator, which already accepts a pattern.

Proposed resolution

Change the base class of RegexDirectoryIterator;

API changes

Nope.

πŸ“Œ Task
Status

Fixed

Version

10.1 ✨

Component
BaseΒ  β†’

Last updated about 2 hours ago

Created by

πŸ‡ΊπŸ‡¦Ukraine Matroskeen πŸ‡ΊπŸ‡¦ Ukraine, Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024