2017 © Pedro Peláez
 

library lib-import-orm

ORM providers for the import library of the Ride framework

image

ride/lib-import-orm

ORM providers for the import library of the Ride framework

  • Tuesday, May 29, 2018
  • by ride-user
  • Repository
  • 9 Watchers
  • 0 Stars
  • 2,393 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Ride: Import Library

ORM providers for the import library of the PHP Ride framework., (*1)

Code Sample

Check this code sample to see how to use these providers:, (*2)

<?php

use ride\library\decorator\BooleanDecorator;
use ride\library\import\mapper\GenericMapper;
use ride\library\import\provider\orm\OrmSourceProvider;
use ride\library\import\provider\orm\OrmDestinationProvider;
use ride\library\import\GenericImporter;
use ride\library\orm\OrmManager;
use ride\library\reflection\ReflectionHelper;

function importModel(OrmManager $orm, ReflectionHelper $reflectionHelper) {
    $sourceProvider = new OrmSourceProvider($orm->getModel('Source'), $reflectionHelper);
    $destinationProvider = new OrmSourceProvider($orm->getModel('Destination'), $reflectionHelper);

    // create a mapping to translate values from the source to the destination
    $mapper = new GenericMapper();
    $mapper->mapColumn(array('name', 'firstname'), 'fullName');
    // glue street, number and box together; use a space between street and number, then use a slash to add the box
    $mapper->mapColumn(array('street', 'number', 'box'), 'address', array(' ', '/'));
    $mapper->mapColumn('postalCode', 'postalCode');
    $mapper->mapColumn('city', 'city');
    $mapper->mapColumn('subscribe_newsletter', 'isNewsletter');
    // you can add decorators to process the resulting value
    $mapper->addDecorator('isNewsletter', new BooleanDecorator());

    // initialize importer with providers and mapper
    $importer = new GenericImporter();
    $importer->setSourceProvider($sourceProvider);
    $importer->setDestinationProvider($destinationProvider);
    $importer->addMapper($mapper);

    $importer->import();
}

Installation

You can use Composer to install this library., (*3)

composer require ride/lib-import-orm

The Versions

29/05 2018

dev-master

9999999-dev

ORM providers for the import library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

29/05 2018

1.0.1

1.0.1.0

ORM providers for the import library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

29/05 2018

dev-develop

dev-develop

ORM providers for the import library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

13/10 2016

1.0.0

1.0.0.0

ORM providers for the import library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd