Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Bouh\CouchBaseMapper\MapperConfigurationObject;
- use Bouh\CouchBaseMapper\MapperConfiguration;
- use Bouh\CouchBaseMapper\Mapper;
- $mapperConfiguration = new MapperConfiguration();
- $mapperConfigurationObject = new MapperConfigurationObject(Bouh\Demo\Entity\City::class);
- $mapperConfigurationObject
- ->attributeUseMethod('id', 'setId', 'getId')
- ->attributeUseMethod('name', 'setName', 'getName')
- ->attributeUseObject('country', Bouh\Demo\Entity\Country::class, 'countryIs', 'getCountry')
- ->attributeUseCollectionObject('countries', Bouh\Demo\Entity\Country::class, 'countriesAre', 'getCountries')
- ->mapperConfigurationIs($mapperConfiguration);
- $mapperConfigurationObject = new MapperConfigurationObject(Bouh\Demo\Entity\Country::class);
- $mapperConfigurationObject
- ->attributeUseMethod('code', 'setCode', 'getCode')
- ->attributeUseMethod('name', 'setName', 'getName')
- ->attributeUseObject('city', Bouh\Demo\Entity\City::class, 'cityIs', 'getCity')
- ->mapperConfigurationIs($mapperConfiguration);
- /*
- Et toujours la possibilité de faire :
- ->attributeUseHandler('countries', Bouh\Demo\Entity\Country::class,
- function () {},
- function (Mapper $mapper, $city, $values) {
- $objects = [];
- foreach ($values as $objectData) {
- $object = new Bouh\Demo\Entity\Country();
- $mapper->setObject($object, Bouh\Demo\Entity\Country::class, $objectData);
- $objects[] = $object;
- }
- $city->countriesAre($objects);
- }
- )
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement