flownative / flow-resourceproxy
一个透明地从远程源导入缺失资源的Flow包
v0.0.5
2023-06-09 10:06 UTC
Requires
- php: ^7.4 || ^8.0 || ^8.1
- neos/flow: ^6.0 || ^7.0 || ^8.0
README
Flownative.Flow.ResourceProxy
描述
这个Flow包允许透明地从其他系统导入资源数据到Flow。它通过提供一个实现来尝试从远程源获取缺失的资源。当一个资源可以被获取时,它会被“导入”并像往常一样可用,否则系统会在资源缺失时按常规行为运行。
由于Neos CMS在底层使用Flow的资源管理,这也非常适合Neos中的资产。
这对于本地开发非常有用,因为它消除了需要将所有资源与数据库转储一起复制到本地机器的需要。
安装
Flownative Resource Proxy通过Composer作为一个常规Flow包进行安装。对于您现有的项目,只需将flownative/flow-resourceproxy
包含到您的Flow或Neos分布的依赖项中
composer require flownative/flow-resourceproxy
配置
为了导入,该包需要知道远程源的基本URI以及它是否使用分割的哈希路径段。
Flownative: Flow: ResourceProxy: storages: # the default storage for a Flow setup 'defaultPersistentResourcesStorage': # the remote base URI to the published resources remoteSourceBaseUri: 'https://www.acme.com/_Resources/Persistent' # whether or not the remote source uses the target setting of the same name subdivideHashPathSegment: true
配置设置后,清除Fusion缓存以确保将再次获取URI,并可以检查是否需要导入。同样,清除现有的缩略图将迫使系统重新生成它们。
故障排除
如果事情没有按预期进行,请检查系统日志,该包在调试日志级别中相当健谈。
实现
在Flow中,资源访问是通过资源管理API处理的。这些方法需要检查缺失的资源,并在本地不可用时尝试获取它
StorageInterface.getStreamByResource
StorageInterface.getStreamByResourcePath
(在纯Neos设置中未使用)TargetInterface.getPublicPersistentResourceUri
以下方法涵盖以上内容
Collection.getStreamByResource
通过StorageInterface.getStreamByResource
ResourceManager.getStreamByResource
通过Collection.getStreamByResource
ResourceManager.getPublicPersistentResourceUri
通过TargetInterface.getPublicPersistentResourceUri
ResourceManager.getPublicPersistentResourceUriByHash
通过TargetInterface.getPublicPersistentResourceUri
此外,系统使用图像变体和缩略图,假设如果它们的元数据可以在数据库中找到,这些将存在。不过,这些的URI是通过TargetInterface.getPublicPersistentResourceUri
方法获取的。
因此,该包建议StorageInterface
和TargetInterface
检查缺失的资源,并在需要时尝试“导入”它们。
注意:到目前为止,这仅适用于WritableFileSystemStorage
。