Gaufrette icon indicating copy to clipboard operation
Gaufrette copied to clipboard

[Adapter] - Directory

Open zender opened this issue 12 years ago • 9 comments

There should be a public method Adapter:getDirectory().

zender avatar Aug 18 '13 11:08 zender

Similar to #175, #201

hason avatar Aug 20 '13 05:08 hason

I don't agree with you : I don't think this issue is similar to #175 and #201. For me, @zender talks about having a getDirectory method in order to retrieve directory path. Useful if you want to manage manually the directory, which is not possible at the moment (#115).

#175 and #201 just refer to add an option for limiting recursion when you iterate through keys to improve performance.

gpaton avatar Sep 30 '13 09:09 gpaton

I don't think it should be on the Adapter though. Not every adapter uses a directory. But it would be useful to be able to get the directory path on the Local adapter for example.

rvanlaarhoven avatar Apr 11 '14 12:04 rvanlaarhoven

What is the usecase ? You set the directory in the adapter by yourself.

Nek- avatar May 15 '14 15:05 Nek-

@gpaton What is the use case please? The whole point of Gaufrette is to provide a storage-agnostic layer. For me, opening the fact that this storage uses a directory is already breaking the abstraction of this layer. It's for the same reason that it's not possible to get the file path from outside of the Local adpater.

gquemener avatar Jun 04 '14 08:06 gquemener

For me, I inject a Filesystem into a class that writes a file. After writing the file, i need to return the file path. Because different filesystems could be injected, I can't know the directory path the adapter uses.

It would be useful to be able to simply call $this->filesystem->getAdapter()->getDirectory().

rvanlaarhoven avatar Jun 04 '14 09:06 rvanlaarhoven

That's my point, the only input/output of a Gaufrette filesystem is a file key. This key will allow you to communicate with whatever filesystems you defined and if you need a path that is storage specific, then you're doing it wrong.

Another solution is that you configure a directory into the local adapter that you could reuse elsewhere and compute by hand a file path. It really depend on what you want to achieve with the file path in the class you inject a Filesystem instance.

gquemener avatar Jun 04 '14 09:06 gquemener

Well yeah you're right. In my case I needed the full path to execute a shell command with it. I'll have a look at it later to find a better solution.

rvanlaarhoven avatar Jun 04 '14 10:06 rvanlaarhoven

I'm having the same use case. I need to have a path to execute some files. @rvanlaarhoven how did you solve this?

ruudk avatar May 02 '15 09:05 ruudk