Open
Description
This package provides 3 node types out of the box: Directory
, File
and Image
. It's possible that users may want other node types in the future, each with their own set of metadata/functionality. Some possible examples: Pdf
, Video
, Audio
.
While if enough users request a specific type, we would add to core, but some kind of extension system could be developed via a NodeFactory
concept to allow 3rd party nodes.
Some ideas:
/**
* @template T of Node
*/
interface NodeFactory
{
/**
* @return T
*/
public function createFrom(Node $node): Node;
}
Change Filesystem::node()
method:
interface Filesystem
{
/**
* @template T of Node
*
* @param class-string<T> $type
*
* @return T
*/
public function node(string $path, string $type = Node::class): Node;
}
Add Node::ensure()
method:
interface Node
{
/**
* @template T of Node
*
* @param class-string<T> $type
*
* @return T
*/
public function ensure(string $type): Node;
}
Once such functionality exists, the existing 1st party image support could be extracted into a dedicated zenstruck/filesystem-image
package. This would leave File
and Directory
as the only node-types provided by the core library.
Metadata
Metadata
Assignees
Labels
No labels