How to extend Asset / AssetRepository

Hello everyone,

I’m trying to extend the Neos\Media\Domain\Model\Asset for some more properties with my custom ExtendedMetadataAsset I am only using in a part of my application. I also extended the AssetRepository with my custom AssetMetadataAssetRepository which is extending Neos\Media\Domain\Repository\AssetRepository.

Objects.yaml:

'Neos\Media\Domain\Repository\AssetRepository':
  scope: singleton
  factoryObjectName: `Vendor\Package\Repository\ExtendedMetadataAssetRepository`

This is working great for my purpose but heavily breaks the Neos Media Module in the backend:

Call to undefined method Vendor\Package\Domain\Repository\ExtendedMetadataAssetRepository::create

Can you give me a hint how to extend the Asset model and also extend the database table ?

Thanks in advance!

Hi @hettler ,

I’m not sure if this is even possible.

Did you have a look into this package? Maybe this is already what you need? Otherwise it can give some hints, on how to do something like that.

Hi Daniel,

can you share your use case? Maybe there are more futureproof ways to achieve what you are trying to do

Thank you both for answering! :slight_smile:

I am importing pages, files & articles of a WordPress project into Neos. While importing pages and articles into nodes is working like a charm, Neos and Wordpress have totally different ways of managing files (generated _Resource/Persistent/[…] vs upload folder with sub folder structure). I want to import the files and save more meta data than copyright and description for later researches e.g. the old folder structure / old public urls, the old WordPress identifier, old WordPress author id etc.

I have separated those data in another database table vendor_package_extendedmetadataasset and my import is working but this breaks the editorial backend.

My next attempt is to remove my custom Model and Repository right after import to restore backend media management and I still have this data in the database if it is not possible to provide it by Neos.

Maybe it’s an option to use dedicated Node Types that reference the imported asset but also store additional metadata?

May following package help you ?