Download the PHP package voilab/mapping without Composer
On this page you can find all versions of the php package voilab/mapping. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download voilab/mapping
More information about voilab/mapping
Files in voilab/mapping
Package mapping
Short Description Mapping system to promote a constant output from a set of datas
License MIT
Homepage http://www.voilab.ch
Informations about the package mapping
Voilab Mapping system
Install
Via Composer
Create a composer.json file in your project root:
Sample dataset
Examples
This piece of script helps you to obtain a constant output structure no matter how the input data is hydrated (array or object).
Simple mapping
Function call mapping
One-to-one or many-to-one relation mapping
One-to-many or many-to-many relation mapping
Complex relation mapping
Change mapping key
Change relation mapping key
As an alternative, you may use this notation below. Code should not change anytime soon.
Wildcard mapping
It's experimental with objects.
Advanced function mapping usage
You may want to access the current index inside your function if you are inside a collection. It's as easy as:
Hydrators
Hydrators are objects that extract data from the initial source. Two defaults, packaged in this lib, are for array management and simple objects (with getters and setters camelcased).
Change hydrators
If your data needs to be handled differently, you will need to create your own hydrators (which must extend \voilab\mapping\Hydrator) and then set them at construction time:
Please check packaged hydrators sources to see how it works. It's quite simple.
Plugins
Introduction
Configuration
The plugin "Deep one-to-one or many-to-one relation mapping" is always active. If you want to add other plugins, just do this when initializing the mapping object:
Disable plugin management
If you don't want to call any plugin (even the default one), simply set the plugin key separator to null.
Deep one-to-one or many-to-one relation mapping
Goes through a tree of one-to-one or many-to-one relations, until it reaches the key (here: type for section and name for interests).
Deep first one-to-many or many-to-many relation mapping
When encountering a one-to-many or many-to-many relation, it fetch the 1st element in the collection, and then tries to fetch the other relations, before accessing the key (here: name).
Testing
Security
If you discover any security related issues, please use the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.