-
-
Notifications
You must be signed in to change notification settings - Fork 513
Feature: add support for $filePaths
#2794
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
base: 2.12.x
Are you sure you want to change the base?
Feature: add support for $filePaths
#2794
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be possible to keep a single list of paths and split it in two when necessary to have dirs on one side and files on the other? This would simplify use and avoid breaking backward compatibility.
Do you mean passing both directory and file paths into the same list? @greg0ire suggested the current approach in doctrine/persistence#424 (comment) . This is a way of distinguishing From our vision, Or, another approach would be creating a class that represents an To summarize, mixing directory and file paths in the same list would make things more complex. The code would need to handle both types of paths and expand directories into individual files, making the |
3c2c72e
to
45d0043
Compare
I was too quick in my first review. I agree it's simpler to have either a list of dir names or a list of file names. But then I would remove the $pathsAsFilePaths = match(true) {
is_file($paths[0]) => true,
is_dir($paths[0]) => false,
default => throw new RuntimeException
} And then loop and validate that we only have dirs or file names. |
@GromNaN it would probably be better to discuss this at doctrine/persistence#429 with everybody. I will quote your message and respond to it. |
aeaaca3
to
06f744e
Compare
$sourceFilePathNames
$filePaths
In the scope of doctrine/persistence#432 (available from `doctrine/persistence` >= 4.1) there was added `ColocatedMappingDriver::$filePaths`, which allows passing an `Traversable` of file paths for the mapping driver to use. This commit integrates those changes into `AttributeDriver` (and `AnnotationDriver`). Since `doctrine/orm` maintains the support for `doctrine/persistence` of older versions, the `AttributeDriver` ensures that `$filePaths` is actually defined. Tests use `InstalledVersions` to opt into new behaviour if `doctrine/persistence` is at least version 4.1. The old behaviour can be adapted into new by using `DirectoryFilesIterator` and `FilePathNameIterator` on directory paths.
06f744e
to
6e1add0
Compare
Summary
In the scope of doctrine/persistence#432 (available from
doctrine/persistence
>= 4.1) there was addedColocatedMappingDriver::$filePaths
, which allows passing anTraversable
of file paths for the mapping driver to use.This commit integrates those changes into
AttributeDriver
(andAnnotationDriver
).Since
doctrine/orm
maintains the support fordoctrine/persistence
of older versions, theAttributeDriver
ensures that$filePaths
is actually defined. Tests useInstalledVersions
to opt into new behaviour ifdoctrine/persistence
is at least version 4.1.The old behaviour can be adapted into a new one by using
DirectoryFilesIterator
andFilePathNameIterator
on directory paths.