src/Infrastructure/Filesystem/FilesystemService.php
public static function generatePath(
        AttributeInterface $attribute,
        $additional_prefix = '',
        $extension = '',
        $uuid = null
    ) {
        $uuid = $uuid ? UuidGenerator::fromString($uuid) : UuidGenerator::uuid4();
        $uuid_string = $uuid->toString();
        $uuid_parts = $uuid->getClockSeqLow(); // 8 bit int => 256 folders

        $root_type = $attribute->getRootType();
        $root_type_name = $root_type->getName();
        if ($root_type instanceof EntityTypeInterface) {
            $root_type_name = $root_type->getPrefix();
        }

        $attribute_path = $attribute->getPath();

        $identifier = '';

        if (!empty($additional_prefix)) {
            $identifier = $additional_prefix . '/';
        }

        $identifier .= sprintf('%s/%s/%s/%s', $root_type_name, $attribute_path, $uuid_parts, $uuid_string);

        if (!empty($extension)) {
            $identifier .= '.' . $extension;
        }

        return $identifier;
    }
public static function generatePath(
        AttributeInterface $attribute,
        $additional_prefix = '',
        $extension = '',
        $uuid = null
    ) {
        $uuid = $uuid ? UuidGenerator::fromString($uuid) : UuidGenerator::uuid4();
        $uuid_string = $uuid->toString();
        $uuid_parts = $uuid->getClockSeqLow(); // 8 bit int => 256 folders

        $root_type = $attribute->getRootType();
        $root_type_name = $root_type->getName();
        if ($root_type instanceof EntityTypeInterface) {
            $root_type_name = $root_type->getPrefix();
        }

        $attribute_path = $attribute->getPath();

        $identifier = '';

        if (!empty($additional_prefix)) {
            $identifier = $additional_prefix . '/';
        }

        $identifier .= sprintf('%s/%s/%s/%s', $root_type_name, $attribute_path, $uuid_parts, $uuid_string);

        if (!empty($extension)) {
            $identifier .= '.' . $extension;
        }

        return $identifier;
    }
public static function generatePath ( AttributeInterface $ attribute , $ additional_prefix = '' , $ extension = '' , $ uuid = null ) { $ uuid = $ uuid ? UuidGenerator :: fromString ( $ uuid ) : UuidGenerator :: uuid4 ( ) ; $ uuid_string = $ uuid -> toString ( ) ; $ uuid_parts = $ uuid -> getClockSeqLow ( ) ; // 8 bit int => 256 folders $ root_type = $ attribute -> getRootType ( ) ; $ root_type_name = $ root_type -> getName ( ) ; if ( $ root_type instanceof EntityTypeInterface ) { $ root_type_name = $ root_type -> getPrefix ( ) ; } $ attribute_path = $ attribute -> getPath ( ) ; $ identifier = '' ; if ( ! empty ( $ additional_prefix ) ) { $ identifier = $ additional_prefix . '/' ; } $ identifier .= sprintf ( '%s/%s/%s/%s' , $ root_type_name , $ attribute_path , $ uuid_parts , $ uuid_string ) ; if ( ! empty ( $ extension ) ) { $ identifier .= '.' . $ extension ; } return $ identifier ; }
Generates a unique file identifier that may be used as a relative file path.

@param AttributeInterface $attribute attribute to generate a file identifier for
@param string $additional_prefix a string to add in front of the generated identifier
@param string $extension a (file) extension to append to the generated identifier (e.g. 'jpg')

@return string unique relative file path
Generates a unique file identifier that may be used as a relative file path .