Download the PHP package apie/storage-metadata without Composer
On this page you can find all versions of the php package apie/storage-metadata. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download apie/storage-metadata
More information about apie/storage-metadata
Files in apie/storage-metadata
Package storage-metadata
Short Description Composer package of the apie library: storage metadata
License MIT
Informations about the package storage-metadata
storage-metadata
This package is part of the Apie library. The code is maintained in a monorepo, so PR's need to be sent to the monorepo
Documentation
This package is used to convert an Apie domain object to a storage DTO that can be used by data mapper ORM's. The creation of a storage DTO can be done by hand or created automatically by the package apie/storage-metadata-builder.
Usage
The simplest usage is using the simple static create method. In case you want to customize it you can create the object yourself.
A file storage service is required to store properties with typehints of UploadedFileInterface or StoredFile, since you do not want to store your files in the database (this is still possible with InlineStorage, but that should only be used for testing).
An Indexer service can also be provided for how indexing search indexes and columns.
You need a domain object and a storage DTO. For example this could be how your storage DTO looks like for an Address object that is part of an User object:
Then you can convert a domain object to a storage object or vice versa. It's also possible to inject in existing records.
This example creates a Address domain object with street, zipcode, city and manual property filled in.
Polymorphic resources
Polymorphic resources are mapped as well, but you need to provide a second argument to PropertyAttribute to define the mapped class. Basically if the property is not mapped to this domain object null will be stored in the column.
This example also shows how to make the domain object first as you can not instantiate a base abstract class like without knowing how to map it (this works with the DiscriminatorMappingAttribute attribute).