Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2.  
  3. use Bouh\CouchBaseMapper\MapperConfigurationObject;
  4. use Bouh\CouchBaseMapper\MapperConfiguration;
  5. use Bouh\CouchBaseMapper\Mapper;
  6.  
  7. $mapperConfiguration = new MapperConfiguration();
  8.  
  9. $mapperConfigurationObject = new MapperConfigurationObject(Bouh\Demo\Entity\City::class);
  10. $mapperConfigurationObject
  11. ->attributeUseMethod('id', 'setId', 'getId')
  12. ->attributeUseMethod('name', 'setName', 'getName')
  13. ->attributeUseObject('country', Bouh\Demo\Entity\Country::class, 'countryIs', 'getCountry')
  14. ->attributeUseCollectionObject('countries', Bouh\Demo\Entity\Country::class, 'countriesAre', 'getCountries')
  15. ->mapperConfigurationIs($mapperConfiguration);
  16.  
  17. $mapperConfigurationObject = new MapperConfigurationObject(Bouh\Demo\Entity\Country::class);
  18. $mapperConfigurationObject
  19. ->attributeUseMethod('code', 'setCode', 'getCode')
  20. ->attributeUseMethod('name', 'setName', 'getName')
  21. ->attributeUseObject('city', Bouh\Demo\Entity\City::class, 'cityIs', 'getCity')
  22. ->mapperConfigurationIs($mapperConfiguration);
  23.  
  24. /*
  25. Et toujours la possibilité de faire :
  26.  
  27. ->attributeUseHandler('countries', Bouh\Demo\Entity\Country::class,
  28. function () {},
  29. function (Mapper $mapper, $city, $values) {
  30. $objects = [];
  31. foreach ($values as $objectData) {
  32. $object = new Bouh\Demo\Entity\Country();
  33. $mapper->setObject($object, Bouh\Demo\Entity\Country::class, $objectData);
  34. $objects[] = $object;
  35. }
  36.  
  37. $city->countriesAre($objects);
  38. }
  39. )
  40. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement