Download the PHP package vox/restfull-client-mapper without Composer
On this page you can find all versions of the php package vox/restfull-client-mapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package restfull-client-mapper
Rest Mapper
A Restfull Resource Relational Mapper
1. Instalation
2. Creating a Transfer Manager
3.1. Using the TransferManagerBuilder
The builder class enables a more configuration style creation of the transfer manager.
The most basic setup would be the following, to obtain a manager with annotations driver, with no caching system:
to add caching system simply change it on the builder
to create with yml driver:
3.2 Using transactional mode
Sometimes, you need things to be rolled back when something goes wrong just like you can using a database. That behavior is possible with RRM too. Using the builder just call the method isTransactional.
Now, when something goes wrong, the manager will try to restore all data by doing posts, updates and deletions to the previows values on your webservice
3. Mapping a Transfer
3.1. the yml driver
if you want to leave the mapping metadata out of your object to keep it clean or keep it decoupled from this lib you can also use the yml metadata reader
3.1.1 - Yml mapping
the yml mapping must be named after the complete class namespace replacing backslashes by dots. Ex: /propject/metadata/Project.Package.ClassName.yml
3.2. Composite Ids
Composite id's are supported, however there are some limitations.
To map composite ids using annotations is really simple
The yaml mapping is also trivial
3.2.1 Mapping relationships with composite ids transfers
For now it is only possible to map belongs to relationships when linking to a composite ids transfer.
There are some limitations however, never use setters for ids or else it will not be able to post new transfers. new transfers needs to pull the ids from the foreign keys automaticaly by the unity of work
4. Using the Transfer Manager
5. Iri relationships support
if your webservice uses iri relationships, you can map it using the following
or with Yaml
the iriCollectionField is the field that conatiains an array of iri addresses, a collection of objects will be created as soon as you call the relatedTransfers, but have in mind, it will call the webservice one by one.
The other situations like belongs to, will be taken care automaticaly, just map as commom relationships, the lib detects if its an iri address using a regexp that looks for the format ".+/.+$"
6. Doctrine Interop
This lib uses the doctrine commom interfaces, so you can do code wich is interoperable with doctrine. The annotation mapping however is completely different, hence the use of the yaml mapping is encouraged (also using yml or xml mapping for doctrine projects is also encouraged, in order to create a domain decoupled from the framework)
7. The event system
The event system is made to be compatible with doctrine's, so you can have easy time importing plain objects from other system and have its events on your consumer
Create a listener class
Register the listener
Limitations
- The unity of work implementation of this lib uses the ids of the entities to determine the state of the entity, so using setters for the id fields may result in the entity being considered as untouched even if its a new entity wich should be posted. To avoid problems, prefer to let the lib manage the id fields automaticaly.
- Theres no many to many relationships handling, therefore if needed the associative table of the many to many association has to be mapped on the api and managed manualy, setting the transfers on it, do not set the ids manualy, manage only the objects around
All versions of restfull-client-mapper with dependencies
jms/metadata Version ^1
doctrine/annotations Version ^1
symfony/serializer Version ^3
guzzlehttp/guzzle Version ^6
symfony/yaml Version ^3
ocramius/proxy-manager Version ^2.0|^2
doctrine/common Version ^2.7|^2