Le 28/02/2012 02:11, Brandon Olivares a écrit :
Hi,
I've been looking at the Symfony source, and find myself wondering why there
isn't more integration among the various components.
As an example, Symfony\Component\Finder\Finder returns an iterator that has
Symfony\Component\Finder\SplFileInfo. However, there is also a
Symfony\Component\HttpFoundation\File\File class that extends PHP's
SplFileInfo, but adds extension guessing, moving files, etc.
So on both ends, why doesn't the iterator from Finder return instances of File
instead of SplFileInfo? And why doesn't File extend the custom SplFileInfo that
supports relative directories, instead of PHP's built-in one?
I guess it's a small thing, but I want to use the finder, and want to have a
Symfony\Component\HttpFoundation\File\File object, but am instead getting
SplFileInfo. I'm sure there might be other cases of the same thing.
I guess the File class, being in HttpFoundation, is supposed to be used more in
the case of file uploads, but it might be useful in other contexts as well, and
it seems that a file should be represented by one class, across the framework,
or else specific subclasses for additional requirements.
I would porpose:
1. Move Symfony\Component\HttpFoundation\File\File to
Symfony\Component\File\File, and include the
Symfony\Component\Finder\SplFileInfo functionality as well.
2. Have Symfony\Component\HttpFoundation\File\UploadedFile stay where it is
obviously, and extend the proposed Symfony\Component\File\File.
3. Have the iterators in Symfony\Component\Finder\Iterator return
Symfony\Component\File\File instead of SplFileInfo.
Etc. Just being consistent.
Brandon
both these extended classes have different purposes. The Finder
SplFileInfo object simply adds a method returning the path relative to
the place you searched in. It does not need the additional methods added
in HttpFoundation to handle file upload, and so it does not make sense
to add a dependency to the Finder component IMO whereas it is fully
standalone right now.
and the HttpFoundation cannot return the Finder class either: which root
should be used for the relative path when you have nothing to be
relative to ? And it would also add a dependency for the component
whereas it is also fully standalone right now (which is the reason why
Drupal started using it for instance)
Thus I don't think adding these cross-dependencies would really add
consistency as these classes have different purposes.
--
Christophe | Stof
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en