Attachment/AttachmentHandler.php
protected function generateKey(File $file, AttachableObjectInterface $object, $fieldName)
    {
        $schema = $this->getSchemaForObject($object, $fieldName);
        
        if ($file instanceof UploadedFile)
        {
            $extension = $file->getClientOriginalExtension();
        }
        else
        {
            $extension = $file->getExtension();
        }
        
        $hash = $this->generateFileHash($file, $schema);
        
        $fileKey = new $this->fileKeyClass();
        $fileKey
            ->setHash($hash)
            ->setExtension($extension)
            ->setDepth($schema->getStorageDepth())
            ->setClassName($object->getAttachableClassName())
            ->setFieldName($fieldName)
            ->setStorageName($schema->getStorage()->getName())
        ;
        
        // This triggers the generation inside the key. If there are any exceptions, we want them here for clarity.
        $fileKey->getKey();
        
        return $fileKey;
    }
protected function generateKey(File $file, AttachableObjectInterface $object, $fieldName)
    {
        $schema = $this->getSchemaForObject($object, $fieldName);
        
        if ($file instanceof UploadedFile)
        {
            $extension = $file->getClientOriginalExtension();
        }
        else
        {
            $extension = $file->getExtension();
        }
        
        $hash = $this->generateFileHash($file, $schema);
        
        $fileKey = new $this->fileKeyClass();
        $fileKey
            ->setHash($hash)
            ->setExtension($extension)
            ->setDepth($schema->getStorageDepth())
            ->setClassName($object->getAttachableClassName())
            ->setFieldName($fieldName)
            ->setStorageName($schema->getStorage()->getName())
        ;
        
        // This triggers the generation inside the key. If there are any exceptions, we want them here for clarity.
        $fileKey->getKey();
        
        return $fileKey;
    }
protected function generateKey ( File $ file , AttachableObjectInterface $ object , $ fieldName ) { $ schema = $ this -> getSchemaForObject ( $ object , $ fieldName ) ; if ( $ file instanceof UploadedFile ) { $ extension = $ file -> getClientOriginalExtension ( ) ; } else { $ extension = $ file -> getExtension ( ) ; } $ hash = $ this -> generateFileHash ( $ file , $ schema ) ; $ fileKey = new $ this -> fileKeyClass ( ) ; $ fileKey -> setHash ( $ hash ) -> setExtension ( $ extension ) -> setDepth ( $ schema -> getStorageDepth ( ) ) -> setClassName ( $ object -> getAttachableClassName ( ) ) -> setFieldName ( $ fieldName ) -> setStorageName ( $ schema -> getStorage ( ) -> getName ( ) ) ; // This triggers the generation inside the key. If there are any exceptions, we want them here for clarity. $ fileKey -> getKey ( ) ; return $ fileKey ; }
Generate the file key for the given file path and config.

@param File $file
@param AttachmentSchema $schema

@return FileKey
Generate the file key for the given file path and config .